Add Hugging Face Space link to model card
Browse filesHi there,
This PR updates the model card for `OpenGVLab/InternVL3_5-14B` to include a direct link to its Hugging Face Space: [https://huggingface.co/spaces/OpenGVLab/InternVL](https://huggingface.co/spaces/OpenGVLab/InternVL). This enhances discoverability and makes it easier for users to access the interactive demo.
No other changes were made as the existing model card already provides comprehensive information, including the paper link, GitHub repository, sample usage, and relevant metadata.
Thanks!
README.md
CHANGED
|
@@ -1,25 +1,25 @@
|
|
| 1 |
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
pipeline_tag: image-text-to-text
|
| 4 |
-
library_name: transformers
|
| 5 |
base_model:
|
| 6 |
-
|
| 7 |
-
base_model_relation: finetune
|
| 8 |
datasets:
|
| 9 |
-
|
| 10 |
-
|
| 11 |
language:
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
| 13 |
tags:
|
| 14 |
-
|
| 15 |
-
|
|
|
|
| 16 |
---
|
| 17 |
|
| 18 |
# InternVL3_5-14B
|
| 19 |
|
| 20 |
[\[📂 GitHub\]](https://github.com/OpenGVLab/InternVL) [\[📜 InternVL 1.0\]](https://huggingface.co/papers/2312.14238) [\[📜 InternVL 1.5\]](https://huggingface.co/papers/2404.16821) [\[📜 InternVL 2.5\]](https://huggingface.co/papers/2412.05271) [\[📜 InternVL2.5-MPO\]](https://huggingface.co/papers/2411.10442) [\[📜 InternVL3\]](https://huggingface.co/papers/2504.10479) [\[📜 InternVL3.5\]](https://huggingface.co/papers/2508.18265)
|
| 21 |
|
| 22 |
-
[\[🆕 Blog\]](https://internvl.github.io/blog/) [\[🗨️ Chat Demo\]](https://chat.intern-ai.org.cn/)
|
| 23 |
|
| 24 |
<div align="center">
|
| 25 |
<img width="500" alt="image" src="https://cdn-uploads.huggingface.co/production/uploads/64006c09330a45b03605bba3/zJsd2hqd3EevgXo6fNgC-.png">
|
|
@@ -27,7 +27,7 @@ tags:
|
|
| 27 |
|
| 28 |
## Introduction
|
| 29 |
|
| 30 |
-
We introduce *InternVL3.5*, a new family of open-source multimodal models that significantly advances versatility, reasoning capability, and inference efficiency along the InternVL series. A key innovation is the *Cascade Reinforcement Learning (Cascade RL)* framework, which enhances reasoning through a two-stage process: offline RL for stable convergence and online RL for refined alignment. This coarse-to-fine training strategy leads to substantial improvements on downstream reasoning tasks, e.g., MMMU and MathVista. To optimize efficiency, we propose a *Visual Resolution Router (ViR)* that dynamically adjusts the resolution of visual tokens without compromising performance. Coupled with ViR, our Decoupled *Vision-Language Deployment (DvD)* strategy separates the vision encoder and language model across different GPUs, effectively balancing computational load. These contributions collectively enable InternVL3.5 to achieve up to a +16.0
|
| 31 |
|
| 32 |

|
| 33 |
|
|
@@ -141,7 +141,7 @@ Compared to InternVL3.5, InternVL3.5-Flash further integrates the *Visual Resolu
|
|
| 141 |
Specifically, in InternVL3.5, each image patch is initially represented as 1024 visual tokens for the vision encoder, which are then compressed into 256 tokens via a pixel shuffle module before being passed to the Large Language Model (LLM).
|
| 142 |
In InternVL3.5-Flash, as shown in the Figure below, an additional pixel shuffle module with a higher compression rate is included, enabling the compression of visual tokens down to 64 tokens.
|
| 143 |
For each patch, the patch router determines the appropriate compression rate by assessing its semantic richness, and routes it to the corresponding pixel shuffle module accordingly.
|
| 144 |
-
Benefiting from this patch-aware compression mechanism, InternVL3.5-Flash is able to reduce the number of visual tokens by 50
|
| 145 |
|
| 146 |
|
| 147 |

|
|
@@ -529,40 +529,50 @@ generation_config = dict(max_new_tokens=1024, do_sample=True)
|
|
| 529 |
# pure-text conversation (纯文本对话)
|
| 530 |
question = 'Hello, who are you?'
|
| 531 |
response, history = model.chat(tokenizer, None, question, generation_config, history=None, return_history=True)
|
| 532 |
-
print(f'User: {question}
|
|
|
|
| 533 |
|
| 534 |
question = 'Can you tell me a story?'
|
| 535 |
response, history = model.chat(tokenizer, None, question, generation_config, history=history, return_history=True)
|
| 536 |
-
print(f'User: {question}
|
|
|
|
| 537 |
|
| 538 |
# single-image single-round conversation (单图单轮对话)
|
| 539 |
-
question = '<image
|
|
|
|
| 540 |
response = model.chat(tokenizer, pixel_values, question, generation_config)
|
| 541 |
-
print(f'User: {question}
|
|
|
|
| 542 |
|
| 543 |
# single-image multi-round conversation (单图多轮对话)
|
| 544 |
-
question = '<image
|
|
|
|
| 545 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)
|
| 546 |
-
print(f'User: {question}
|
|
|
|
| 547 |
|
| 548 |
question = 'Please write a poem according to the image.'
|
| 549 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=history, return_history=True)
|
| 550 |
-
print(f'User: {question}
|
|
|
|
| 551 |
|
| 552 |
# multi-image multi-round conversation, combined images (多图多轮对话,拼接图像)
|
| 553 |
pixel_values1 = load_image('./examples/image1.jpg', max_num=12).to(torch.bfloat16).cuda()
|
| 554 |
pixel_values2 = load_image('./examples/image2.jpg', max_num=12).to(torch.bfloat16).cuda()
|
| 555 |
pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
|
| 556 |
|
| 557 |
-
question = '<image
|
|
|
|
| 558 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config,
|
| 559 |
history=None, return_history=True)
|
| 560 |
-
print(f'User: {question}
|
|
|
|
| 561 |
|
| 562 |
question = 'What are the similarities and differences between these two images.'
|
| 563 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config,
|
| 564 |
history=history, return_history=True)
|
| 565 |
-
print(f'User: {question}
|
|
|
|
| 566 |
|
| 567 |
# multi-image multi-round conversation, separate images (多图多轮对话,独立图像)
|
| 568 |
pixel_values1 = load_image('./examples/image1.jpg', max_num=12).to(torch.bfloat16).cuda()
|
|
@@ -570,17 +580,21 @@ pixel_values2 = load_image('./examples/image2.jpg', max_num=12).to(torch.bfloat1
|
|
| 570 |
pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
|
| 571 |
num_patches_list = [pixel_values1.size(0), pixel_values2.size(0)]
|
| 572 |
|
| 573 |
-
question = 'Image-1: <image
|
|
|
|
|
|
|
| 574 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config,
|
| 575 |
num_patches_list=num_patches_list,
|
| 576 |
history=None, return_history=True)
|
| 577 |
-
print(f'User: {question}
|
|
|
|
| 578 |
|
| 579 |
question = 'What are the similarities and differences between these two images.'
|
| 580 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config,
|
| 581 |
num_patches_list=num_patches_list,
|
| 582 |
history=history, return_history=True)
|
| 583 |
-
print(f'User: {question}
|
|
|
|
| 584 |
|
| 585 |
# batch inference, single image per sample (单图批处理)
|
| 586 |
pixel_values1 = load_image('./examples/image1.jpg', max_num=12).to(torch.bfloat16).cuda()
|
|
@@ -588,13 +602,15 @@ pixel_values2 = load_image('./examples/image2.jpg', max_num=12).to(torch.bfloat1
|
|
| 588 |
num_patches_list = [pixel_values1.size(0), pixel_values2.size(0)]
|
| 589 |
pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
|
| 590 |
|
| 591 |
-
questions = ['<image
|
|
|
|
| 592 |
responses = model.batch_chat(tokenizer, pixel_values,
|
| 593 |
num_patches_list=num_patches_list,
|
| 594 |
questions=questions,
|
| 595 |
generation_config=generation_config)
|
| 596 |
for question, response in zip(questions, responses):
|
| 597 |
-
print(f'User: {question}
|
|
|
|
| 598 |
|
| 599 |
# video multi-round conversation (视频多轮对话)
|
| 600 |
def get_index(bound, fps, max_frame, first_idx=0, num_segments=32):
|
|
@@ -632,17 +648,24 @@ def load_video(video_path, bound=None, input_size=448, max_num=1, num_segments=3
|
|
| 632 |
video_path = './examples/red-panda.mp4'
|
| 633 |
pixel_values, num_patches_list = load_video(video_path, num_segments=8, max_num=1)
|
| 634 |
pixel_values = pixel_values.to(torch.bfloat16).cuda()
|
| 635 |
-
video_prefix = ''.join([f'Frame{i+1}: <image
|
|
|
|
| 636 |
question = video_prefix + 'What is the red panda doing?'
|
| 637 |
-
# Frame1: <image
|
|
|
|
|
|
|
|
|
|
|
|
|
| 638 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config,
|
| 639 |
num_patches_list=num_patches_list, history=None, return_history=True)
|
| 640 |
-
print(f'User: {question}
|
|
|
|
| 641 |
|
| 642 |
question = 'Describe this video in detail.'
|
| 643 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config,
|
| 644 |
num_patches_list=num_patches_list, history=history, return_history=True)
|
| 645 |
-
print(f'User: {question}
|
|
|
|
| 646 |
```
|
| 647 |
|
| 648 |
#### Streaming Output
|
|
@@ -726,7 +749,150 @@ image_urls=[
|
|
| 726 |
|
| 727 |
images = [load_image(img_url) for img_url in image_urls]
|
| 728 |
# Numbering images improves multi-image conversations
|
| 729 |
-
response = pipe((f'Image-1: {IMAGE_TOKEN}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 730 |
print(response.text)
|
| 731 |
```
|
| 732 |
|
|
@@ -828,4 +994,59 @@ If you find this project useful in your research, please consider citing:
|
|
| 828 |
journal={arXiv preprint arXiv:2508.18265},
|
| 829 |
year={2025}
|
| 830 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 831 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
| 2 |
base_model:
|
| 3 |
+
- OpenGVLab/InternVL3_5-14B-MPO
|
|
|
|
| 4 |
datasets:
|
| 5 |
+
- OpenGVLab/MMPR-v1.2
|
| 6 |
+
- OpenGVLab/MMPR-Tiny
|
| 7 |
language:
|
| 8 |
+
- multilingual
|
| 9 |
+
library_name: transformers
|
| 10 |
+
license: apache-2.0
|
| 11 |
+
pipeline_tag: image-text-to-text
|
| 12 |
tags:
|
| 13 |
+
- internvl
|
| 14 |
+
- custom_code
|
| 15 |
+
base_model_relation: finetune
|
| 16 |
---
|
| 17 |
|
| 18 |
# InternVL3_5-14B
|
| 19 |
|
| 20 |
[\[📂 GitHub\]](https://github.com/OpenGVLab/InternVL) [\[📜 InternVL 1.0\]](https://huggingface.co/papers/2312.14238) [\[📜 InternVL 1.5\]](https://huggingface.co/papers/2404.16821) [\[📜 InternVL 2.5\]](https://huggingface.co/papers/2412.05271) [\[📜 InternVL2.5-MPO\]](https://huggingface.co/papers/2411.10442) [\[📜 InternVL3\]](https://huggingface.co/papers/2504.10479) [\[📜 InternVL3.5\]](https://huggingface.co/papers/2508.18265)
|
| 21 |
|
| 22 |
+
[\[🆕 Blog\]](https://internvl.github.io/blog/) [\[🗨️ Chat Demo\]](https://chat.intern-ai.org.cn/) [\[🤗 HF Space\]](https://huggingface.co/spaces/OpenGVLab/InternVL) [\[🚀 Quick Start\]](#quick-start) [\[📖 Documents\]](https://internvl.readthedocs.io/en/latest/)
|
| 23 |
|
| 24 |
<div align="center">
|
| 25 |
<img width="500" alt="image" src="https://cdn-uploads.huggingface.co/production/uploads/64006c09330a45b03605bba3/zJsd2hqd3EevgXo6fNgC-.png">
|
|
|
|
| 27 |
|
| 28 |
## Introduction
|
| 29 |
|
| 30 |
+
We introduce *InternVL3.5*, a new family of open-source multimodal models that significantly advances versatility, reasoning capability, and inference efficiency along the InternVL series. A key innovation is the *Cascade Reinforcement Learning (Cascade RL)* framework, which enhances reasoning through a two-stage process: offline RL for stable convergence and online RL for refined alignment. This coarse-to-fine training strategy leads to substantial improvements on downstream reasoning tasks, e.g., MMMU and MathVista. To optimize efficiency, we propose a *Visual Resolution Router (ViR)* that dynamically adjusts the resolution of visual tokens without compromising performance. Coupled with ViR, our Decoupled *Vision-Language Deployment (DvD)* strategy separates the vision encoder and language model across different GPUs, effectively balancing computational load. These contributions collectively enable InternVL3.5 to achieve up to a +16.0% gain in overall reasoning performance and a 4.05 \\(\times\\) inference speedup compared to its predecessor, i.e., InternVL3. In addition, InternVL3.5 supports novel capabilities such as GUI interaction and embodied agency. Notably, our largest model, i.e., InternVL3.5-241B-A28B, attains state-of-the-art results among open-source MLLMs across general multimodal, reasoning, text, and agentic tasks—narrowing the performance gap with leading commercial models like GPT-5. All models and code are publicly released.
|
| 31 |
|
| 32 |

|
| 33 |
|
|
|
|
| 141 |
Specifically, in InternVL3.5, each image patch is initially represented as 1024 visual tokens for the vision encoder, which are then compressed into 256 tokens via a pixel shuffle module before being passed to the Large Language Model (LLM).
|
| 142 |
In InternVL3.5-Flash, as shown in the Figure below, an additional pixel shuffle module with a higher compression rate is included, enabling the compression of visual tokens down to 64 tokens.
|
| 143 |
For each patch, the patch router determines the appropriate compression rate by assessing its semantic richness, and routes it to the corresponding pixel shuffle module accordingly.
|
| 144 |
+
Benefiting from this patch-aware compression mechanism, InternVL3.5-Flash is able to reduce the number of visual tokens by 50% while maintaining nearly 100% of the performance of InternVL3.5.
|
| 145 |
|
| 146 |
|
| 147 |

|
|
|
|
| 529 |
# pure-text conversation (纯文本对话)
|
| 530 |
question = 'Hello, who are you?'
|
| 531 |
response, history = model.chat(tokenizer, None, question, generation_config, history=None, return_history=True)
|
| 532 |
+
print(f'User: {question}
|
| 533 |
+
Assistant: {response}')
|
| 534 |
|
| 535 |
question = 'Can you tell me a story?'
|
| 536 |
response, history = model.chat(tokenizer, None, question, generation_config, history=history, return_history=True)
|
| 537 |
+
print(f'User: {question}
|
| 538 |
+
Assistant: {response}')
|
| 539 |
|
| 540 |
# single-image single-round conversation (单图单轮对话)
|
| 541 |
+
question = '<image>
|
| 542 |
+
Please describe the image shortly.'
|
| 543 |
response = model.chat(tokenizer, pixel_values, question, generation_config)
|
| 544 |
+
print(f'User: {question}
|
| 545 |
+
Assistant: {response}')
|
| 546 |
|
| 547 |
# single-image multi-round conversation (单图多轮对话)
|
| 548 |
+
question = '<image>
|
| 549 |
+
Please describe the image in detail.'
|
| 550 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)
|
| 551 |
+
print(f'User: {question}
|
| 552 |
+
Assistant: {response}')
|
| 553 |
|
| 554 |
question = 'Please write a poem according to the image.'
|
| 555 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=history, return_history=True)
|
| 556 |
+
print(f'User: {question}
|
| 557 |
+
Assistant: {response}')
|
| 558 |
|
| 559 |
# multi-image multi-round conversation, combined images (多图多轮对话,拼接图像)
|
| 560 |
pixel_values1 = load_image('./examples/image1.jpg', max_num=12).to(torch.bfloat16).cuda()
|
| 561 |
pixel_values2 = load_image('./examples/image2.jpg', max_num=12).to(torch.bfloat16).cuda()
|
| 562 |
pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
|
| 563 |
|
| 564 |
+
question = '<image>
|
| 565 |
+
Describe the two images in detail.'
|
| 566 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config,
|
| 567 |
history=None, return_history=True)
|
| 568 |
+
print(f'User: {question}
|
| 569 |
+
Assistant: {response}')
|
| 570 |
|
| 571 |
question = 'What are the similarities and differences between these two images.'
|
| 572 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config,
|
| 573 |
history=history, return_history=True)
|
| 574 |
+
print(f'User: {question}
|
| 575 |
+
Assistant: {response}')
|
| 576 |
|
| 577 |
# multi-image multi-round conversation, separate images (多图多轮对话,独立图像)
|
| 578 |
pixel_values1 = load_image('./examples/image1.jpg', max_num=12).to(torch.bfloat16).cuda()
|
|
|
|
| 580 |
pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
|
| 581 |
num_patches_list = [pixel_values1.size(0), pixel_values2.size(0)]
|
| 582 |
|
| 583 |
+
question = 'Image-1: <image>
|
| 584 |
+
Image-2: <image>
|
| 585 |
+
Describe the two images in detail.'
|
| 586 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config,
|
| 587 |
num_patches_list=num_patches_list,
|
| 588 |
history=None, return_history=True)
|
| 589 |
+
print(f'User: {question}
|
| 590 |
+
Assistant: {response}')
|
| 591 |
|
| 592 |
question = 'What are the similarities and differences between these two images.'
|
| 593 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config,
|
| 594 |
num_patches_list=num_patches_list,
|
| 595 |
history=history, return_history=True)
|
| 596 |
+
print(f'User: {question}
|
| 597 |
+
Assistant: {response}')
|
| 598 |
|
| 599 |
# batch inference, single image per sample (单图批处理)
|
| 600 |
pixel_values1 = load_image('./examples/image1.jpg', max_num=12).to(torch.bfloat16).cuda()
|
|
|
|
| 602 |
num_patches_list = [pixel_values1.size(0), pixel_values2.size(0)]
|
| 603 |
pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
|
| 604 |
|
| 605 |
+
questions = ['<image>
|
| 606 |
+
Describe the image in detail.'] * len(num_patches_list)
|
| 607 |
responses = model.batch_chat(tokenizer, pixel_values,
|
| 608 |
num_patches_list=num_patches_list,
|
| 609 |
questions=questions,
|
| 610 |
generation_config=generation_config)
|
| 611 |
for question, response in zip(questions, responses):
|
| 612 |
+
print(f'User: {question}
|
| 613 |
+
Assistant: {response}')
|
| 614 |
|
| 615 |
# video multi-round conversation (视频多轮对话)
|
| 616 |
def get_index(bound, fps, max_frame, first_idx=0, num_segments=32):
|
|
|
|
| 648 |
video_path = './examples/red-panda.mp4'
|
| 649 |
pixel_values, num_patches_list = load_video(video_path, num_segments=8, max_num=1)
|
| 650 |
pixel_values = pixel_values.to(torch.bfloat16).cuda()
|
| 651 |
+
video_prefix = ''.join([f'Frame{i+1}: <image>
|
| 652 |
+
' for i in range(len(num_patches_list))])
|
| 653 |
question = video_prefix + 'What is the red panda doing?'
|
| 654 |
+
# Frame1: <image>
|
| 655 |
+
Frame2: <image>
|
| 656 |
+
...
|
| 657 |
+
Frame8: <image>
|
| 658 |
+
{question}
|
| 659 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config,
|
| 660 |
num_patches_list=num_patches_list, history=None, return_history=True)
|
| 661 |
+
print(f'User: {question}
|
| 662 |
+
Assistant: {response}')
|
| 663 |
|
| 664 |
question = 'Describe this video in detail.'
|
| 665 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config,
|
| 666 |
num_patches_list=num_patches_list, history=history, return_history=True)
|
| 667 |
+
print(f'User: {question}
|
| 668 |
+
Assistant: {response}')
|
| 669 |
```
|
| 670 |
|
| 671 |
#### Streaming Output
|
|
|
|
| 749 |
|
| 750 |
images = [load_image(img_url) for img_url in image_urls]
|
| 751 |
# Numbering images improves multi-image conversations
|
| 752 |
+
response = pipe((f'Image-1: {IMAGE_TOKEN}
|
| 753 |
+
Image-2: {IMAGE_TOKEN}
|
| 754 |
+
describe these two images', images))
|
| 755 |
+
print(response.text)
|
| 756 |
+
```
|
| 757 |
+
|
| 758 |
+
#### Batch Prompts Inference
|
| 759 |
+
|
| 760 |
+
Conducting inference with batch prompts is quite straightforward; just place them within a list structure:
|
| 761 |
+
|
| 762 |
+
```python
|
| 763 |
+
from lmdeploy import pipeline, PytorchEngineConfig
|
| 764 |
+
from lmdeploy.vl import load_image
|
| 765 |
+
|
| 766 |
+
# Please set tp=2 for the 38B version and tp=8 for the 241B-A28B version.
|
| 767 |
+
model = 'OpenGVLab/InternVL3_5-8B'
|
| 768 |
+
pipe = pipeline(model, backend_config=PytorchEngineConfig(session_len=32768, tp=1))
|
| 769 |
+
|
| 770 |
+
image_urls=[
|
| 771 |
+
"https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/human-pose.jpg",
|
| 772 |
+
"https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/det.jpg"
|
| 773 |
+
]
|
| 774 |
+
prompts = [('describe this image', load_image(img_url)) for img_url in image_urls]
|
| 775 |
+
response = pipe(prompts)
|
| 776 |
+
print(response)
|
| 777 |
+
```
|
| 778 |
+
|
| 779 |
+
#### Multi-turn Conversation
|
| 780 |
+
|
| 781 |
+
There are two ways to do the multi-turn conversations with the pipeline. One is to construct messages according to the format of OpenAI and use above introduced method, the other is to use the `pipeline.chat` interface.
|
| 782 |
+
|
| 783 |
+
```python
|
| 784 |
+
from lmdeploy import pipeline, PytorchEngineConfig, GenerationConfig
|
| 785 |
+
from lmdeploy.vl import load_image
|
| 786 |
+
|
| 787 |
+
# Please set tp=2 for the 38B version and tp=8 for the 241B-A28B version.
|
| 788 |
+
model = 'OpenGVLab/InternVL3_5-8B'
|
| 789 |
+
pipe = pipeline(model, backend_config=PytorchEngineConfig(session_len=32768, tp=1))
|
| 790 |
+
|
| 791 |
+
image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/human-pose.jpg')
|
| 792 |
+
gen_config = GenerationConfig(top_k=50, top_p=0.95, temperature=0.6, max_new_tokens=8192)
|
| 793 |
+
sess = pipe.chat(('describe this image', image), gen_config=gen_config)
|
| 794 |
+
print(sess.response.text)
|
| 795 |
+
sess = pipe.chat('What is the woman doing?', session=sess, gen_config=gen_config)
|
| 796 |
+
print(sess.response.text)
|
| 797 |
+
```
|
| 798 |
+
|
| 799 |
+
#### Service
|
| 800 |
+
|
| 801 |
+
LMDeploy's `api_server` enables models to be easily packed into services with a single command. The provided RESTful APIs are compatible with OpenAI's interfaces. Below are an example of service startup:
|
| 802 |
+
|
| 803 |
+
```shell
|
| 804 |
+
lmdeploy serve api_server OpenGVLab/InternVL3_5-8B --server-port 23333 --tp 1 --backend pytorch
|
| 805 |
+
```
|
| 806 |
+
|
| 807 |
+
To use the OpenAI-style interface, you need to install OpenAI:
|
| 808 |
+
|
| 809 |
+
```shell
|
| 810 |
+
pip install openai
|
| 811 |
+
```
|
| 812 |
+
|
| 813 |
+
Then, use the code below to make the API call:
|
| 814 |
+
|
| 815 |
+
```python
|
| 816 |
+
from openai import OpenAI
|
| 817 |
+
|
| 818 |
+
client = OpenAI(api_key='YOUR_API_KEY', base_url='http://0.0.0.0:23333/v1')
|
| 819 |
+
model_name = client.models.list().data[0].id
|
| 820 |
+
response = client.chat.completions.create(
|
| 821 |
+
model=model_name,
|
| 822 |
+
messages=[{
|
| 823 |
+
'role':
|
| 824 |
+
'user',
|
| 825 |
+
'content': [{
|
| 826 |
+
'type': 'text',
|
| 827 |
+
'text': 'describe this image',
|
| 828 |
+
}, {
|
| 829 |
+
'type': 'image_url',
|
| 830 |
+
'image_url': {
|
| 831 |
+
'url':
|
| 832 |
+
'https://modelscope.oss-cn-beijing.aliyuncs.com/resource/tiger.jpeg',
|
| 833 |
+
},
|
| 834 |
+
}],
|
| 835 |
+
}],
|
| 836 |
+
temperature=0.8,
|
| 837 |
+
top_p=0.8)
|
| 838 |
+
print(response)
|
| 839 |
+
```
|
| 840 |
+
|
| 841 |
+
## Finetune
|
| 842 |
+
|
| 843 |
+
Many repositories now support fine-tuning of the InternVL series models, including [InternVL](https://github.com/OpenGVLab/InternVL), [SWIFT](https://github.com/modelscope/ms-swift), [XTuner](https://github.com/InternLM/xtuner), and others. Please refer to their documentation for more details on fine-tuning.
|
| 844 |
+
|
| 845 |
+
## Deployment
|
| 846 |
+
|
| 847 |
+
### LMDeploy
|
| 848 |
+
|
| 849 |
+
LMDeploy is a toolkit for compressing, deploying, and serving LLMs & VLMs.
|
| 850 |
+
|
| 851 |
+
```sh
|
| 852 |
+
pip install lmdeploy>=0.9.1
|
| 853 |
+
```
|
| 854 |
+
|
| 855 |
+
LMDeploy abstracts the complex inference process of multi-modal Vision-Language Models (VLM) into an easy-to-use pipeline, similar to the Large Language Model (LLM) inference pipeline.
|
| 856 |
+
|
| 857 |
+
#### A 'Hello, world' Example
|
| 858 |
+
|
| 859 |
+
```python
|
| 860 |
+
from lmdeploy import pipeline, PytorchEngineConfig
|
| 861 |
+
from lmdeploy.vl import load_image
|
| 862 |
+
|
| 863 |
+
image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/tests/data/tiger.jpeg')
|
| 864 |
+
|
| 865 |
+
# Please set tp=2 for the 38B version and tp=8 for the 241B-A28B version.
|
| 866 |
+
model = 'OpenGVLab/InternVL3_5-8B'
|
| 867 |
+
pipe = pipeline(model, backend_config=PytorchEngineConfig(session_len=32768, tp=1))
|
| 868 |
+
|
| 869 |
+
response = pipe(('describe this image', image))
|
| 870 |
+
print(response.text)
|
| 871 |
+
```
|
| 872 |
+
|
| 873 |
+
#### Multi-images Inference
|
| 874 |
+
|
| 875 |
+
When dealing with multiple images, you can put them all in one list. Keep in mind that multiple images will lead to a higher number of input tokens, and as a result, the size of the context window typically needs to be increased.
|
| 876 |
+
|
| 877 |
+
```python
|
| 878 |
+
from lmdeploy import pipeline, PytorchEngineConfig
|
| 879 |
+
from lmdeploy.vl import load_image
|
| 880 |
+
from lmdeploy.vl.constants import IMAGE_TOKEN
|
| 881 |
+
|
| 882 |
+
# Please set tp=2 for the 38B version and tp=8 for the 241B-A28B version.
|
| 883 |
+
model = 'OpenGVLab/InternVL3_5-8B'
|
| 884 |
+
pipe = pipeline(model, backend_config=PytorchEngineConfig(session_len=32768, tp=1))
|
| 885 |
+
|
| 886 |
+
image_urls=[
|
| 887 |
+
'https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/human-pose.jpg',
|
| 888 |
+
'https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/demo/resources/det.jpg'
|
| 889 |
+
]
|
| 890 |
+
|
| 891 |
+
images = [load_image(img_url) for img_url in image_urls]
|
| 892 |
+
# Numbering images improves multi-image conversations
|
| 893 |
+
response = pipe((f'Image-1: {IMAGE_TOKEN}
|
| 894 |
+
Image-2: {IMAGE_TOKEN}
|
| 895 |
+
describe these two images', images))
|
| 896 |
print(response.text)
|
| 897 |
```
|
| 898 |
|
|
|
|
| 994 |
journal={arXiv preprint arXiv:2508.18265},
|
| 995 |
year={2025}
|
| 996 |
}
|
| 997 |
+
@article{zhu2025internvl3,
|
| 998 |
+
title={Internvl3: Exploring advanced training and test-time recipes for open-source multimodal models},
|
| 999 |
+
author={Zhu, Jinguo and Wang, Weiyun and Chen, Zhe and Liu, Zhaoyang and Ye, Shenglong and Gu, Lixin and Tian, Hao and Duan, Yuchen and Su, Weijie and Shao, Jie and others},
|
| 1000 |
+
journal={arXiv preprint arXiv:2504.10479},
|
| 1001 |
+
year={2025}
|
| 1002 |
+
}
|
| 1003 |
+
@article{chen2024expanding,
|
| 1004 |
+
title={Expanding Performance Boundaries of Open-Source Multimodal Models with Model, Data, and Test-Time Scaling},
|
| 1005 |
+
author={Chen, Zhe and Wang, Weiyun and Cao, Yue and Liu, Yangzhou and Gao, Zhangwei and Cui, Erfei and Zhu, Jinguo and Ye, Shenglong and Tian, Hao and Liu, Zhaoyang and others},
|
| 1006 |
+
journal={arXiv preprint arXiv:2412.05271},
|
| 1007 |
+
year={2024}
|
| 1008 |
+
}
|
| 1009 |
+
@article{wang2024mpo,
|
| 1010 |
+
title={Enhancing the Reasoning Ability of Multimodal Large Language Models via Mixed Preference Optimization},
|
| 1011 |
+
author={Wang, Weiyun and Chen, Zhe and Wang, Wenhai and Cao, Yue and Liu, Yangzhou and Gao, Zhangwei and Zhu, Jinguo and Zhu, Xizhou and Lu, Lewei and Qiao, Yu and Dai, Jifeng},
|
| 1012 |
+
journal={arXiv preprint arXiv:2411.10442},
|
| 1013 |
+
year={2024}
|
| 1014 |
+
}
|
| 1015 |
+
@article{gao2024mini,
|
| 1016 |
+
title={Mini-InternVL: a flexible-transfer pocket multi-modal model with 5% parameters and 90% performance},
|
| 1017 |
+
author={Gao, Zhangwei and Chen, Zhe and Cui, Erfei and Ren, Yiming and Wang, Weiyun and Zhu, Jinguo and Tian, Hao and Ye, Shenglong and He, Junjun and Zhu, Xizhou and others},
|
| 1018 |
+
journal={Visual Intelligence},
|
| 1019 |
+
volume={2},
|
| 1020 |
+
number={1},
|
| 1021 |
+
pages={1--17},
|
| 1022 |
+
year={2024},
|
| 1023 |
+
publisher={Springer}
|
| 1024 |
+
}
|
| 1025 |
+
@article{chen2024far,
|
| 1026 |
+
title={How far are we to gpt-4v? closing the gap to commercial multimodal models with open-source suites},
|
| 1027 |
+
author={Chen, Zhe and Wang, Weiyun and Tian, Hao and Ye, Shenglong and Gao, Zhangwei and Cui, Erfei and Tong, Wenwen and Hu, Kongzhi and Luo, Jiapeng and Ma, Zheng and others},
|
| 1028 |
+
journal={Science China Information Sciences},
|
| 1029 |
+
volume={67},
|
| 1030 |
+
number={12},
|
| 1031 |
+
pages={220101},
|
| 1032 |
+
year={2024},
|
| 1033 |
+
publisher={Springer}
|
| 1034 |
+
}
|
| 1035 |
+
@inproceedings{chen2024internvl,
|
| 1036 |
+
title={Internvl: Scaling up vision foundation models and aligning for generic visual-linguistic tasks},
|
| 1037 |
+
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 others},
|
| 1038 |
+
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
|
| 1039 |
+
pages={24185--24198},
|
| 1040 |
+
year={2024}
|
| 1041 |
+
}
|
| 1042 |
```
|
| 1043 |
+
|
| 1044 |
+
## Acknowledgement
|
| 1045 |
+
|
| 1046 |
+
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!
|
| 1047 |
+
|
| 1048 |
+
______________________________________________________________________
|
| 1049 |
+
|
| 1050 |
+
Scan the following QR Code, join our WeChat group.
|
| 1051 |
+
|
| 1052 |
+
<p align="center"><img width="300" alt="image" src="https://github.com/user-attachments/assets/f776df09-ebba-4fd5-80c2-fec4ff1518be"></p>
|