Image-Text-to-Text
Transformers
Safetensors
multilingual
internvl_chat
feature-extraction
internvl
custom_code
conversational
Instructions to use OpenGVLab/InternVL2-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenGVLab/InternVL2-2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OpenGVLab/InternVL2-2B", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("OpenGVLab/InternVL2-2B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use OpenGVLab/InternVL2-2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenGVLab/InternVL2-2B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenGVLab/InternVL2-2B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/OpenGVLab/InternVL2-2B
- SGLang
How to use OpenGVLab/InternVL2-2B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "OpenGVLab/InternVL2-2B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenGVLab/InternVL2-2B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "OpenGVLab/InternVL2-2B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenGVLab/InternVL2-2B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use OpenGVLab/InternVL2-2B with Docker Model Runner:
docker model run hf.co/OpenGVLab/InternVL2-2B
Upload folder using huggingface_hub
Browse files- README.md +39 -2
- config.json +6 -3
README.md
CHANGED
|
@@ -9,7 +9,44 @@ pipeline_tag: visual-question-answering
|
|
| 9 |
|
| 10 |
[\[🤗 HF Demo\]](https://huggingface.co/spaces/OpenGVLab/InternVL) [\[🚀 Quick Start\]](#model-usage) [\[📖 中文解读\]](https://zhuanlan.zhihu.com/p/675877376)
|
| 11 |
|
| 12 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
We provide an example code to run InternVL2-2B using `transformers`.
|
| 15 |
|
|
@@ -203,4 +240,4 @@ If you find this project useful in your research, please consider citing:
|
|
| 203 |
journal={arXiv preprint arXiv:2404.16821},
|
| 204 |
year={2024}
|
| 205 |
}
|
| 206 |
-
```
|
|
|
|
| 9 |
|
| 10 |
[\[🤗 HF Demo\]](https://huggingface.co/spaces/OpenGVLab/InternVL) [\[🚀 Quick Start\]](#model-usage) [\[📖 中文解读\]](https://zhuanlan.zhihu.com/p/675877376)
|
| 11 |
|
| 12 |
+
## Introduction
|
| 13 |
+
|
| 14 |
+
We are excited to announce the release of InternVL 2.0, the latest addition to the InternVL series of multimodal large language models. InternVL 2.0 features a variety of instruction-tuned models, ranging from 2 billion to 108 billion parameters. This repository contains the instruction-tuned InternVL2-2B model.
|
| 15 |
+
|
| 16 |
+
Compared to the state-of-the-art open-source multimodal large language models, InternVL 2.0 surpasses most open-source models. It demonstrates competitive performance on par with proprietary commercial models across various capabilities, including document and chart comprehension, infographics QA, scene text understanding and OCR tasks, scientific and mathematical problem solving, as well as cultural understanding and integrated multimodal capabilities.
|
| 17 |
+
|
| 18 |
+
InternVL 2.0 is trained with an 8k context window and utilizes training data consisting of long texts, multiple images, and videos, significantly improving its ability to handle these types of inputs compared to InternVL 1.5. For more details, please refer to our blog and GitHub.
|
| 19 |
+
|
| 20 |
+
## Performance
|
| 21 |
+
|
| 22 |
+
| Benchmark | PaliGemma-3B | Phi-3-Vision | Mini-InternVL-2B-1.5 | InternVL2-2B |
|
| 23 |
+
| :-----------------------: | :----------: | :----------: | :------------------: | :----------: |
|
| 24 |
+
| Model Size | 2.9B | 4.2B | 2.2B | 2.2B |
|
| 25 |
+
| | | | | |
|
| 26 |
+
| DocVQA<sub>test</sub> | - | - | 85.0 | TODO |
|
| 27 |
+
| ChartQA<sub>test</sub> | - | 81.4 | 74.8 | 76.2 |
|
| 28 |
+
| InfoVQA<sub>test</sub> | - | - | 55.4 | TODO |
|
| 29 |
+
| TextVQA<sub>val</sub> | 68.1 | 70.9 | 70.5 | 73.4 |
|
| 30 |
+
| OCRBench | 614 | 639 | 654 | 784 |
|
| 31 |
+
| MME<sub>sum</sub> | 1686.1 | 1508.0 | 1901.5 | 1876.8 |
|
| 32 |
+
| RealWorldQA | 55.2 | 58.8 | 57.9 | 57.3 |
|
| 33 |
+
| AI2D<sub>test</sub> | 68.3 | 76.7 | 69.8 | 74.1 |
|
| 34 |
+
| MMMU<sub>val</sub> | 34.9 | 40.4 | 34.6 | 34.3 |
|
| 35 |
+
| MMBench-EN<sub>test</sub> | 71.0 | 73.6 | 70.9 | 73.2 |
|
| 36 |
+
| MMBench-CN<sub>test</sub> | 63.6 | - | 66.2 | 70.9 |
|
| 37 |
+
| CCBench<sub>dev</sub> | 29.6 | 24.1 | 63.5 | 74.7 |
|
| 38 |
+
| MMVet<sub>GPT4-0613</sub> | 33.1 | - | 39.3 | 44.6 |
|
| 39 |
+
| SEED-Image | 69.6 | 70.9 | 69.8 | 71.6 |
|
| 40 |
+
| HallBench<sub>avg.</sub> | 32.2 | 39.0 | 37.5 | 37.9 |
|
| 41 |
+
| MathVista<sub>mini</sub> | 28.7 | 44.5 | 41.1 | 46.3 |
|
| 42 |
+
|
| 43 |
+
- 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.
|
| 44 |
+
|
| 45 |
+
- Please note that evaluating the same model using different testing toolkits like InternVL and VLMEvalKit can result in slight differences, which is normal. Updates to code versions and variations in environment and hardware can also cause minor discrepancies in results.
|
| 46 |
+
|
| 47 |
+
- It is important to mention that the MMVet scores we report are evaluated using GPT-4-0613 as the judge model. Different versions of GPT-4 can lead to significant variations in the scores for this dataset. For instance, using GPT-4-Turbo would result in significantly lower scores.
|
| 48 |
+
|
| 49 |
+
## Quick Start
|
| 50 |
|
| 51 |
We provide an example code to run InternVL2-2B using `transformers`.
|
| 52 |
|
|
|
|
| 240 |
journal={arXiv preprint arXiv:2404.16821},
|
| 241 |
year={2024}
|
| 242 |
}
|
| 243 |
+
```
|
config.json
CHANGED
|
@@ -77,7 +77,10 @@
|
|
| 77 |
"return_dict": true,
|
| 78 |
"return_dict_in_generate": false,
|
| 79 |
"rms_norm_eps": 1e-05,
|
| 80 |
-
"rope_scaling":
|
|
|
|
|
|
|
|
|
|
| 81 |
"rope_theta": 1000000,
|
| 82 |
"sep_token_id": null,
|
| 83 |
"suppress_tokens": null,
|
|
@@ -88,7 +91,7 @@
|
|
| 88 |
"tie_word_embeddings": false,
|
| 89 |
"tokenizer_class": null,
|
| 90 |
"top_k": 50,
|
| 91 |
-
"top_p":
|
| 92 |
"torch_dtype": "bfloat16",
|
| 93 |
"torchscript": false,
|
| 94 |
"transformers_version": "4.37.2",
|
|
@@ -183,7 +186,7 @@
|
|
| 183 |
"tie_word_embeddings": true,
|
| 184 |
"tokenizer_class": null,
|
| 185 |
"top_k": 50,
|
| 186 |
-
"top_p":
|
| 187 |
"torch_dtype": "bfloat16",
|
| 188 |
"torchscript": false,
|
| 189 |
"transformers_version": "4.37.2",
|
|
|
|
| 77 |
"return_dict": true,
|
| 78 |
"return_dict_in_generate": false,
|
| 79 |
"rms_norm_eps": 1e-05,
|
| 80 |
+
"rope_scaling": {
|
| 81 |
+
"factor": 2.0,
|
| 82 |
+
"type": "dynamic"
|
| 83 |
+
},
|
| 84 |
"rope_theta": 1000000,
|
| 85 |
"sep_token_id": null,
|
| 86 |
"suppress_tokens": null,
|
|
|
|
| 91 |
"tie_word_embeddings": false,
|
| 92 |
"tokenizer_class": null,
|
| 93 |
"top_k": 50,
|
| 94 |
+
"top_p": null,
|
| 95 |
"torch_dtype": "bfloat16",
|
| 96 |
"torchscript": false,
|
| 97 |
"transformers_version": "4.37.2",
|
|
|
|
| 186 |
"tie_word_embeddings": true,
|
| 187 |
"tokenizer_class": null,
|
| 188 |
"top_k": 50,
|
| 189 |
+
"top_p": null,
|
| 190 |
"torch_dtype": "bfloat16",
|
| 191 |
"torchscript": false,
|
| 192 |
"transformers_version": "4.37.2",
|