Instructions to use kingsley01/InternVL2_5-8B-MPO-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kingsley01/InternVL2_5-8B-MPO-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="kingsley01/InternVL2_5-8B-MPO-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("kingsley01/InternVL2_5-8B-MPO-hf") model = AutoModelForImageTextToText.from_pretrained("kingsley01/InternVL2_5-8B-MPO-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 Settings
- vLLM
How to use kingsley01/InternVL2_5-8B-MPO-hf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kingsley01/InternVL2_5-8B-MPO-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": "kingsley01/InternVL2_5-8B-MPO-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/kingsley01/InternVL2_5-8B-MPO-hf
- SGLang
How to use kingsley01/InternVL2_5-8B-MPO-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 "kingsley01/InternVL2_5-8B-MPO-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": "kingsley01/InternVL2_5-8B-MPO-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 "kingsley01/InternVL2_5-8B-MPO-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": "kingsley01/InternVL2_5-8B-MPO-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 kingsley01/InternVL2_5-8B-MPO-hf with Docker Model Runner:
docker model run hf.co/kingsley01/InternVL2_5-8B-MPO-hf
Upload processor
Browse files- preprocessor_config.json +1 -0
- processor_config.json +9 -0
- tokenizer_config.json +1 -0
preprocessor_config.json
CHANGED
|
@@ -18,6 +18,7 @@
|
|
| 18 |
],
|
| 19 |
"max_patches": 12,
|
| 20 |
"min_patches": 1,
|
|
|
|
| 21 |
"resample": 3,
|
| 22 |
"rescale_factor": 0.00392156862745098,
|
| 23 |
"size": {
|
|
|
|
| 18 |
],
|
| 19 |
"max_patches": 12,
|
| 20 |
"min_patches": 1,
|
| 21 |
+
"processor_class": "InternVLProcessor",
|
| 22 |
"resample": 3,
|
| 23 |
"rescale_factor": 0.00392156862745098,
|
| 24 |
"size": {
|
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 |
+
}
|
tokenizer_config.json
CHANGED
|
@@ -96,6 +96,7 @@
|
|
| 96 |
"extra_special_tokens": {},
|
| 97 |
"model_max_length": 1000000000000000019884624838656,
|
| 98 |
"pad_token": "</s>",
|
|
|
|
| 99 |
"return_token_type_ids": false,
|
| 100 |
"sp_model_kwargs": null,
|
| 101 |
"tokenizer_class": "InternLM2Tokenizer",
|
|
|
|
| 96 |
"extra_special_tokens": {},
|
| 97 |
"model_max_length": 1000000000000000019884624838656,
|
| 98 |
"pad_token": "</s>",
|
| 99 |
+
"processor_class": "InternVLProcessor",
|
| 100 |
"return_token_type_ids": false,
|
| 101 |
"sp_model_kwargs": null,
|
| 102 |
"tokenizer_class": "InternLM2Tokenizer",
|