Edit model card

Model Card for InternVL-Chat-V1.2

Image Description

[InternVL 1.5 Technical Report] [Paper] [GitHub] [Chat Demo] [中文解读]

We are excited to introduce InternVL-Chat-V1.2. Inspired by LLaVA-NeXT-34B, we have also adopted Nous-Hermes-2-Yi-34B as the language model. Below is the pipeline.

image

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).

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.

Model Details

  • Model Type: multimodal large language model (MLLM)

  • Model Stats:

  • Training Strategy:

    • Pretraining Stage
      • Learnable Component: MLP
      • Data: Trained on 8192x4800=39.3M samples, including COYO, LAION, CC12M, CC3M, SBU, Wukong, GRIT, Objects365, OpenImages, and OCR-related datasets.
      • Note: In this stage, we load the pretrained weights of 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.
    • Supervised Finetuning Stage
      • Learnable Component: ViT + MLP + LLM
      • Data: A simplified, fully open-source dataset, containing approximately 1.2 million samples.

Released Models

Model Vision Foundation Model Release Date Note
InternVL-Chat-V1.5(🤗 HF link) InternViT-6B-448px-V1-5(🤗 HF link) 2024.04.18 support 4K image; super strong OCR; Approaching the performance of GPT-4V and Gemini Pro on various benchmarks like MMMU, DocVQA, ChartQA, MathVista, etc. (🔥new)
InternVL-Chat-V1.2-Plus(🤗 HF link ) InternViT-6B-448px-V1-2(🤗 HF link) 2024.02.21 more SFT data and stronger
InternVL-Chat-V1.2(🤗 HF link ) InternViT-6B-448px-V1-2(🤗 HF link) 2024.02.11 scaling up LLM to 34B
InternVL-Chat-V1.1(🤗 HF link) InternViT-6B-448px-V1-0(🤗 HF link) 2024.01.24 support Chinese and stronger OCR

Performance

* Proprietary Model

name image size MMMU
(val)
MMMU
(test)
MathVista
(testmini)
MMB
(test)
MMB−CN
(test)
MMVP MME ScienceQA
(image)
POPE TextVQA
(val)
SEEDv1
(image)
VizWiz
(test)
GQA
(test)
GPT−4V* unknown 56.8 55.7 49.9 77.0 74.4 38.7 1409/517 - - 78.0 71.6 - -
Gemini Ultra* unknown 59.4 - 53.0 - - - - - - 82.3 - - -
Gemini Pro* unknown 47.9 - 45.2 73.6 74.3 40.7 1497/437 - - 74.6 70.7 - -
Qwen−VL−Plus* unknown 45.2 40.8 43.3 67.0 70.7 - 1681/502 - - 78.9 65.7 - -
Qwen−VL−Max* unknown 51.4 46.8 51.0 77.6 75.7 - - - - 79.5 - - -
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
InternVL−Chat−V1.2 448x448 51.6 46.2 47.7 82.2 81.2 56.7 1687/489 83.3 88.0 72.5 75.6 60.0 64.0
  • In most benchmarks, InternVL-Chat-V1.2 achieves better performance than LLaVA-NeXT-34B.
  • Update (2024-04-21): We have fixed a bug in the evaluation code, and the TextVQA result has been corrected to 72.5.

Training Details

Data Preparation

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 and additionally integrate LLaVA-ZH, DVQA, ChartQA, AI2D, DocVQA, GeoQA+, and SynthDoG-EN. Most of the data remains consistent with LLaVA-NeXT.

For more details about data preparation, please see here.

Training (Supervised Finetuning)

We provide slurm scripts 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.

For more details about training, please see here.

The hyperparameters used for finetuning are listed in the following table.

Hyperparameter Trainable Param Global Batch Size Learning rate Epochs Max length Weight decay
InternVL−Chat−V1.2 40B (full model) 512 1e-5 1 2048 0.05

Model Usage

We provide an example code to run InternVL-Chat-V1.2 using transformers.

You also can use our online demo for a quick experience of this model.

import torch
from PIL import Image
from transformers import AutoModel, CLIPImageProcessor
from transformers import AutoTokenizer

path = "OpenGVLab/InternVL-Chat-V1-2"
# If you have an 80G A100 GPU, you can put the entire model on a single GPU.
model = AutoModel.from_pretrained(
    path,
    torch_dtype=torch.bfloat16,
    low_cpu_mem_usage=True,
    trust_remote_code=True).eval().cuda()
# Otherwise, you need to set device_map='auto' to use multiple GPUs for inference.
# model = AutoModel.from_pretrained(
#     path,
#     torch_dtype=torch.bfloat16,
#     low_cpu_mem_usage=True,
#     trust_remote_code=True,
#     device_map='auto').eval()

tokenizer = AutoTokenizer.from_pretrained(path)
image = Image.open('./examples/image2.jpg').convert('RGB')
image = image.resize((448, 448))
image_processor = CLIPImageProcessor.from_pretrained(path)

pixel_values = image_processor(images=image, return_tensors='pt').pixel_values
pixel_values = pixel_values.to(torch.bfloat16).cuda()

generation_config = dict(
    num_beams=1,
    max_new_tokens=512,
    do_sample=False,
)

# single-round conversation
question = "请详细描述图片"
response = model.chat(tokenizer, pixel_values, question, generation_config)
print(question, response)

# multi-round conversation
question = "请详细描述图片"
response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)
print(question, response)

question = "请根据图片写一首诗"
response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=history, return_history=True)
print(question, response)

Citation

If you find this project useful in your research, please consider citing:

@article{chen2023internvl,
  title={InternVL: Scaling up Vision Foundation Models and Aligning for Generic Visual-Linguistic Tasks},
  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},
  journal={arXiv preprint arXiv:2312.14238},
  year={2023}
}

License

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.

Llama 2 is licensed under the LLAMA 2 Community License, Copyright (c) Meta Platforms, Inc. All Rights Reserved.

Acknowledgement

InternVL is built with reference to the code of the following projects: OpenAI CLIP, Open CLIP, CLIP Benchmark, EVA, InternImage, ViT-Adapter, MMSegmentation, Transformers, DINOv2, BLIP-2, Qwen-VL, and LLaVA-1.5. Thanks for their awesome work!

Contributors

Developed by: Zhe Chen, Weiyun Wang, Wenhai Wang, Erfei Cui, Zhangwei Gao, Xizhou Zhu, Lewei Lu, Tong Lu, Yu Qiao, Jifeng Dai

Downloads last month
399
Safetensors
Model size
40.1B params
Tensor type
BF16
·
Inference API
Inference API (serverless) does not yet support model repos that contain custom code.

Datasets used to train OpenGVLab/InternVL-Chat-V1-2

Collection including OpenGVLab/InternVL-Chat-V1-2