czczup commited on
Commit
2e42dea
1 Parent(s): 9cac2f2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +155 -0
README.md CHANGED
@@ -1,3 +1,158 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ datasets:
4
+ - laion/laion2B-en
5
+ - laion/laion-coco
6
+ - laion/laion2B-multi
7
+ - kakaobrain/coyo-700m
8
+ - conceptual_captions
9
+ - wanng/wukong100m
10
  ---
11
+
12
+ # Model Card for InternVL-Chat-Chinese-V1.2
13
+
14
+ ## What is InternVL?
15
+
16
+ \[[Paper](https://arxiv.org/abs/2312.14238)\] \[[GitHub](https://github.com/OpenGVLab/InternVL)\] \[[Chat Demo](https://internvl.opengvlab.com/)\]
17
+
18
+ InternVL scales up the ViT to _**6B parameters**_ and aligns it with LLM.
19
+
20
+ ## InternVL-Chat-V1.2 Blog
21
+
22
+ > Date: 2024/02/12<br>
23
+ > Developed by: Zhe Chen, Weiyun Wang, Wenhai Wang, Erfei Cui, Zhangwei Gao, Xizhou Zhu, Lewei Lu, Tong Lu, Yu Qiao, Jifeng Dai
24
+
25
+ We are excited to introduce InternVL-Chat-V1.2. Inspired by [LLaVA-NeXT-34B](https://llava-vl.github.io/blog/2024-01-30-llava-next/), we have also adopted [Nous-Hermes-2-Yi-34B](https://huggingface.co/NousResearch/Nous-Hermes-2-Yi-34B) as the language model. Below is the pipeline.
26
+
27
+ <img width="600" alt="image" src="https://cdn-uploads.huggingface.co/production/uploads/64119264f0f81eb569e0d569/GIEKCvNc1Y5iMQqLv645p.png">
28
+
29
+ From the experimental results, **we've observed that a stronger language model (34B) can better leverage the powerful capabilities of our vision foundation model ([InternViT-6B](https://huggingface.co/OpenGVLab/InternViT-6B-448px-V1-2)).**
30
+
31
+ For better training reproducibility, we follow the minimalist design and data efficiency similar to LLaVA-NeXT. To reduce training costs, we provide a pre-trained MLP projector and only employ around 1 million visual instruction tuning samples for SFT. Our model has a total of 40 billion parameters and can be trained within 1.5 days using 32 A100 GPUs. The code, data, and model will be made publicly available.
32
+
33
+ ### Data Preparation
34
+
35
+ Inspired by LLaVA-NeXT, we adopted a data-efficient SFT strategy to train InternVL-Chat-V1.2, utilizing approximately 1.2M of visual instruction tuning samples in total, all of which are fully open-source. In a macro sense, we build upon [ShareGPT-4V](https://github.com/InternLM/InternLM-XComposer/blob/main/projects/ShareGPT4V/docs/Data.md#prepare-images) and additionally integrate [LLaVA-ZH](https://huggingface.co/datasets/openbmb/llava_zh), [DVQA](https://github.com/kushalkafle/DVQA_dataset), [ChartQA](https://github.com/vis-nlp/ChartQA), [AI2D](https://allenai.org/data/diagrams), [DocVQA](https://www.docvqa.org/datasets), [GeoQA+](https://github.com/SCNU203/GeoQA-Plus), and [SynthDoG-EN](https://huggingface.co/datasets/naver-clova-ix/synthdog-en). Most of the data remains consistent with LLaVA-NeXT.
36
+
37
+ For more details about data preparation, please see [here](https://github.com/OpenGVLab/InternVL/tree/main/internvl_chat#prepare-training-datasets).
38
+
39
+ ### Performance
40
+
41
+ \* Proprietary Model
42
+
43
+ | name | image size | MMMU<br>(val) | MMMU<br>(test) | MathVista<br>(testmini) | MMB<br>(test) | MMB−CN<br>(test) | MMVP | MME | ScienceQA<br>(image) | POPE | TextVQA<br>(val) | SEEDv1<br>(image) | VizWiz<br>(test) | GQA<br>(test) |
44
+ | ------------------ | ---------- | ------------- | -------------- | ----------------------- | ------------- | ---------------- | ---- | -------- | -------------------- | ---- | ------- | ----------------- | ---------------- | ------------- |
45
+ | GPT-4V\* | unknown | 56.8 | 55.7 | 49.9 | 77.0 | 74.4 | 38.7 | 1409/517 | - | - | 78.0 | 71.6 | - | - |
46
+ | Gemini Ultra\* | unknown | 59.4 | - | 53.0 | - | - | - | - | - | - | 82.3 | - | - | - |
47
+ | Gemini Pro\* | unknown | 47.9 | - | 45.2 | 73.6 | 74.3 | 40.7 | 1497/437 | - | - | 74.6 | 70.7 | - | - |
48
+ | Qwen-VL-Plus\* | unknown | 45.2 | 40.8 | 43.3 | 67.0 | 70.7 | - | 1681/502 | - | - | 78.9 | 65.7 | - | - |
49
+ | Qwen-VL-Max\* | unknown | 51.4 | 46.8 | 51.0 | 77.6 | 75.7 | - | - | - | - | 79.5 | - | - | - |
50
+ | | | | | | | | | | | | | | | |
51
+ | LLaVA-NEXT-34B | 672x672 | 51.1 | 44.7 | 46.5 | 79.3 | 79.0 | - | 1631/397 | 81.8 | 87.7 | 69.5 | 75.9 | 63.8 | 67.1 |
52
+ | InternVL-Chat-V1.2 | 448x448 | 51.6 | 46.2 | 47.7 | 82.2 | 81.2 | 56.7 | 1672/509 | 83.3 | 88.0 | 69.7 | 75.6 | 60.0 | 64.0 |
53
+
54
+ - MMBench results are collected from the [leaderboard](https://mmbench.opencompass.org.cn/leaderboard).
55
+ - In most benchmarks, InternVL-Chat-V1.2 achieves better performance than LLaVA-NeXT-34B.
56
+
57
+ ### Training (SFT)
58
+
59
+ We provide [slurm scripts](https://github.com/OpenGVLab/InternVL/tree/main/internvl_chat/shell/hermes2_yi34b/internvl_chat_v1_2_hermes2_yi34b_448_finetune.sh) for multi-node multi-GPU training. You can use either 32 or 64 GPUs to train this model. If you use 64 GPUs, training will take approximately 18 hours.
60
+
61
+ For more details about training, please see [here](https://github.com/OpenGVLab/InternVL/tree/main/internvl_chat#start-training).
62
+
63
+ The hyperparameters used for finetuning are listed in the following table.
64
+
65
+ | Hyperparameter | Trainable Param | Global Batch Size | Learning rate | Epochs | Max length | Weight decay |
66
+ | ------------------ | ---------------- | ----------------- | ------------- | ------ | ---------- | ------------ |
67
+ | InternVL-Chat-V1.2 | 40B (full model) | 512 | 1e-5 | 1 | 2048 | 0.05 |
68
+
69
+
70
+ ## Model Details
71
+ - **Model Type:** vision large language model, multimodal chatbot
72
+ - **Model Stats:**
73
+ - Architecture: [InternViT-6B-448px-V1-2](https://huggingface.co/OpenGVLab/InternViT-6B-448px-V1-2) + MLP + [Nous-Hermes-2-Yi-34B](https://huggingface.co/NousResearch/Nous-Hermes-2-Yi-34B)
74
+ - Params: 40B
75
+ - Image size: 448 x 448
76
+ - Number of visual tokens: 256
77
+
78
+ - **Training Strategy:**
79
+ - Pretraining Stage
80
+ - Learnable Component: MLP
81
+ - Data: Trained on 8192x4800=39.3M samples, including COYO, LAION, CC12M, CC3M, SBU, Wukong, GRIT, Objects365, OpenImages, and OCR data.
82
+ - Note: In this stage, we load the pretrained weights of [InternViT-6B-448px-V1-2](https://huggingface.co/OpenGVLab/InternViT-6B-448px-V1-2). Moreover, in order to reduce the number of visual tokens, we use a pixel shuffle to reduce 1024 tokens to 256 tokens.
83
+ - SFT Stage
84
+ - Learnable Component: ViT + MLP + LLM
85
+ - Data: A simplified, fully open-source dataset, containing approximately 1 million samples.
86
+
87
+
88
+ ## Model Usage
89
+
90
+ We provide a minimum code example to run InternVL-Chat using only the `transformers` library.
91
+
92
+ You also can use our [online demo](https://internvl.opengvlab.com/) for a quick experience of this model.
93
+
94
+ Note: If you meet this error `ImportError: This modeling file requires the following packages that were not found in your environment: fastchat`, please run `pip install fschat`.
95
+
96
+
97
+ ```python
98
+ import torch
99
+ from PIL import Image
100
+ from transformers import AutoModel, CLIPImageProcessor
101
+ from transformers import AutoTokenizer
102
+
103
+ path = "OpenGVLab/InternVL-Chat-Chinese-V1-2"
104
+ # If you have an 80G A100 GPU, you can put the entire model on a single GPU.
105
+ model = AutoModel.from_pretrained(
106
+ path,
107
+ torch_dtype=torch.bfloat16,
108
+ low_cpu_mem_usage=True,
109
+ trust_remote_code=True).eval().cuda()
110
+ # Otherwise, you need to set device_map='auto' to use multiple GPUs for inference.
111
+ # model = AutoModel.from_pretrained(
112
+ # path,
113
+ # torch_dtype=torch.bfloat16,
114
+ # low_cpu_mem_usage=True,
115
+ # trust_remote_code=True,
116
+ # device_map='auto').eval()
117
+
118
+ tokenizer = AutoTokenizer.from_pretrained(path)
119
+ image = Image.open('./examples/image2.jpg').convert('RGB')
120
+ image = image.resize((448, 448))
121
+ image_processor = CLIPImageProcessor.from_pretrained(path)
122
+
123
+ pixel_values = image_processor(images=image, return_tensors='pt').pixel_values
124
+ pixel_values = pixel_values.to(torch.bfloat16).cuda()
125
+
126
+ generation_config = dict(
127
+ num_beams=1,
128
+ max_new_tokens=512,
129
+ do_sample=False,
130
+ )
131
+
132
+ question = "请详细描述图片"
133
+ response = model.chat(tokenizer, pixel_values, question, generation_config)
134
+ ```
135
+
136
+
137
+ ## Citation
138
+
139
+ If you find this project useful in your research, please consider citing:
140
+
141
+ ```BibTeX
142
+ @article{chen2023internvl,
143
+ title={InternVL: Scaling up Vision Foundation Models and Aligning for Generic Visual-Linguistic Tasks},
144
+ author={Chen, Zhe and Wu, Jiannan and Wang, Wenhai and Su, Weijie and Chen, Guo and Xing, Sen and Zhong, Muyan and Zhang, Qinglong and Zhu, Xizhou and Lu, Lewei and Li, Bin and Luo, Ping and Lu, Tong and Qiao, Yu and Dai, Jifeng},
145
+ journal={arXiv preprint arXiv:2312.14238},
146
+ year={2023}
147
+ }
148
+ ```
149
+
150
+ ## License
151
+
152
+ This project is released under the MIT license. Parts of this project contain code and models (e.g., LLaMA2) from other sources, which are subject to their respective licenses.
153
+
154
+ Llama 2 is licensed under the LLAMA 2 Community License, Copyright (c) Meta Platforms, Inc. All Rights Reserved.
155
+
156
+ ## Acknowledgement
157
+
158
+ InternVL is built with reference to the code of the following projects: [OpenAI CLIP](https://github.com/openai/CLIP), [Open CLIP](https://github.com/mlfoundations/open_clip), [CLIP Benchmark](https://github.com/LAION-AI/CLIP_benchmark), [EVA](https://github.com/baaivision/EVA/tree/master), [InternImage](https://github.com/OpenGVLab/InternImage), [ViT-Adapter](https://github.com/czczup/ViT-Adapter), [MMSegmentation](https://github.com/open-mmlab/mmsegmentation), [Transformers](https://github.com/huggingface/transformers), [DINOv2](https://github.com/facebookresearch/dinov2), [BLIP-2](https://github.com/salesforce/LAVIS/tree/main/projects/blip2), [Qwen-VL](https://github.com/QwenLM/Qwen-VL/tree/master/eval_mm), and [LLaVA-1.5](https://github.com/haotian-liu/LLaVA). Thanks for their awesome work!