Instructions to use trl-internal-testing/tiny-SmolVLMForConditionalGeneration with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trl-internal-testing/tiny-SmolVLMForConditionalGeneration with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="trl-internal-testing/tiny-SmolVLMForConditionalGeneration") 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("trl-internal-testing/tiny-SmolVLMForConditionalGeneration") model = AutoModelForMultimodalLM.from_pretrained("trl-internal-testing/tiny-SmolVLMForConditionalGeneration", 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use trl-internal-testing/tiny-SmolVLMForConditionalGeneration with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "trl-internal-testing/tiny-SmolVLMForConditionalGeneration" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "trl-internal-testing/tiny-SmolVLMForConditionalGeneration", "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/trl-internal-testing/tiny-SmolVLMForConditionalGeneration
- SGLang
How to use trl-internal-testing/tiny-SmolVLMForConditionalGeneration 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 "trl-internal-testing/tiny-SmolVLMForConditionalGeneration" \ --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": "trl-internal-testing/tiny-SmolVLMForConditionalGeneration", "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 "trl-internal-testing/tiny-SmolVLMForConditionalGeneration" \ --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": "trl-internal-testing/tiny-SmolVLMForConditionalGeneration", "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 trl-internal-testing/tiny-SmolVLMForConditionalGeneration with Docker Model Runner:
docker model run hf.co/trl-internal-testing/tiny-SmolVLMForConditionalGeneration
Upload SmolVLMForConditionalGeneration
Browse files- chat_template.jinja +1 -1
- config.json +2 -5
- generation_config.json +1 -1
- model.safetensors +1 -1
- tokenizer.json +8 -1
- video_preprocessor_config.json +1 -1
chat_template.jinja
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
-
<|im_start|>{% for message in messages %}{{message['role'] | capitalize}}{% if message['content'][0]['type'] == 'image' %}{{':'}}{% else %}{{': '}}{% endif %}{% for line in message['content'] %}{% if line['type'] == 'text' %}{{line['text']}}{% elif line['type'] == 'image' %}{{ '<image>' }}{% endif %}{% endfor %}<end_of_utterance>
|
| 2 |
{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}
|
|
|
|
| 1 |
+
<|im_start|>{% for message in messages %}{{message['role'] | capitalize}}{% if message['content'] is string %}{{': ' + message['content']}}{% else %}{% if message['content'][0]['type'] == 'image' %}{{':'}}{% else %}{{': '}}{% endif %}{% for line in message['content'] %}{% if line['type'] == 'text' %}{{line['text']}}{% elif line['type'] == 'image' %}{{ '<image>' }}{% endif %}{% endfor %}{% endif %}<end_of_utterance>
|
| 2 |
{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}
|
config.json
CHANGED
|
@@ -21,7 +21,6 @@
|
|
| 21 |
"hidden_size": 16,
|
| 22 |
"initializer_range": 0.02,
|
| 23 |
"intermediate_size": 8192,
|
| 24 |
-
"layer_types": null,
|
| 25 |
"max_position_embeddings": 8192,
|
| 26 |
"mlp_bias": false,
|
| 27 |
"model_type": "llama",
|
|
@@ -120,12 +119,11 @@
|
|
| 120 |
"vocab_size": 49280
|
| 121 |
},
|
| 122 |
"tie_word_embeddings": false,
|
| 123 |
-
"transformers_version": "4.
|
| 124 |
"use_cache": false,
|
| 125 |
"use_reentrant_checkpointing": false,
|
| 126 |
"vision_config": {
|
| 127 |
"attention_dropout": 0.0,
|
| 128 |
-
"embed_dim": 64,
|
| 129 |
"hidden_act": "gelu_pytorch_tanh",
|
| 130 |
"hidden_size": 16,
|
| 131 |
"image_size": 384,
|
|
@@ -136,10 +134,9 @@
|
|
| 136 |
"longest_edge": 384
|
| 137 |
},
|
| 138 |
"model_type": "smolvlm_vision",
|
| 139 |
-
"num_attention_heads":
|
| 140 |
"num_channels": 3,
|
| 141 |
"num_hidden_layers": 2,
|
| 142 |
-
"num_key_value_heads": 2,
|
| 143 |
"patch_size": 14,
|
| 144 |
"size": {
|
| 145 |
"longest_edge": 1920
|
|
|
|
| 21 |
"hidden_size": 16,
|
| 22 |
"initializer_range": 0.02,
|
| 23 |
"intermediate_size": 8192,
|
|
|
|
| 24 |
"max_position_embeddings": 8192,
|
| 25 |
"mlp_bias": false,
|
| 26 |
"model_type": "llama",
|
|
|
|
| 119 |
"vocab_size": 49280
|
| 120 |
},
|
| 121 |
"tie_word_embeddings": false,
|
| 122 |
+
"transformers_version": "4.56.2",
|
| 123 |
"use_cache": false,
|
| 124 |
"use_reentrant_checkpointing": false,
|
| 125 |
"vision_config": {
|
| 126 |
"attention_dropout": 0.0,
|
|
|
|
| 127 |
"hidden_act": "gelu_pytorch_tanh",
|
| 128 |
"hidden_size": 16,
|
| 129 |
"image_size": 384,
|
|
|
|
| 134 |
"longest_edge": 384
|
| 135 |
},
|
| 136 |
"model_type": "smolvlm_vision",
|
| 137 |
+
"num_attention_heads": 2,
|
| 138 |
"num_channels": 3,
|
| 139 |
"num_hidden_layers": 2,
|
|
|
|
| 140 |
"patch_size": 14,
|
| 141 |
"size": {
|
| 142 |
"longest_edge": 1920
|
generation_config.json
CHANGED
|
@@ -3,5 +3,5 @@
|
|
| 3 |
"bos_token_id": 0,
|
| 4 |
"eos_token_id": 49279,
|
| 5 |
"pad_token_id": 2,
|
| 6 |
-
"transformers_version": "4.
|
| 7 |
}
|
|
|
|
| 3 |
"bos_token_id": 0,
|
| 4 |
"eos_token_id": 49279,
|
| 5 |
"pad_token_id": 2,
|
| 6 |
+
"transformers_version": "4.56.2"
|
| 7 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 10798536
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:31a447c9d8c529b4fff16dc9e983a8cfbc1e435b6ed1203a13b094b9431f0193
|
| 3 |
size 10798536
|
tokenizer.json
CHANGED
|
@@ -1,7 +1,14 @@
|
|
| 1 |
{
|
| 2 |
"version": "1.0",
|
| 3 |
"truncation": null,
|
| 4 |
-
"padding":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
"added_tokens": [
|
| 6 |
{
|
| 7 |
"id": 0,
|
|
|
|
| 1 |
{
|
| 2 |
"version": "1.0",
|
| 3 |
"truncation": null,
|
| 4 |
+
"padding": {
|
| 5 |
+
"strategy": "BatchLongest",
|
| 6 |
+
"direction": "Right",
|
| 7 |
+
"pad_to_multiple_of": null,
|
| 8 |
+
"pad_id": 2,
|
| 9 |
+
"pad_type_id": 0,
|
| 10 |
+
"pad_token": "<|im_end|>"
|
| 11 |
+
},
|
| 12 |
"added_tokens": [
|
| 13 |
{
|
| 14 |
"id": 0,
|
video_preprocessor_config.json
CHANGED
|
@@ -28,7 +28,6 @@
|
|
| 28 |
"longest_edge": 384
|
| 29 |
},
|
| 30 |
"num_frames": 64,
|
| 31 |
-
"pad_size": null,
|
| 32 |
"processor_class": "SmolVLMProcessor",
|
| 33 |
"resample": 1,
|
| 34 |
"rescale_factor": 0.00392156862745098,
|
|
@@ -36,6 +35,7 @@
|
|
| 36 |
"size": {
|
| 37 |
"longest_edge": 1536
|
| 38 |
},
|
|
|
|
| 39 |
"video_metadata": null,
|
| 40 |
"video_processor_type": "SmolVLMVideoProcessor",
|
| 41 |
"video_sampling": {
|
|
|
|
| 28 |
"longest_edge": 384
|
| 29 |
},
|
| 30 |
"num_frames": 64,
|
|
|
|
| 31 |
"processor_class": "SmolVLMProcessor",
|
| 32 |
"resample": 1,
|
| 33 |
"rescale_factor": 0.00392156862745098,
|
|
|
|
| 35 |
"size": {
|
| 36 |
"longest_edge": 1536
|
| 37 |
},
|
| 38 |
+
"size_divisor": null,
|
| 39 |
"video_metadata": null,
|
| 40 |
"video_processor_type": "SmolVLMVideoProcessor",
|
| 41 |
"video_sampling": {
|