Upload folder using huggingface_hub
Browse files
README.md
CHANGED
@@ -29,23 +29,23 @@ InternVL 2.0 is a multimodal large language model series, featuring models of va
|
|
29 |
| :--------------------------: | :-------------: | :------------: | :-----------: | :------------------: |
|
30 |
| Model Size | - | - | 40B | 76B |
|
31 |
| | | | | |
|
32 |
-
| DocVQA<sub>test</sub> | 87.2 | 86.5 | 93.9 |
|
33 |
| ChartQA<sub>test</sub> | 78.1 | 81.3 | 86.2 | 88.4 |
|
34 |
| InfoVQA<sub>test</sub> | - | 72.7 | 78.7 | 82.0 |
|
35 |
| TextVQA<sub>val</sub> | - | 73.5 | 83.0 | 84.4 |
|
36 |
-
| OCRBench | 678 | 754 | 837 |
|
37 |
| MME<sub>sum</sub> | 2070.2 | 2110.6 | 2315.0 | 2414.7 |
|
38 |
-
| RealWorldQA | 68.0 | 67.5 | 71.8 |
|
39 |
| AI2D<sub>test</sub> | 89.4 | 80.3 | 87.1 | 87.6 |
|
40 |
-
| MMMU<sub>val</sub> |
|
41 |
| MMBench-EN<sub>test</sub> | 81.0 | 73.9 | 86.8 | 86.5 |
|
42 |
| MMBench-CN<sub>test</sub> | 80.2 | 73.8 | 86.5 | 86.3 |
|
43 |
| CCBench<sub>dev</sub> | 57.3 | 28.4 | 80.6 | 81.0 |
|
44 |
| MMVet<sub>GPT-4-0613</sub> | - | - | 68.5 | 69.8 |
|
45 |
-
| MMVet<sub>GPT-4-Turbo</sub> | 67.5 | 64.0 | 65.5 |
|
46 |
| SEED-Image | - | - | 78.2 | 78.2 |
|
47 |
-
| HallBench<sub>avg</sub> | 43.9 | 45.6 | 56.9 |
|
48 |
-
| MathVista<sub>testmini</sub> | 58.1 | 57.7 | 63.7 |
|
49 |
|
50 |
- We simultaneously use InternVL and VLMEvalKit repositories for model evaluation. Specifically, the results reported for DocVQA, ChartQA, InfoVQA, TextVQA, MME, AI2D, MMBench, CCBench, MMVet, and SEED-Image were tested using the InternVL repository. MMMU, OCRBench, RealWorldQA, HallBench, and MathVista were evaluated using the VLMEvalKit.
|
51 |
|
@@ -59,7 +59,7 @@ InternVL 2.0 is a multimodal large language model series, featuring models of va
|
|
59 |
| :------------------: | :----: | :------: | :--------------: | :-----------: | :------------------: |
|
60 |
| Model Size | - | 34B | 34B | 40B | 76B |
|
61 |
| | | | | | |
|
62 |
-
| MVBench | - | - | - | 72.5 |
|
63 |
| Video-MME<br>wo subs | 59.9 | 59.0 | 52.0 | TODO | TODO |
|
64 |
| Video-MME<br>w/ subs | 63.3 | 59.4 | 54.9 | TODO | TODO |
|
65 |
|
@@ -76,6 +76,7 @@ We also welcome you to experience the InternVL2 series models in our [online dem
|
|
76 |
> Please use transformers==4.37.2 to ensure the model works normally.
|
77 |
|
78 |
```python
|
|
|
79 |
import numpy as np
|
80 |
import torch
|
81 |
import torchvision.transforms as T
|
@@ -163,17 +164,44 @@ def load_image(image_file, input_size=448, max_num=6):
|
|
163 |
return pixel_values
|
164 |
|
165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
path = 'OpenGVLab/InternVL2-Llama3-76B'
|
167 |
-
|
168 |
-
|
169 |
-
|
|
|
170 |
model = AutoModel.from_pretrained(
|
171 |
path,
|
172 |
torch_dtype=torch.bfloat16,
|
|
|
173 |
low_cpu_mem_usage=True,
|
174 |
trust_remote_code=True,
|
175 |
-
device_map=
|
176 |
-
|
177 |
tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
|
178 |
# set the max number of tiles in `max_num`
|
179 |
pixel_values = load_image('./examples/image1.jpg', max_num=6).to(torch.bfloat16).cuda()
|
@@ -317,6 +345,10 @@ print(f'User: {question}')
|
|
317 |
print(f'Assistant: {response}')
|
318 |
```
|
319 |
|
|
|
|
|
|
|
|
|
320 |
## Deployment
|
321 |
|
322 |
### LMDeploy
|
@@ -374,23 +406,23 @@ InternVL 2.0 是一个多模态大语言模型系列,包含各种规模的模
|
|
374 |
| :--------------------------: | :-------------: | :------------: | :-----------: | :------------------: |
|
375 |
| 模型大小 | - | - | 40B | 76B |
|
376 |
| | | | | |
|
377 |
-
| DocVQA<sub>test</sub> | 87.2 | 86.5 | 93.9 |
|
378 |
-
| ChartQA<sub>test</sub> | 78.1 | 81.3 | 86.2 |
|
379 |
-
| InfoVQA<sub>test</sub> | - | 72.7 | 78.7 |
|
380 |
-
| TextVQA<sub>val</sub> | - | 73.5 | 83.0 |
|
381 |
-
| OCRBench | 678 | 754 | 837 |
|
382 |
-
| MME<sub>sum</sub> | 2070.2 | 2110.6 | 2315.0 |
|
383 |
-
| RealWorldQA | 68.0 | 67.5 | 71.8 |
|
384 |
-
| AI2D<sub>test</sub> | 89.4 | 80.3 | 87.1 |
|
385 |
-
| MMMU<sub>val</sub> |
|
386 |
-
| MMBench-EN<sub>test</sub> | 81.0 | 73.9 | 86.8 |
|
387 |
-
| MMBench-CN<sub>test</sub> | 80.2 | 73.8 | 86.5 |
|
388 |
-
| CCBench<sub>dev</sub> | 57.3 | 28.4 | 80.6 |
|
389 |
-
| MMVet<sub>GPT-4-0613</sub> | - | - | 68.5 |
|
390 |
-
| MMVet<sub>GPT-4-Turbo</sub> | 67.5 | 64.0 | 65.5 |
|
391 |
-
| SEED-Image | - | - | 78.2 |
|
392 |
-
| HallBench<sub>avg</sub> | 43.9 | 45.6 | 56.9 |
|
393 |
-
| MathVista<sub>testmini</sub> | 58.1 | 57.7 | 63.7 |
|
394 |
|
395 |
- 我们同时使用 InternVL 和 VLMEvalKit 仓库进行模型评估。具体来说,DocVQA、ChartQA、InfoVQA、TextVQA、MME、AI2D、MMBench、CCBench、MMVet 和 SEED-Image 的结果是使用 InternVL 仓库测试的。MMMU、OCRBench、RealWorldQA、HallBench 和 MathVista 是使用 VLMEvalKit 进行评估的。
|
396 |
|
@@ -404,7 +436,7 @@ InternVL 2.0 是一个多模态大语言模型系列,包含各种规模的模
|
|
404 |
| :------------------: | :----: | :------: | :--------------: | :-----------: | :------------------: |
|
405 |
| 模型大小 | - | 34B | 34B | 40B | 76B |
|
406 |
| | | | | | |
|
407 |
-
| MVBench | - | - | - | 72.5 |
|
408 |
| Video-MME<br>wo subs | 59.9 | 59.0 | 52.0 | TODO | TODO |
|
409 |
| Video-MME<br>w/ subs | 63.3 | 59.4 | 54.9 | TODO | TODO |
|
410 |
|
@@ -422,6 +454,10 @@ InternVL 2.0 是一个多模态大语言模型系列,包含各种规模的模
|
|
422 |
|
423 |
示例代码请[点击这里](#quick-start)。
|
424 |
|
|
|
|
|
|
|
|
|
425 |
## 部署
|
426 |
|
427 |
### LMDeploy
|
|
|
29 |
| :--------------------------: | :-------------: | :------------: | :-----------: | :------------------: |
|
30 |
| Model Size | - | - | 40B | 76B |
|
31 |
| | | | | |
|
32 |
+
| DocVQA<sub>test</sub> | 87.2 | 86.5 | 93.9 | 94.1 |
|
33 |
| ChartQA<sub>test</sub> | 78.1 | 81.3 | 86.2 | 88.4 |
|
34 |
| InfoVQA<sub>test</sub> | - | 72.7 | 78.7 | 82.0 |
|
35 |
| TextVQA<sub>val</sub> | - | 73.5 | 83.0 | 84.4 |
|
36 |
+
| OCRBench | 678 | 754 | 837 | 839 |
|
37 |
| MME<sub>sum</sub> | 2070.2 | 2110.6 | 2315.0 | 2414.7 |
|
38 |
+
| RealWorldQA | 68.0 | 67.5 | 71.8 | 72.2 |
|
39 |
| AI2D<sub>test</sub> | 89.4 | 80.3 | 87.1 | 87.6 |
|
40 |
+
| MMMU<sub>val</sub> | 63.1 / 61.7 | 58.5 / 60.6 | 53.9 / 55.2 | 55.2 / 58.2 |
|
41 |
| MMBench-EN<sub>test</sub> | 81.0 | 73.9 | 86.8 | 86.5 |
|
42 |
| MMBench-CN<sub>test</sub> | 80.2 | 73.8 | 86.5 | 86.3 |
|
43 |
| CCBench<sub>dev</sub> | 57.3 | 28.4 | 80.6 | 81.0 |
|
44 |
| MMVet<sub>GPT-4-0613</sub> | - | - | 68.5 | 69.8 |
|
45 |
+
| MMVet<sub>GPT-4-Turbo</sub> | 67.5 | 64.0 | 65.5 | 65.7 |
|
46 |
| SEED-Image | - | - | 78.2 | 78.2 |
|
47 |
+
| HallBench<sub>avg</sub> | 43.9 | 45.6 | 56.9 | 55.2 |
|
48 |
+
| MathVista<sub>testmini</sub> | 58.1 | 57.7 | 63.7 | 65.5 |
|
49 |
|
50 |
- We simultaneously use InternVL and VLMEvalKit repositories for model evaluation. Specifically, the results reported for DocVQA, ChartQA, InfoVQA, TextVQA, MME, AI2D, MMBench, CCBench, MMVet, and SEED-Image were tested using the InternVL repository. MMMU, OCRBench, RealWorldQA, HallBench, and MathVista were evaluated using the VLMEvalKit.
|
51 |
|
|
|
59 |
| :------------------: | :----: | :------: | :--------------: | :-----------: | :------------------: |
|
60 |
| Model Size | - | 34B | 34B | 40B | 76B |
|
61 |
| | | | | | |
|
62 |
+
| MVBench | - | - | - | 72.5 | 69.6 |
|
63 |
| Video-MME<br>wo subs | 59.9 | 59.0 | 52.0 | TODO | TODO |
|
64 |
| Video-MME<br>w/ subs | 63.3 | 59.4 | 54.9 | TODO | TODO |
|
65 |
|
|
|
76 |
> Please use transformers==4.37.2 to ensure the model works normally.
|
77 |
|
78 |
```python
|
79 |
+
import math
|
80 |
import numpy as np
|
81 |
import torch
|
82 |
import torchvision.transforms as T
|
|
|
164 |
return pixel_values
|
165 |
|
166 |
|
167 |
+
def split_model(model_name):
|
168 |
+
device_map = {}
|
169 |
+
world_size = torch.cuda.device_count()
|
170 |
+
num_layers = {'InternVL2-8B': 32, 'InternVL2-26B': 48,
|
171 |
+
'InternVL2-40B': 60, 'InternVL2-Llama3-76B': 80}[model_name]
|
172 |
+
# Since the first GPU will be used for ViT, treat it as half a GPU.
|
173 |
+
num_layers_per_gpu = math.ceil(num_layers / (world_size - 0.5))
|
174 |
+
num_layers_per_gpu = [num_layers_per_gpu] * world_size
|
175 |
+
num_layers_per_gpu[0] = math.ceil(num_layers_per_gpu[0] * 0.5)
|
176 |
+
layer_cnt = 0
|
177 |
+
for i, num_layer in enumerate(num_layers_per_gpu):
|
178 |
+
for j in range(num_layer):
|
179 |
+
device_map[f'language_model.model.layers.{layer_cnt}'] = i
|
180 |
+
layer_cnt += 1
|
181 |
+
device_map['vision_model'] = 0
|
182 |
+
device_map['mlp1'] = 0
|
183 |
+
device_map['language_model.model.tok_embeddings'] = 0
|
184 |
+
device_map['language_model.model.embed_tokens'] = 0
|
185 |
+
device_map['language_model.output'] = 0
|
186 |
+
device_map['language_model.model.norm'] = 0
|
187 |
+
device_map['language_model.lm_head'] = 0
|
188 |
+
device_map[f'language_model.model.layers.{num_layers - 1}'] = 0
|
189 |
+
|
190 |
+
return device_map
|
191 |
+
|
192 |
+
|
193 |
path = 'OpenGVLab/InternVL2-Llama3-76B'
|
194 |
+
device_map = split_model('InternVL2-Llama3-76B')
|
195 |
+
print(device_map)
|
196 |
+
# If you set `load_in_8bit=True`, you will need two 80GB GPUs.
|
197 |
+
# If you set `load_in_8bit=False`, you will need at least three 80GB GPUs.
|
198 |
model = AutoModel.from_pretrained(
|
199 |
path,
|
200 |
torch_dtype=torch.bfloat16,
|
201 |
+
load_in_8bit=True,
|
202 |
low_cpu_mem_usage=True,
|
203 |
trust_remote_code=True,
|
204 |
+
device_map=device_map).eval()
|
|
|
205 |
tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
|
206 |
# set the max number of tiles in `max_num`
|
207 |
pixel_values = load_image('./examples/image1.jpg', max_num=6).to(torch.bfloat16).cuda()
|
|
|
345 |
print(f'Assistant: {response}')
|
346 |
```
|
347 |
|
348 |
+
## Finetune
|
349 |
+
|
350 |
+
SWIFT from ModelScope community has supported the fine-tuning (Image/Video) of InternVL, please check [this link](https://github.com/modelscope/swift/blob/main/docs/source_en/Multi-Modal/internvl-best-practice.md) for more details.
|
351 |
+
|
352 |
## Deployment
|
353 |
|
354 |
### LMDeploy
|
|
|
406 |
| :--------------------------: | :-------------: | :------------: | :-----------: | :------------------: |
|
407 |
| 模型大小 | - | - | 40B | 76B |
|
408 |
| | | | | |
|
409 |
+
| DocVQA<sub>test</sub> | 87.2 | 86.5 | 93.9 | 94.1 |
|
410 |
+
| ChartQA<sub>test</sub> | 78.1 | 81.3 | 86.2 | 88.4 |
|
411 |
+
| InfoVQA<sub>test</sub> | - | 72.7 | 78.7 | 82.0 |
|
412 |
+
| TextVQA<sub>val</sub> | - | 73.5 | 83.0 | 84.4 |
|
413 |
+
| OCRBench | 678 | 754 | 837 | 839 |
|
414 |
+
| MME<sub>sum</sub> | 2070.2 | 2110.6 | 2315.0 | 2414.7 |
|
415 |
+
| RealWorldQA | 68.0 | 67.5 | 71.8 | 72.2 |
|
416 |
+
| AI2D<sub>test</sub> | 89.4 | 80.3 | 87.1 | 87.6 |
|
417 |
+
| MMMU<sub>val</sub> | 63.1 / 61.7 | 58.5 / 60.6 | 53.9 / 55.2 | 55.2 / 58.2 |
|
418 |
+
| MMBench-EN<sub>test</sub> | 81.0 | 73.9 | 86.8 | 86.5 |
|
419 |
+
| MMBench-CN<sub>test</sub> | 80.2 | 73.8 | 86.5 | 86.3 |
|
420 |
+
| CCBench<sub>dev</sub> | 57.3 | 28.4 | 80.6 | 81.0 |
|
421 |
+
| MMVet<sub>GPT-4-0613</sub> | - | - | 68.5 | 69.8 |
|
422 |
+
| MMVet<sub>GPT-4-Turbo</sub> | 67.5 | 64.0 | 65.5 | 65.7 |
|
423 |
+
| SEED-Image | - | - | 78.2 | 78.2 |
|
424 |
+
| HallBench<sub>avg</sub> | 43.9 | 45.6 | 56.9 | 55.2 |
|
425 |
+
| MathVista<sub>testmini</sub> | 58.1 | 57.7 | 63.7 | 65.5 |
|
426 |
|
427 |
- 我们同时使用 InternVL 和 VLMEvalKit 仓库进行模型评估。具体来说,DocVQA、ChartQA、InfoVQA、TextVQA、MME、AI2D、MMBench、CCBench、MMVet 和 SEED-Image 的结果是使用 InternVL 仓库测试的。MMMU、OCRBench、RealWorldQA、HallBench 和 MathVista 是使用 VLMEvalKit 进行评估的。
|
428 |
|
|
|
436 |
| :------------------: | :----: | :------: | :--------------: | :-----------: | :------------------: |
|
437 |
| 模型大小 | - | 34B | 34B | 40B | 76B |
|
438 |
| | | | | | |
|
439 |
+
| MVBench | - | - | - | 72.5 | 69.6 |
|
440 |
| Video-MME<br>wo subs | 59.9 | 59.0 | 52.0 | TODO | TODO |
|
441 |
| Video-MME<br>w/ subs | 63.3 | 59.4 | 54.9 | TODO | TODO |
|
442 |
|
|
|
454 |
|
455 |
示例代码请[点击这里](#quick-start)。
|
456 |
|
457 |
+
## 微调
|
458 |
+
|
459 |
+
来自ModelScope社区的SWIFT已经支持对InternVL进行微调(图像/视频),详情请查看[此链接](https://github.com/modelscope/swift/blob/main/docs/source_en/Multi-Modal/internvl-best-practice.md)。
|
460 |
+
|
461 |
## 部署
|
462 |
|
463 |
### LMDeploy
|