Add Hugging Face Space link to metadata for InternVL3_5-8B

#7
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +71 -33
README.md CHANGED
@@ -1,18 +1,20 @@
1
  ---
2
- license: apache-2.0
3
- pipeline_tag: image-text-to-text
4
- library_name: transformers
5
  base_model:
6
- - OpenGVLab/InternVL3_5-8B-MPO
7
- base_model_relation: finetune
8
  datasets:
9
- - OpenGVLab/MMPR-v1.2
10
- - OpenGVLab/MMPR-Tiny
11
  language:
12
- - multilingual
 
 
 
13
  tags:
14
- - internvl
15
- - custom_code
 
 
 
16
  ---
17
 
18
  # InternVL3_5-8B
@@ -27,7 +29,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\% 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
  ![image/jpg](https://huggingface.co/OpenGVLab/InternVL3_5-241B-A28B/resolve/main/images/performance.jpg)
33
 
@@ -141,7 +143,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\% while maintaining nearly 100\% of the performance of InternVL3.5.
145
 
146
 
147
  ![image/jpg](https://huggingface.co/OpenGVLab/InternVL3_5-241B-A28B/resolve/main/images/architecture.jpg)
@@ -524,45 +526,55 @@ tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True, use_fast
524
 
525
  # set the max number of tiles in `max_num`
526
  pixel_values = load_image('./examples/image1.jpg', max_num=12).to(torch.bfloat16).cuda()
527
- generation_config = dict(max_new_tokens=1024, do_sample=True)
528
 
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}\nAssistant: {response}')
 
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}\nAssistant: {response}')
 
537
 
538
  # single-image single-round conversation (单图单轮对话)
539
- question = '<image>\nPlease describe the image shortly.'
 
540
  response = model.chat(tokenizer, pixel_values, question, generation_config)
541
- print(f'User: {question}\nAssistant: {response}')
 
542
 
543
  # single-image multi-round conversation (单图多轮对话)
544
- question = '<image>\nPlease describe the image in detail.'
 
545
  response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)
546
- print(f'User: {question}\nAssistant: {response}')
 
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}\nAssistant: {response}')
 
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>\nDescribe the two images in detail.'
 
558
  response, history = model.chat(tokenizer, pixel_values, question, generation_config,
559
  history=None, return_history=True)
560
- print(f'User: {question}\nAssistant: {response}')
 
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}\nAssistant: {response}')
 
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 +582,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>\nImage-2: <image>\nDescribe the two images in detail.'
 
 
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}\nAssistant: {response}')
 
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}\nAssistant: {response}')
 
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 +604,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>\nDescribe the image in detail.'] * len(num_patches_list)
 
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}\nAssistant: {response}')
 
598
 
599
  # video multi-round conversation (视频多轮对话)
600
  def get_index(bound, fps, max_frame, first_idx=0, num_segments=32):
@@ -632,17 +650,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>\n' for i in range(len(num_patches_list))])
 
636
  question = video_prefix + 'What is the red panda doing?'
637
- # Frame1: <image>\nFrame2: <image>\n...\nFrame8: <image>\n{question}
 
 
 
 
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}\nAssistant: {response}')
 
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}\nAssistant: {response}')
 
646
  ```
647
 
648
  #### Streaming Output
@@ -726,7 +751,9 @@ 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}\nImage-2: {IMAGE_TOKEN}\ndescribe these two images', images))
 
 
730
  print(response.text)
731
  ```
732
 
@@ -829,3 +856,14 @@ If you find this project useful in your research, please consider citing:
829
  year={2025}
830
  }
