Run this model with HF Jobs
Run OpenGVLab/InternVL3-2B-hf 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/InternVL3-2B-hf. Ask me which dataset to train on, then push the LoRA adapter to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs and Transformers to run batch inference with https://huggingface.co/OpenGVLab/InternVL3-2B-hf on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the predictions back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs and Lighteval to evaluate https://huggingface.co/OpenGVLab/InternVL3-2B-hf. 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/InternVL3-2B-hf with Transformers and bitsandbytes. 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/InternVL3-2B-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenGVLab/InternVL3-2B-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OpenGVLab/InternVL3-2B-hf") 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 AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("OpenGVLab/InternVL3-2B-hf") model = AutoModelForMultimodalLM.from_pretrained("OpenGVLab/InternVL3-2B-hf", device_map="auto") 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?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use OpenGVLab/InternVL3-2B-hf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenGVLab/InternVL3-2B-hf" # 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/InternVL3-2B-hf", "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/InternVL3-2B-hf
- SGLang
How to use OpenGVLab/InternVL3-2B-hf 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/InternVL3-2B-hf" \ --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/InternVL3-2B-hf", "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/InternVL3-2B-hf" \ --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/InternVL3-2B-hf", "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/InternVL3-2B-hf with Docker Model Runner:
docker model run hf.co/OpenGVLab/InternVL3-2B-hf
Update processor (#2)
Browse files- update (67db678d566800894b5469a1eefbef1a1dd3b296)
Co-authored-by: Raushan Turganbay <RaushanTurganbay@users.noreply.huggingface.co>
Files changed (6)
9 unmodified lines1011121314159 unmodified lines"<quad>": 151668,"<ref>": 151670,"<tool_call>": 151657,"<|box_end|>": 151649,"<|box_start|>": 151648,"<|endoftext|>": 151643,9 unmodified lines101112131415169 unmodified lines"<quad>": 151668,"<ref>": 151670,"<tool_call>": 151657,"<video>": 151674,"<|box_end|>": 151649,"<|box_start|>": 151648,"<|endoftext|>": 151643,
12345{% for message in messages %}{{'<|im_start|>' + message['role'] + ''}}{% if message['content'] is string %}{{ message['content'] }}{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' %}{{ '<image>' }}{% elif content['type'] == 'video' %}{{ '<video>' }}{% elif content['type'] == 'text' %}{{ content['text'] }}{% endif %}{% endfor %}{% endif %}{{'<|im_end|>'}}{% endfor %}{% if add_generation_prompt %}{{'<|im_start|>assistant12345{% for message in messages %}{{'<|im_start|>' + message['role'] + ''}}{% if message['content'] is string %}{{ message['content'] }}{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' %}{{ '<IMG_CONTEXT>' }}{% elif content['type'] == 'video' %}{{ '<video>' }}{% elif content['type'] == 'text' %}{{ content['text'] }}{% endif %}{% endfor %}{% endif %}{{'<|im_end|>'}}{% endfor %}{% if add_generation_prompt %}{{'<|im_start|>assistant
123456{"fake_image_token": "<image>","fake_video_token": "<video>","image_seq_length": 256,"processor_class": "InternVLProcessor"}1234{"image_seq_length": 256,"processor_class": "InternVLProcessor"}
12 unmodified lines13141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808111 unmodified lines939495969712 unmodified lines"<|vision_pad|>","<|image_pad|>","<|video_pad|>",{"content": "<img>","lstrip": false,"normalized": false,"rstrip": false,"single_word": false},{"content": "</img>","lstrip": false,"normalized": false,"rstrip": false,"single_word": false},{"content": "<IMG_CONTEXT>","lstrip": false,"normalized": false,"rstrip": false,"single_word": false},{"content": "<quad>","lstrip": false,"normalized": false,"rstrip": false,"single_word": false},{"content": "</quad>","lstrip": false,"normalized": false,"rstrip": false,"single_word": false},{"content": "<ref>","lstrip": false,"normalized": false,"rstrip": false,"single_word": false},{"content": "</ref>","lstrip": false,"normalized": false,"rstrip": false,"single_word": false},{"content": "<box>","lstrip": false,"normalized": false,"rstrip": false,"single_word": false},{"content": "</box>","lstrip": false,"normalized": false,"rstrip": false,"single_word": false}],"context_image_token": "<IMG_CONTEXT>","end_image_token": "</img>",11 unmodified lines"rstrip": false,"single_word": false},"start_image_token": "<img>"}12 unmodified lines13141516171819202122232425262711 unmodified lines39404142434412 unmodified lines"<|vision_pad|>","<|image_pad|>","<|video_pad|>","<img>","</img>","<IMG_CONTEXT>","<quad>","</quad>","<ref>","</ref>","<box>","</box>"],"context_image_token": "<IMG_CONTEXT>","end_image_token": "</img>",11 unmodified lines"rstrip": false,"single_word": false},"start_image_token": "<img>","video_token": "<video>"}
123version https://git-lfs.github.com/spec/v1oid sha256:6f9ba4b4a6625b5047a1356f6081b641c3e4e6a4a198facbd4bef217747d1685size 11423548123version https://git-lfs.github.com/spec/v1oid sha256:7cc80b7e20adf8bf6f6ca442bf1abfac8056bb3b7d3e0b11c9d497d3e79398c9size 11423732
248 unmodified lines24925025125225325429 unmodified lines2842852862872882892901 unmodified line292293294295296248 unmodified lines"rstrip": false,"single_word": false,"special": true}},"additional_special_tokens": [29 unmodified lines"extra_special_tokens": {"context_image_token": "<IMG_CONTEXT>","end_image_token": "</img>","start_image_token": "<img>"},"model_max_length": 8192,"pad_token": "<|endoftext|>",1 unmodified line"split_special_tokens": false,"start_image_token": "<img>","tokenizer_class": "Qwen2Tokenizer","unk_token": null}248 unmodified lines24925025125225325425525625725825926026126229 unmodified lines2922932942952962972982991 unmodified line301302303304305306248 unmodified lines"rstrip": false,"single_word": false,"special": true},"151674": {"content": "<video>","lstrip": false,"normalized": false,"rstrip": false,"single_word": false,"special": true}},"additional_special_tokens": [29 unmodified lines"extra_special_tokens": {"context_image_token": "<IMG_CONTEXT>","end_image_token": "</img>","start_image_token": "<img>","video_token": "<video>"},"model_max_length": 8192,"pad_token": "<|endoftext|>",1 unmodified line"split_special_tokens": false,"start_image_token": "<img>","tokenizer_class": "Qwen2Tokenizer","unk_token": null,"video_token": "<video>"}
added_tokens.json+1
chat_template.jinja+1-1
processor_config.json-2
special_tokens_map.json+11-64
tokenizer.json+2-2
tokenizer_config.json+12-2