Image-Text-to-Text
Transformers
Safetensors
multilingual
internvl_chat
feature-extraction
internvl
custom_code
conversational
Instructions to use OpenGVLab/InternVL2-40B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenGVLab/InternVL2-40B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OpenGVLab/InternVL2-40B", 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-40B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use OpenGVLab/InternVL2-40B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenGVLab/InternVL2-40B" # 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-40B", "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-40B
- SGLang
How to use OpenGVLab/InternVL2-40B 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-40B" \ --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-40B", "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-40B" \ --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-40B", "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-40B with Docker Model Runner:
docker model run hf.co/OpenGVLab/InternVL2-40B
Upload folder using huggingface_hub
Browse files- README.md +8 -8
- conversation.py +3 -3
README.md
CHANGED
|
@@ -340,7 +340,7 @@ from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig
|
|
| 340 |
from lmdeploy.vl import load_image
|
| 341 |
|
| 342 |
model = 'OpenGVLab/InternVL2-40B'
|
| 343 |
-
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态
|
| 344 |
image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/tests/data/tiger.jpeg')
|
| 345 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 346 |
chat_template_config.meta_instruction = system_prompt
|
|
@@ -362,7 +362,7 @@ from lmdeploy.vl import load_image
|
|
| 362 |
from lmdeploy.vl.constants import IMAGE_TOKEN
|
| 363 |
|
| 364 |
model = 'OpenGVLab/InternVL2-40B'
|
| 365 |
-
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态
|
| 366 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 367 |
chat_template_config.meta_instruction = system_prompt
|
| 368 |
pipe = pipeline(model, chat_template_config=chat_template_config,
|
|
@@ -388,7 +388,7 @@ from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig
|
|
| 388 |
from lmdeploy.vl import load_image
|
| 389 |
|
| 390 |
model = 'OpenGVLab/InternVL2-40B'
|
| 391 |
-
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态
|
| 392 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 393 |
chat_template_config.meta_instruction = system_prompt
|
| 394 |
pipe = pipeline(model, chat_template_config=chat_template_config,
|
|
@@ -412,7 +412,7 @@ from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig, Genera
|
|
| 412 |
from lmdeploy.vl import load_image
|
| 413 |
|
| 414 |
model = 'OpenGVLab/InternVL2-40B'
|
| 415 |
-
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态
|
| 416 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 417 |
chat_template_config.meta_instruction = system_prompt
|
| 418 |
pipe = pipeline(model, chat_template_config=chat_template_config,
|
|
@@ -534,7 +534,7 @@ from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig
|
|
| 534 |
from lmdeploy.vl import load_image
|
| 535 |
|
| 536 |
model = 'OpenGVLab/InternVL2-40B'
|
| 537 |
-
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态
|
| 538 |
image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/tests/data/tiger.jpeg')
|
| 539 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 540 |
chat_template_config.meta_instruction = system_prompt
|
|
@@ -556,7 +556,7 @@ from lmdeploy.vl import load_image
|
|
| 556 |
from lmdeploy.vl.constants import IMAGE_TOKEN
|
| 557 |
|
| 558 |
model = 'OpenGVLab/InternVL2-40B'
|
| 559 |
-
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合
|
| 560 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 561 |
chat_template_config.meta_instruction = system_prompt
|
| 562 |
pipe = pipeline(model, chat_template_config=chat_template_config,
|
|
@@ -581,7 +581,7 @@ from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig
|
|
| 581 |
from lmdeploy.vl import load_image
|
| 582 |
|
| 583 |
model = 'OpenGVLab/InternVL2-40B'
|
| 584 |
-
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态
|
| 585 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 586 |
chat_template_config.meta_instruction = system_prompt
|
| 587 |
pipe = pipeline(model, chat_template_config=chat_template_config,
|
|
@@ -605,7 +605,7 @@ from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig, Genera
|
|
| 605 |
from lmdeploy.vl import load_image
|
| 606 |
|
| 607 |
model = 'OpenGVLab/InternVL2-40B'
|
| 608 |
-
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态
|
| 609 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 610 |
chat_template_config.meta_instruction = system_prompt
|
| 611 |
pipe = pipeline(model, chat_template_config=chat_template_config,
|
|
|
|
| 340 |
from lmdeploy.vl import load_image
|
| 341 |
|
| 342 |
model = 'OpenGVLab/InternVL2-40B'
|
| 343 |
+
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态大语言模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
|
| 344 |
image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/tests/data/tiger.jpeg')
|
| 345 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 346 |
chat_template_config.meta_instruction = system_prompt
|
|
|
|
| 362 |
from lmdeploy.vl.constants import IMAGE_TOKEN
|
| 363 |
|
| 364 |
model = 'OpenGVLab/InternVL2-40B'
|
| 365 |
+
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态大语言模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
|
| 366 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 367 |
chat_template_config.meta_instruction = system_prompt
|
| 368 |
pipe = pipeline(model, chat_template_config=chat_template_config,
|
|
|
|
| 388 |
from lmdeploy.vl import load_image
|
| 389 |
|
| 390 |
model = 'OpenGVLab/InternVL2-40B'
|
| 391 |
+
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态大语言模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
|
| 392 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 393 |
chat_template_config.meta_instruction = system_prompt
|
| 394 |
pipe = pipeline(model, chat_template_config=chat_template_config,
|
|
|
|
| 412 |
from lmdeploy.vl import load_image
|
| 413 |
|
| 414 |
model = 'OpenGVLab/InternVL2-40B'
|
| 415 |
+
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态大语言模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
|
| 416 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 417 |
chat_template_config.meta_instruction = system_prompt
|
| 418 |
pipe = pipeline(model, chat_template_config=chat_template_config,
|
|
|
|
| 534 |
from lmdeploy.vl import load_image
|
| 535 |
|
| 536 |
model = 'OpenGVLab/InternVL2-40B'
|
| 537 |
+
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态大语言模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
|
| 538 |
image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/tests/data/tiger.jpeg')
|
| 539 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 540 |
chat_template_config.meta_instruction = system_prompt
|
|
|
|
| 556 |
from lmdeploy.vl.constants import IMAGE_TOKEN
|
| 557 |
|
| 558 |
model = 'OpenGVLab/InternVL2-40B'
|
| 559 |
+
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合���单位联合开发的多模态大语言模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
|
| 560 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 561 |
chat_template_config.meta_instruction = system_prompt
|
| 562 |
pipe = pipeline(model, chat_template_config=chat_template_config,
|
|
|
|
| 581 |
from lmdeploy.vl import load_image
|
| 582 |
|
| 583 |
model = 'OpenGVLab/InternVL2-40B'
|
| 584 |
+
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态大语言模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
|
| 585 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 586 |
chat_template_config.meta_instruction = system_prompt
|
| 587 |
pipe = pipeline(model, chat_template_config=chat_template_config,
|
|
|
|
| 605 |
from lmdeploy.vl import load_image
|
| 606 |
|
| 607 |
model = 'OpenGVLab/InternVL2-40B'
|
| 608 |
+
system_prompt = '我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态大语言模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。'
|
| 609 |
chat_template_config = ChatTemplateConfig('internvl-internlm2')
|
| 610 |
chat_template_config.meta_instruction = system_prompt
|
| 611 |
pipe = pipeline(model, chat_template_config=chat_template_config,
|
conversation.py
CHANGED
|
@@ -336,7 +336,7 @@ register_conv_template(
|
|
| 336 |
name='Hermes-2',
|
| 337 |
system_template='<|im_start|>system\n{system_message}',
|
| 338 |
# note: The new system prompt was not used here to avoid changes in benchmark performance.
|
| 339 |
-
# system_message='我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态
|
| 340 |
system_message='你是由上海人工智能实验室联合商汤科技开发的书生多模态大模型,英文名叫InternVL, 是一个有用无害的人工智能助手。',
|
| 341 |
roles=('<|im_start|>user\n', '<|im_start|>assistant\n'),
|
| 342 |
sep_style=SeparatorStyle.MPT,
|
|
@@ -357,7 +357,7 @@ register_conv_template(
|
|
| 357 |
name='internlm2-chat',
|
| 358 |
system_template='<|im_start|>system\n{system_message}',
|
| 359 |
# note: The new system prompt was not used here to avoid changes in benchmark performance.
|
| 360 |
-
# system_message='我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态
|
| 361 |
system_message='你是由上海人工智能实验室联合商汤科技开发的书生多模态大模型,英文名叫InternVL, 是一个有用无害的人工智能助手。',
|
| 362 |
roles=('<|im_start|>user\n', '<|im_start|>assistant\n'),
|
| 363 |
sep_style=SeparatorStyle.MPT,
|
|
@@ -376,7 +376,7 @@ register_conv_template(
|
|
| 376 |
name='phi3-chat',
|
| 377 |
system_template='<|system|>\n{system_message}',
|
| 378 |
# note: The new system prompt was not used here to avoid changes in benchmark performance.
|
| 379 |
-
# system_message='我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态
|
| 380 |
system_message='你是由上海人工智能实验室联合商汤科技开发的书生多模态大模型,英文名叫InternVL, 是一个有用无害的人工智能助手。',
|
| 381 |
roles=('<|user|>\n', '<|assistant|>\n'),
|
| 382 |
sep_style=SeparatorStyle.MPT,
|
|
|
|
| 336 |
name='Hermes-2',
|
| 337 |
system_template='<|im_start|>system\n{system_message}',
|
| 338 |
# note: The new system prompt was not used here to avoid changes in benchmark performance.
|
| 339 |
+
# system_message='我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态大语言模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。',
|
| 340 |
system_message='你是由上海人工智能实验室联合商汤科技开发的书生多模态大模型,英文名叫InternVL, 是一个有用无害的人工智能助手。',
|
| 341 |
roles=('<|im_start|>user\n', '<|im_start|>assistant\n'),
|
| 342 |
sep_style=SeparatorStyle.MPT,
|
|
|
|
| 357 |
name='internlm2-chat',
|
| 358 |
system_template='<|im_start|>system\n{system_message}',
|
| 359 |
# note: The new system prompt was not used here to avoid changes in benchmark performance.
|
| 360 |
+
# system_message='我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态大语言模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。',
|
| 361 |
system_message='你是由上海人工智能实验室联合商汤科技开发的书生多模态大模型,英文名叫InternVL, 是一个有用无害的人工智能助手。',
|
| 362 |
roles=('<|im_start|>user\n', '<|im_start|>assistant\n'),
|
| 363 |
sep_style=SeparatorStyle.MPT,
|
|
|
|
| 376 |
name='phi3-chat',
|
| 377 |
system_template='<|system|>\n{system_message}',
|
| 378 |
# note: The new system prompt was not used here to avoid changes in benchmark performance.
|
| 379 |
+
# system_message='我是书生·万象,英文名是InternVL,是由上海人工智能实验室及多家合作单位联合开发的多模态大语言模型。人工智能实验室致力于原始技术创新,开源开放,共享共创,推动科技进步和产业发展。',
|
| 380 |
system_message='你是由上海人工智能实验室联合商汤科技开发的书生多模态大模型,英文名叫InternVL, 是一个有用无害的人工智能助手。',
|
| 381 |
roles=('<|user|>\n', '<|assistant|>\n'),
|
| 382 |
sep_style=SeparatorStyle.MPT,
|