Image-Text-to-Text
Transformers
Safetensors
multilingual
internvl_chat
feature-extraction
internvl
custom_code
conversational
Run this model with HF Jobs
Run OpenGVLab/InternVL2-2B on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/OpenGVLab/InternVL2-2B. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/OpenGVLab/InternVL2-2B on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/OpenGVLab/InternVL2-2B. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/OpenGVLab/InternVL2-2B. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
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)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("OpenGVLab/InternVL2-2B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- 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 filesFiles changed (2)
- README.md+39-2
- config.json+6-3
8 unmodified lines9101112131415187 unmodified lines2032042052068 unmodified lines[\[🤗 HF Demo\]](https://huggingface.co/spaces/OpenGVLab/InternVL) [\[🚀 Quick Start\]](#model-usage) [\[📖 中文解读\]](https://zhuanlan.zhihu.com/p/675877376)## Model UsageWe provide an example code to run InternVL2-2B using `transformers`.187 unmodified linesjournal={arXiv preprint arXiv:2404.16821},year={2024}}```8 unmodified lines910111213141516171819202122232425262728293031323334353637383940414243444546474849505152187 unmodified lines2402412422438 unmodified lines[\[🤗 HF Demo\]](https://huggingface.co/spaces/OpenGVLab/InternVL) [\[🚀 Quick Start\]](#model-usage) [\[📖 中文解读\]](https://zhuanlan.zhihu.com/p/675877376)## IntroductionWe 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.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.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.## Performance| Benchmark | PaliGemma-3B | Phi-3-Vision | Mini-InternVL-2B-1.5 | InternVL2-2B || :-----------------------: | :----------: | :----------: | :------------------: | :----------: || Model Size | 2.9B | 4.2B | 2.2B | 2.2B || | | | | || DocVQA<sub>test</sub> | - | - | 85.0 | TODO || ChartQA<sub>test</sub> | - | 81.4 | 74.8 | 76.2 || InfoVQA<sub>test</sub> | - | - | 55.4 | TODO || TextVQA<sub>val</sub> | 68.1 | 70.9 | 70.5 | 73.4 || OCRBench | 614 | 639 | 654 | 784 || MME<sub>sum</sub> | 1686.1 | 1508.0 | 1901.5 | 1876.8 || RealWorldQA | 55.2 | 58.8 | 57.9 | 57.3 || AI2D<sub>test</sub> | 68.3 | 76.7 | 69.8 | 74.1 || MMMU<sub>val</sub> | 34.9 | 40.4 | 34.6 | 34.3 || MMBench-EN<sub>test</sub> | 71.0 | 73.6 | 70.9 | 73.2 || MMBench-CN<sub>test</sub> | 63.6 | - | 66.2 | 70.9 || CCBench<sub>dev</sub> | 29.6 | 24.1 | 63.5 | 74.7 || MMVet<sub>GPT4-0613</sub> | 33.1 | - | 39.3 | 44.6 || SEED-Image | 69.6 | 70.9 | 69.8 | 71.6 || HallBench<sub>avg.</sub> | 32.2 | 39.0 | 37.5 | 37.9 || MathVista<sub>mini</sub> | 28.7 | 44.5 | 41.1 | 46.3 |- 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.- 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.- 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.## Quick StartWe provide an example code to run InternVL2-2B using `transformers`.187 unmodified linesjournal={arXiv preprint arXiv:2404.16821},year={2024}}```
76 unmodified lines777879808182834 unmodified lines8889909192939488 unmodified lines18318418518618718818976 unmodified lines"return_dict": true,"return_dict_in_generate": false,"rms_norm_eps": 1e-05,"rope_scaling": null,"rope_theta": 1000000,"sep_token_id": null,"suppress_tokens": null,4 unmodified lines"tie_word_embeddings": false,"tokenizer_class": null,"top_k": 50,"top_p": 1.0,"torch_dtype": "bfloat16","torchscript": false,"transformers_version": "4.37.2",88 unmodified lines"tie_word_embeddings": true,"tokenizer_class": null,"top_k": 50,"top_p": 1.0,"torch_dtype": "bfloat16","torchscript": false,"transformers_version": "4.37.2",76 unmodified lines777879808182838485864 unmodified lines9192939495969788 unmodified lines18618718818919019119276 unmodified lines"return_dict": true,"return_dict_in_generate": false,"rms_norm_eps": 1e-05,"rope_scaling": {"factor": 2.0,"type": "dynamic"},"rope_theta": 1000000,"sep_token_id": null,"suppress_tokens": null,4 unmodified lines"tie_word_embeddings": false,"tokenizer_class": null,"top_k": 50,"top_p": null,"torch_dtype": "bfloat16","torchscript": false,"transformers_version": "4.37.2",88 unmodified lines"tie_word_embeddings": true,"tokenizer_class": null,"top_k": 50,"top_p": null,"torch_dtype": "bfloat16","torchscript": false,"transformers_version": "4.37.2",
README.md+39-2
config.json+6-3