831
  ```
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
 
 
 
2
  base_model:
3
+ - OpenGVLab/InternVL3_5-8B-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
+ spaces:
17
+ - OpenGVLab/InternVL
18
  ---
19
 
20
  # InternVL3_5-8B
 
29
 
30
  ## Introduction
31
 
32
+ 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.
33
 
34
  ![image/jpg](https://huggingface.co/OpenGVLab/InternVL3_5-241B-A28B/resolve/main/images/performance.jpg)
35
 
 
143
  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).
144
  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.
145
  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.
146
+ 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.
147
 
148
 
149
  ![image/jpg](https://huggingface.co/OpenGVLab/InternVL3_5-241B-A28B/resolve/main/images/architecture.jpg)
 
526
 
527
  # set the max number of tiles in `max_num`
528
  pixel_values = load_image('./examples/image1.jpg', max_num=12).to(torch.bfloat16).cuda()
529
+ generation_config = dict(max_new_tokens=1024, do_sample=False)
530
 
531
  # pure-text conversation (纯文本对话)
532
  question = 'Hello, who are you?'
533
  response, history = model.chat(tokenizer, None, question, generation_config, history=None, return_history=True)
534
+ print(f'User: {question}
535
+ Assistant: {response}')
536
 
537
  question = 'Can you tell me a story?'
538
  response, history = model.chat(tokenizer, None, question, generation_config, history=history, return_history=True)
539
+ print(f'User: {question}
540
+ Assistant: {response}')
541
 
542
  # single-image single-round conversation (单图单轮对话)
543
+ question = '<image>
544
+ Please describe the image shortly.'
545
  response = model.chat(tokenizer, pixel_values, question, generation_config)
546
+ print(f'User: {question}
547
+ Assistant: {response}')
548
 
549
  # single-image multi-round conversation (单图多轮对话)
550
+ question = '<image>
551
+ Please describe the image in detail.'
552
  response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)
553
+ print(f'User: {question}
554
+ Assistant: {response}')
555
 
556
  question = 'Please write a poem according to the image.'
557
  response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=history, return_history=True)
558
+ print(f'User: {question}
559
+ Assistant: {response}')
560
 
561
  # multi-image multi-round conversation, combined images (多图多轮对话,拼接图像)
562
  pixel_values1 = load_image('./examples/image1.jpg', max_num=12).to(torch.bfloat16).cuda()
563
  pixel_values2 = load_image('./examples/image2.jpg', max_num=12).to(torch.bfloat16).cuda()
564
  pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
565
 
566
+ question = '<image>
567
+ Describe the two images in detail.'
568
  response, history = model.chat(tokenizer, pixel_values, question, generation_config,
569
  history=None, return_history=True)
570
+ print(f'User: {question}
571
+ Assistant: {response}')
572
 
573
  question = 'What are the similarities and differences between these two images.'
574
  response, history = model.chat(tokenizer, pixel_values, question, generation_config,
575
  history=history, return_history=True)
576
+ print(f'User: {question}
577
+ Assistant: {response}')
578
 
579
  # multi-image multi-round conversation, separate images (多图多轮对话,独立图像)
580
  pixel_values1 = load_image('./examples/image1.jpg', max_num=12).to(torch.bfloat16).cuda()
 
582
  pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
583
  num_patches_list = [pixel_values1.size(0), pixel_values2.size(0)]
584
 
585
+ question = 'Image-1: <image>
586
+ Image-2: <image>
587
+ Describe the two images in detail.'
588
  response, history = model.chat(tokenizer, pixel_values, question, generation_config,
589
  num_patches_list=num_patches_list,
590
  history=None, return_history=True)
591
+ print(f'User: {question}
592
+ Assistant: {response}')
593
 
594
  question = 'What are the similarities and differences between these two images.'
595
  response, history = model.chat(tokenizer, pixel_values, question, generation_config,
596
  num_patches_list=num_patches_list,
597
  history=history, return_history=True)
598
+ print(f'User: {question}
599
+ Assistant: {response}')
600
 
601
  # batch inference, single image per sample (单图批处理)
602
  pixel_values1 = load_image('./examples/image1.jpg', max_num=12).to(torch.bfloat16).cuda()
 
604
  num_patches_list = [pixel_values1.size(0), pixel_values2.size(0)]
605
  pixel_values = torch.cat((pixel_values1, pixel_values2), dim=0)
606
 
607
+ questions = ['<image>
608
+ Describe the image in detail.'] * len(num_patches_list)
609
  responses = model.batch_chat(tokenizer, pixel_values,
610
  num_patches_list=num_patches_list,
611
  questions=questions,
612
  generation_config=generation_config)
613
  for question, response in zip(questions, responses):
614
+ print(f'User: {question}
615
+ Assistant: {response}')
616
 
617
  # video multi-round conversation (视频多轮对话)
618
  def get_index(bound, fps, max_frame, first_idx=0, num_segments=32):
 
650
  video_path = './examples/red-panda.mp4'
651
  pixel_values, num_patches_list = load_video(video_path, num_segments=8, max_num=1)
652
  pixel_values = pixel_values.to(torch.bfloat16).cuda()
653
+ video_prefix = ''.join([f'Frame{i+1}: <image>
654
+ ' for i in range(len(num_patches_list))])
655
  question = video_prefix + 'What is the red panda doing?'
656
+ # Frame1: <image>
657
+ Frame2: <image>
658
+ ...
659
+ Frame8: <image>
660
+ {question}
661
  response, history = model.chat(tokenizer, pixel_values, question, generation_config,
662
  num_patches_list=num_patches_list, history=None, return_history=True)
663
+ print(f'User: {question}
664
+ Assistant: {response}')
665
 
666
  question = 'Describe this video in detail.'
667
  response, history = model.chat(tokenizer, pixel_values, question, generation_config,
668
  num_patches_list=num_patches_list, history=history, return_history=True)
669
+ print(f'User: {question}
670
+ Assistant: {response}')
671
  ```
672
 
673
  #### Streaming Output
 
751
 
752
  images = [load_image(img_url) for img_url in image_urls]
753
  # Numbering images improves multi-image conversations
754
+ response = pipe((f'Image-1: {IMAGE_TOKEN}
755
+ Image-2: {IMAGE_TOKEN}
756
+ describe these two images', images))
757
  print(response.text)
758
  ```
759
 
 
856
  year={2025}
857
  }
858
  ```
859
+
860
+
861
+ ## Acknowledgement
862
+
863
+ 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!
864
+
865
+ ______________________________________________________________________
866
+
867
+ Scan the following QR Code, join our WeChat group.
868
+
869
+ <p align="center"><img width="300" alt="image" src="https://github.com/user-attachments/assets/f776df09-ebba-4fd5-80c2-fec4ff1518be"></p>