Instructions to use internlm/CapRL-Eval-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use internlm/CapRL-Eval-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="internlm/CapRL-Eval-3B") 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("internlm/CapRL-Eval-3B") model = AutoModelForImageTextToText.from_pretrained("internlm/CapRL-Eval-3B") 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 internlm/CapRL-Eval-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "internlm/CapRL-Eval-3B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "internlm/CapRL-Eval-3B", "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/internlm/CapRL-Eval-3B
- SGLang
How to use internlm/CapRL-Eval-3B 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 "internlm/CapRL-Eval-3B" \ --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": "internlm/CapRL-Eval-3B", "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 "internlm/CapRL-Eval-3B" \ --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": "internlm/CapRL-Eval-3B", "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 internlm/CapRL-Eval-3B with Docker Model Runner:
docker model run hf.co/internlm/CapRL-Eval-3B
Add files using upload-large-folder tool
Browse files- chat_template.json +2 -2
- model-00001-of-00002.safetensors +1 -1
- model-00002-of-00002.safetensors +1 -1
- preprocessor_config.json +8 -18
- tokenizer_config.json +6 -2
chat_template.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
{
|
| 2 |
-
|
| 3 |
-
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"chat_template": "{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n{% endif %}<|im_start|>{{ message['role'] }}\n{% if message['content'] is string %}{{ message['content'] }}<|im_end|>\n{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>\n{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant\n{% endif %}"
|
| 3 |
+
}
|
model-00001-of-00002.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 4997750760
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fe0952d247122a16bccf1d350dddf97d20f4e98f7a8723d2913faf53610dab5f
|
| 3 |
size 4997750760
|
model-00002-of-00002.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2511587184
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dfb989ea7a389c6b9c295afd07466d4faf83e8d4f3fbb7427497ecf8b1c10ace
|
| 3 |
size 2511587184
|
preprocessor_config.json
CHANGED
|
@@ -1,29 +1,19 @@
|
|
| 1 |
{
|
| 2 |
-
"
|
| 3 |
-
"
|
| 4 |
-
"
|
| 5 |
-
"
|
|
|
|
| 6 |
"image_mean": [
|
| 7 |
0.48145466,
|
| 8 |
0.4578275,
|
| 9 |
0.40821073
|
| 10 |
],
|
| 11 |
-
"image_processor_type": "Qwen2VLImageProcessorFast",
|
| 12 |
"image_std": [
|
| 13 |
0.26862954,
|
| 14 |
0.26130258,
|
| 15 |
0.27577711
|
| 16 |
],
|
| 17 |
-
"
|
| 18 |
-
"
|
| 19 |
-
|
| 20 |
-
"patch_size": 14,
|
| 21 |
-
"processor_class": "Qwen2_5_VLProcessor",
|
| 22 |
-
"resample": 3,
|
| 23 |
-
"rescale_factor": 0.00392156862745098,
|
| 24 |
-
"size": {
|
| 25 |
-
"longest_edge": 12845056,
|
| 26 |
-
"shortest_edge": 3136
|
| 27 |
-
},
|
| 28 |
-
"temporal_patch_size": 2
|
| 29 |
-
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"min_pixels": 3136,
|
| 3 |
+
"max_pixels": 12845056,
|
| 4 |
+
"patch_size": 14,
|
| 5 |
+
"temporal_patch_size": 2,
|
| 6 |
+
"merge_size": 2,
|
| 7 |
"image_mean": [
|
| 8 |
0.48145466,
|
| 9 |
0.4578275,
|
| 10 |
0.40821073
|
| 11 |
],
|
|
|
|
| 12 |
"image_std": [
|
| 13 |
0.26862954,
|
| 14 |
0.26130258,
|
| 15 |
0.27577711
|
| 16 |
],
|
| 17 |
+
"image_processor_type": "Qwen2VLImageProcessor",
|
| 18 |
+
"processor_class": "Qwen2VLProcessor"
|
| 19 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tokenizer_config.json
CHANGED
|
@@ -200,13 +200,17 @@
|
|
| 200 |
"eos_token": "<|im_end|>",
|
| 201 |
"errors": "replace",
|
| 202 |
"extra_special_tokens": {},
|
| 203 |
-
"
|
|
|
|
| 204 |
"min_pixels": 3136,
|
| 205 |
"model_max_length": 131072,
|
| 206 |
"pad_token": "<|endoftext|>",
|
| 207 |
-
"processor_class": "
|
| 208 |
"split_special_tokens": false,
|
|
|
|
| 209 |
"tokenizer_class": "Qwen2Tokenizer",
|
|
|
|
|
|
|
| 210 |
"unk_token": null,
|
| 211 |
"use_fast": true
|
| 212 |
}
|
|
|
|
| 200 |
"eos_token": "<|im_end|>",
|
| 201 |
"errors": "replace",
|
| 202 |
"extra_special_tokens": {},
|
| 203 |
+
"max_length": 4096,
|
| 204 |
+
"max_pixels": 501760,
|
| 205 |
"min_pixels": 3136,
|
| 206 |
"model_max_length": 131072,
|
| 207 |
"pad_token": "<|endoftext|>",
|
| 208 |
+
"processor_class": "Qwen2VLProcessor",
|
| 209 |
"split_special_tokens": false,
|
| 210 |
+
"stride": 0,
|
| 211 |
"tokenizer_class": "Qwen2Tokenizer",
|
| 212 |
+
"truncation_side": "right",
|
| 213 |
+
"truncation_strategy": "longest_first",
|
| 214 |
"unk_token": null,
|
| 215 |
"use_fast": true
|
| 216 |
}
|