Instructions to use OpenGVLab/InternVL3-14B-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenGVLab/InternVL3-14B-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OpenGVLab/InternVL3-14B-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)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("OpenGVLab/InternVL3-14B-hf") model = AutoModelForImageTextToText.from_pretrained("OpenGVLab/InternVL3-14B-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?"} ] }, ] 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use OpenGVLab/InternVL3-14B-hf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenGVLab/InternVL3-14B-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-14B-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-14B-hf
- SGLang
How to use OpenGVLab/InternVL3-14B-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-14B-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-14B-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-14B-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-14B-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-14B-hf with Docker Model Runner:
docker model run hf.co/OpenGVLab/InternVL3-14B-hf
Upload processor
Browse files- preprocessor_config.json +1 -0
- processor_config.json +9 -0
- special_tokens_map.json +9 -63
- tokenizer_config.json +1 -0
preprocessor_config.json
CHANGED
|
@@ -23,6 +23,7 @@
|
|
| 23 |
"input_data_format": null,
|
| 24 |
"max_patches": 12,
|
| 25 |
"min_patches": 1,
|
|
|
|
| 26 |
"resample": 3,
|
| 27 |
"rescale_factor": 0.00392156862745098,
|
| 28 |
"return_tensors": null,
|
|
|
|
| 23 |
"input_data_format": null,
|
| 24 |
"max_patches": 12,
|
| 25 |
"min_patches": 1,
|
| 26 |
+
"processor_class": "InternVLProcessor",
|
| 27 |
"resample": 3,
|
| 28 |
"rescale_factor": 0.00392156862745098,
|
| 29 |
"return_tensors": null,
|
processor_config.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"context_image_token": "<IMG_CONTEXT>",
|
| 3 |
+
"end_image_token": "</img>",
|
| 4 |
+
"fake_image_token": "<image>",
|
| 5 |
+
"fake_video_token": "<video>",
|
| 6 |
+
"image_seq_length": 256,
|
| 7 |
+
"processor_class": "InternVLProcessor",
|
| 8 |
+
"start_image_token": "<img>"
|
| 9 |
+
}
|
special_tokens_map.json
CHANGED
|
@@ -13,69 +13,15 @@
|
|
| 13 |
"<|vision_pad|>",
|
| 14 |
"<|image_pad|>",
|
| 15 |
"<|video_pad|>",
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
"lstrip": false,
|
| 26 |
-
"normalized": false,
|
| 27 |
-
"rstrip": false,
|
| 28 |
-
"single_word": false
|
| 29 |
-
},
|
| 30 |
-
{
|
| 31 |
-
"content": "<IMG_CONTEXT>",
|
| 32 |
-
"lstrip": false,
|
| 33 |
-
"normalized": false,
|
| 34 |
-
"rstrip": false,
|
| 35 |
-
"single_word": false
|
| 36 |
-
},
|
| 37 |
-
{
|
| 38 |
-
"content": "<quad>",
|
| 39 |
-
"lstrip": false,
|
| 40 |
-
"normalized": false,
|
| 41 |
-
"rstrip": false,
|
| 42 |
-
"single_word": false
|
| 43 |
-
},
|
| 44 |
-
{
|
| 45 |
-
"content": "</quad>",
|
| 46 |
-
"lstrip": false,
|
| 47 |
-
"normalized": false,
|
| 48 |
-
"rstrip": false,
|
| 49 |
-
"single_word": false
|
| 50 |
-
},
|
| 51 |
-
{
|
| 52 |
-
"content": "<ref>",
|
| 53 |
-
"lstrip": false,
|
| 54 |
-
"normalized": false,
|
| 55 |
-
"rstrip": false,
|
| 56 |
-
"single_word": false
|
| 57 |
-
},
|
| 58 |
-
{
|
| 59 |
-
"content": "</ref>",
|
| 60 |
-
"lstrip": false,
|
| 61 |
-
"normalized": false,
|
| 62 |
-
"rstrip": false,
|
| 63 |
-
"single_word": false
|
| 64 |
-
},
|
| 65 |
-
{
|
| 66 |
-
"content": "<box>",
|
| 67 |
-
"lstrip": false,
|
| 68 |
-
"normalized": false,
|
| 69 |
-
"rstrip": false,
|
| 70 |
-
"single_word": false
|
| 71 |
-
},
|
| 72 |
-
{
|
| 73 |
-
"content": "</box>",
|
| 74 |
-
"lstrip": false,
|
| 75 |
-
"normalized": false,
|
| 76 |
-
"rstrip": false,
|
| 77 |
-
"single_word": false
|
| 78 |
-
}
|
| 79 |
],
|
| 80 |
"eos_token": {
|
| 81 |
"content": "<|im_end|>",
|
|
|
|
| 13 |
"<|vision_pad|>",
|
| 14 |
"<|image_pad|>",
|
| 15 |
"<|video_pad|>",
|
| 16 |
+
"<img>",
|
| 17 |
+
"</img>",
|
| 18 |
+
"<IMG_CONTEXT>",
|
| 19 |
+
"<quad>",
|
| 20 |
+
"</quad>",
|
| 21 |
+
"<ref>",
|
| 22 |
+
"</ref>",
|
| 23 |
+
"<box>",
|
| 24 |
+
"</box>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
],
|
| 26 |
"eos_token": {
|
| 27 |
"content": "<|im_end|>",
|
tokenizer_config.json
CHANGED
|
@@ -282,6 +282,7 @@
|
|
| 282 |
"extra_special_tokens": {},
|
| 283 |
"model_max_length": 8192,
|
| 284 |
"pad_token": "<|endoftext|>",
|
|
|
|
| 285 |
"return_token_type_ids": false,
|
| 286 |
"split_special_tokens": false,
|
| 287 |
"tokenizer_class": "Qwen2Tokenizer",
|
|
|
|
| 282 |
"extra_special_tokens": {},
|
| 283 |
"model_max_length": 8192,
|
| 284 |
"pad_token": "<|endoftext|>",
|
| 285 |
+
"processor_class": "InternVLProcessor",
|
| 286 |
"return_token_type_ids": false,
|
| 287 |
"split_special_tokens": false,
|
| 288 |
"tokenizer_class": "Qwen2Tokenizer",
|