Image-Text-to-Text
Transformers
Safetensors
English
qwen3_vl
text-generation-inference
vision-language
multimodal
image-captioning
visual-question-answering
conditional-generation
vision
language-model
sft
fine-grained-captioning
computer-vision
vllm
conversational
Instructions to use prithivMLmods/OpenCaption-4B-VL-SFT-v1.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prithivMLmods/OpenCaption-4B-VL-SFT-v1.0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="prithivMLmods/OpenCaption-4B-VL-SFT-v1.0") 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, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("prithivMLmods/OpenCaption-4B-VL-SFT-v1.0") model = AutoModelForMultimodalLM.from_pretrained("prithivMLmods/OpenCaption-4B-VL-SFT-v1.0", 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use prithivMLmods/OpenCaption-4B-VL-SFT-v1.0 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "prithivMLmods/OpenCaption-4B-VL-SFT-v1.0" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "prithivMLmods/OpenCaption-4B-VL-SFT-v1.0", "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/prithivMLmods/OpenCaption-4B-VL-SFT-v1.0
- SGLang
How to use prithivMLmods/OpenCaption-4B-VL-SFT-v1.0 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 "prithivMLmods/OpenCaption-4B-VL-SFT-v1.0" \ --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": "prithivMLmods/OpenCaption-4B-VL-SFT-v1.0", "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 "prithivMLmods/OpenCaption-4B-VL-SFT-v1.0" \ --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": "prithivMLmods/OpenCaption-4B-VL-SFT-v1.0", "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 prithivMLmods/OpenCaption-4B-VL-SFT-v1.0 with Docker Model Runner:
docker model run hf.co/prithivMLmods/OpenCaption-4B-VL-SFT-v1.0
Add files using upload-large-folder tool
Browse files- .gitattributes +1 -0
- chat_template.jinja +55 -0
- config.json +69 -0
- generation_config.json +13 -0
- model.safetensors +3 -0
- processor_config.json +64 -0
- tokenizer.json +3 -0
- tokenizer_config.json +23 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- if messages[0].role == 'system' %}
|
| 2 |
+
{{- '<|im_start|>system\n' }}
|
| 3 |
+
{%- if messages[0].content is string %}
|
| 4 |
+
{{- messages[0].content }}
|
| 5 |
+
{%- else %}
|
| 6 |
+
{%- for content in messages[0].content %}
|
| 7 |
+
{%- if 'text' in content %}
|
| 8 |
+
{{- content.text }}
|
| 9 |
+
{%- endif %}
|
| 10 |
+
{%- endfor %}
|
| 11 |
+
{%- endif %}
|
| 12 |
+
{{- '<|im_end|>\n' }}
|
| 13 |
+
{%- else %}
|
| 14 |
+
{{- '<|im_start|>system\nYou are a detailed image captioning assistant. Structure every caption as follows:\n\n1. Open with one sentence naming the shot type (e.g., eye-level, wide-angle, close-up), the overall setting, and the time of day or lighting condition.\n2. Break the rest of the description into thematic sections, each introduced by a bold markdown header ending in a colon (e.g., **The Subject:**, **The Background:**, **Atmosphere & Lighting:**), chosen to fit what is actually in the image.\n3. Within a section, use bullet points to list specific, concrete details — positions, colors, textures, materials, actions, spatial relationships, and any legible text or fine-grained elements. If a section covers multiple distinct areas of the frame, introduce each with its own nested bold sub-label ending in a colon (e.g., **Foreground Right:**, **Background:**) before its bullet points.\n4. Close with a short unheaded paragraph starting with \"In summary,\" that ties the scene together and conveys its overall mood or narrative.\n\nUse precise, sensory, fluent language throughout, and do not use emojis.<|im_end|>\n' }}
|
| 15 |
+
{%- endif %}
|
| 16 |
+
{%- set image_count = namespace(value=0) %}
|
| 17 |
+
{%- set video_count = namespace(value=0) %}
|
| 18 |
+
{%- for message in messages %}
|
| 19 |
+
{%- if message.role == "user" %}
|
| 20 |
+
{{- '<|im_start|>' + message.role + '\n' }}
|
| 21 |
+
{%- if message.content is string %}
|
| 22 |
+
{{- message.content }}
|
| 23 |
+
{%- else %}
|
| 24 |
+
{%- for content in message.content %}
|
| 25 |
+
{%- if content.type == 'image' or 'image' in content or 'image_url' in content %}
|
| 26 |
+
{%- set image_count.value = image_count.value + 1 %}
|
| 27 |
+
{%- if add_vision_id %}Picture {{ image_count.value }}: {% endif -%}
|
| 28 |
+
<|vision_start|><|image_pad|><|vision_end|>
|
| 29 |
+
{%- elif content.type == 'video' or 'video' in content %}
|
| 30 |
+
{%- set video_count.value = video_count.value + 1 %}
|
| 31 |
+
{%- if add_vision_id %}Video {{ video_count.value }}: {% endif -%}
|
| 32 |
+
<|vision_start|><|video_pad|><|vision_end|>
|
| 33 |
+
{%- elif 'text' in content %}
|
| 34 |
+
{{- content.text }}
|
| 35 |
+
{%- endif %}
|
| 36 |
+
{%- endfor %}
|
| 37 |
+
{%- endif %}
|
| 38 |
+
{{- '<|im_end|>\n' }}
|
| 39 |
+
{%- elif message.role == "assistant" %}
|
| 40 |
+
{{- '<|im_start|>' + message.role + '\n' }}
|
| 41 |
+
{%- if message.content is string %}
|
| 42 |
+
{{- message.content }}
|
| 43 |
+
{%- else %}
|
| 44 |
+
{%- for content_item in message.content %}
|
| 45 |
+
{%- if 'text' in content_item %}
|
| 46 |
+
{{- content_item.text }}
|
| 47 |
+
{%- endif %}
|
| 48 |
+
{%- endfor %}
|
| 49 |
+
{%- endif %}
|
| 50 |
+
{{- '<|im_end|>\n' }}
|
| 51 |
+
{%- endif %}
|
| 52 |
+
{%- endfor %}
|
| 53 |
+
{%- if add_generation_prompt %}
|
| 54 |
+
{{- '<|im_start|>assistant\n' }}
|
| 55 |
+
{%- endif %}
|
config.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Qwen3VLForConditionalGeneration"
|
| 4 |
+
],
|
| 5 |
+
"bos_token_id": null,
|
| 6 |
+
"dtype": "bfloat16",
|
| 7 |
+
"eos_token_id": 151645,
|
| 8 |
+
"image_token_id": 151655,
|
| 9 |
+
"model_type": "qwen3_vl",
|
| 10 |
+
"pad_token_id": 151643,
|
| 11 |
+
"text_config": {
|
| 12 |
+
"attention_bias": false,
|
| 13 |
+
"attention_dropout": 0.0,
|
| 14 |
+
"bos_token_id": 151643,
|
| 15 |
+
"dtype": "bfloat16",
|
| 16 |
+
"eos_token_id": 151645,
|
| 17 |
+
"head_dim": 128,
|
| 18 |
+
"hidden_act": "silu",
|
| 19 |
+
"hidden_size": 2560,
|
| 20 |
+
"initializer_range": 0.02,
|
| 21 |
+
"intermediate_size": 9728,
|
| 22 |
+
"max_position_embeddings": 262144,
|
| 23 |
+
"model_type": "qwen3_vl_text",
|
| 24 |
+
"num_attention_heads": 32,
|
| 25 |
+
"num_hidden_layers": 36,
|
| 26 |
+
"num_key_value_heads": 8,
|
| 27 |
+
"pad_token_id": null,
|
| 28 |
+
"rms_norm_eps": 1e-06,
|
| 29 |
+
"rope_parameters": {
|
| 30 |
+
"mrope_interleaved": true,
|
| 31 |
+
"mrope_section": [
|
| 32 |
+
24,
|
| 33 |
+
20,
|
| 34 |
+
20
|
| 35 |
+
],
|
| 36 |
+
"rope_theta": 5000000,
|
| 37 |
+
"rope_type": "default"
|
| 38 |
+
},
|
| 39 |
+
"tie_word_embeddings": true,
|
| 40 |
+
"use_cache": true,
|
| 41 |
+
"vocab_size": 151936
|
| 42 |
+
},
|
| 43 |
+
"tie_word_embeddings": true,
|
| 44 |
+
"transformers_version": "5.14.1",
|
| 45 |
+
"video_token_id": 151656,
|
| 46 |
+
"vision_config": {
|
| 47 |
+
"deepstack_visual_indexes": [
|
| 48 |
+
5,
|
| 49 |
+
11,
|
| 50 |
+
17
|
| 51 |
+
],
|
| 52 |
+
"depth": 24,
|
| 53 |
+
"dtype": "bfloat16",
|
| 54 |
+
"hidden_act": "gelu_pytorch_tanh",
|
| 55 |
+
"hidden_size": 1024,
|
| 56 |
+
"in_channels": 3,
|
| 57 |
+
"initializer_range": 0.02,
|
| 58 |
+
"intermediate_size": 4096,
|
| 59 |
+
"model_type": "qwen3_vl_vision",
|
| 60 |
+
"num_heads": 16,
|
| 61 |
+
"num_position_embeddings": 2304,
|
| 62 |
+
"out_hidden_size": 2560,
|
| 63 |
+
"patch_size": 16,
|
| 64 |
+
"spatial_merge_size": 2,
|
| 65 |
+
"temporal_patch_size": 2
|
| 66 |
+
},
|
| 67 |
+
"vision_end_token_id": 151653,
|
| 68 |
+
"vision_start_token_id": 151652
|
| 69 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"do_sample": true,
|
| 3 |
+
"eos_token_id": [
|
| 4 |
+
151645,
|
| 5 |
+
151645,
|
| 6 |
+
151643
|
| 7 |
+
],
|
| 8 |
+
"pad_token_id": 151643,
|
| 9 |
+
"temperature": 0.7,
|
| 10 |
+
"top_k": 20,
|
| 11 |
+
"top_p": 0.8,
|
| 12 |
+
"transformers_version": "5.14.1"
|
| 13 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bea537423c50d58d116e7bd963dd1010a574a2f1b23cc31870c9052adae3f610
|
| 3 |
+
size 8875719408
|
processor_config.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"image_processor": {
|
| 3 |
+
"data_format": "channels_first",
|
| 4 |
+
"default_to_square": true,
|
| 5 |
+
"do_convert_rgb": true,
|
| 6 |
+
"do_normalize": true,
|
| 7 |
+
"do_rescale": true,
|
| 8 |
+
"do_resize": true,
|
| 9 |
+
"image_mean": [
|
| 10 |
+
0.5,
|
| 11 |
+
0.5,
|
| 12 |
+
0.5
|
| 13 |
+
],
|
| 14 |
+
"image_processor_type": "Qwen2VLImageProcessor",
|
| 15 |
+
"image_std": [
|
| 16 |
+
0.5,
|
| 17 |
+
0.5,
|
| 18 |
+
0.5
|
| 19 |
+
],
|
| 20 |
+
"merge_size": 2,
|
| 21 |
+
"patch_size": 16,
|
| 22 |
+
"resample": 3,
|
| 23 |
+
"rescale_factor": 0.00392156862745098,
|
| 24 |
+
"size": {
|
| 25 |
+
"longest_edge": 16777216,
|
| 26 |
+
"shortest_edge": 65536
|
| 27 |
+
},
|
| 28 |
+
"temporal_patch_size": 2
|
| 29 |
+
},
|
| 30 |
+
"processor_class": "Qwen3VLProcessor",
|
| 31 |
+
"video_processor": {
|
| 32 |
+
"data_format": "channels_first",
|
| 33 |
+
"default_to_square": true,
|
| 34 |
+
"do_convert_rgb": true,
|
| 35 |
+
"do_normalize": true,
|
| 36 |
+
"do_rescale": true,
|
| 37 |
+
"do_resize": true,
|
| 38 |
+
"do_sample_frames": true,
|
| 39 |
+
"fps": 2,
|
| 40 |
+
"image_mean": [
|
| 41 |
+
0.5,
|
| 42 |
+
0.5,
|
| 43 |
+
0.5
|
| 44 |
+
],
|
| 45 |
+
"image_std": [
|
| 46 |
+
0.5,
|
| 47 |
+
0.5,
|
| 48 |
+
0.5
|
| 49 |
+
],
|
| 50 |
+
"max_frames": 768,
|
| 51 |
+
"merge_size": 2,
|
| 52 |
+
"min_frames": 4,
|
| 53 |
+
"patch_size": 16,
|
| 54 |
+
"resample": 3,
|
| 55 |
+
"rescale_factor": 0.00392156862745098,
|
| 56 |
+
"return_metadata": false,
|
| 57 |
+
"size": {
|
| 58 |
+
"longest_edge": 25165824,
|
| 59 |
+
"shortest_edge": 4096
|
| 60 |
+
},
|
| 61 |
+
"temporal_patch_size": 2,
|
| 62 |
+
"video_processor_type": "Qwen3VLVideoProcessor"
|
| 63 |
+
}
|
| 64 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ec81cf4cd3712164ba5c12a479975a0d80142cf066a39632c941c5b40e569bff
|
| 3 |
+
size 11422917
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": null,
|
| 5 |
+
"clean_up_tokenization_spaces": false,
|
| 6 |
+
"eos_token": "<|im_end|>",
|
| 7 |
+
"errors": "replace",
|
| 8 |
+
"is_local": false,
|
| 9 |
+
"local_files_only": false,
|
| 10 |
+
"max_length": 2048,
|
| 11 |
+
"model_max_length": 262144,
|
| 12 |
+
"pad_to_multiple_of": null,
|
| 13 |
+
"pad_token": "<|endoftext|>",
|
| 14 |
+
"pad_token_type_id": 0,
|
| 15 |
+
"padding_side": "right",
|
| 16 |
+
"processor_class": "Qwen3VLProcessor",
|
| 17 |
+
"split_special_tokens": false,
|
| 18 |
+
"stride": 0,
|
| 19 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 20 |
+
"truncation_side": "right",
|
| 21 |
+
"truncation_strategy": "longest_first",
|
| 22 |
+
"unk_token": null
|
| 23 |
+
}
|