Instructions to use HuggingFaceTB/SmolVLM-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceTB/SmolVLM-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="HuggingFaceTB/SmolVLM-Instruct") 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("HuggingFaceTB/SmolVLM-Instruct") model = AutoModelForImageTextToText.from_pretrained("HuggingFaceTB/SmolVLM-Instruct") 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
- vLLM
How to use HuggingFaceTB/SmolVLM-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceTB/SmolVLM-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceTB/SmolVLM-Instruct", "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/HuggingFaceTB/SmolVLM-Instruct
- SGLang
How to use HuggingFaceTB/SmolVLM-Instruct 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 "HuggingFaceTB/SmolVLM-Instruct" \ --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": "HuggingFaceTB/SmolVLM-Instruct", "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 "HuggingFaceTB/SmolVLM-Instruct" \ --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": "HuggingFaceTB/SmolVLM-Instruct", "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 HuggingFaceTB/SmolVLM-Instruct with Docker Model Runner:
docker model run hf.co/HuggingFaceTB/SmolVLM-Instruct
Upload optimized language model w/ WebGPU-compatible GQA (#29)
Browse files- Upload optimized language model w/ WebGPU-compatible GQA (9b303242a8f9d326545b843e1df7034817c2edd3)
- Update config.json (ea0c9de5c48509edf8e2b35059502ff66a17e18f)
- config.json +4 -0
- onnx/decoder_model_merged.onnx +2 -2
- onnx/decoder_model_merged.onnx_data +1 -1
- onnx/decoder_model_merged_bnb4.onnx +2 -2
- onnx/decoder_model_merged_fp16.onnx +2 -2
- onnx/decoder_model_merged_fp16.onnx_data +2 -2
- onnx/decoder_model_merged_int8.onnx +2 -2
- onnx/decoder_model_merged_q4.onnx +2 -2
- onnx/decoder_model_merged_q4f16.onnx +2 -2
- onnx/decoder_model_merged_quantized.onnx +2 -2
- onnx/decoder_model_merged_uint8.onnx +2 -2
config.json
CHANGED
|
@@ -179,6 +179,10 @@
|
|
| 179 |
"embed_tokens": "auto",
|
| 180 |
"vision_encoder": "auto",
|
| 181 |
"decoder_model_merged": "q4"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
}
|
| 183 |
},
|
| 184 |
"use_cache": true,
|
|
|
|
| 179 |
"embed_tokens": "auto",
|
| 180 |
"vision_encoder": "auto",
|
| 181 |
"decoder_model_merged": "q4"
|
| 182 |
+
},
|
| 183 |
+
"use_external_data_format": {
|
| 184 |
+
"decoder_model_merged.onnx": true,
|
| 185 |
+
"decoder_model_merged_fp16.onnx": true
|
| 186 |
}
|
| 187 |
},
|
| 188 |
"use_cache": true,
|
onnx/decoder_model_merged.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a6a5013f7392cb1ab70de86049bdeaf4522599e682e51eeaf1ad22d0ebfffa44
|
| 3 |
+
size 167944
|
onnx/decoder_model_merged.onnx_data
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 6849724416
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9fc6bd88348afba41dcf8cc1727663cb88a150f3e35c5c011f80a14b48d4a6ec
|
| 3 |
size 6849724416
|
onnx/decoder_model_merged_bnb4.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e347876c58484dc6c51422ce04265e6054624754f1f8bb9cc7ac6076e55856bf
|
| 3 |
+
size 967377227
|
onnx/decoder_model_merged_fp16.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ec9bfa341a42d5060d69573f5dab1c8be24d9d8cc78af8649c6b077223dcb0c3
|
| 3 |
+
size 169023
|
onnx/decoder_model_merged_fp16.onnx_data
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2cc57156f23eeb36f3a8ed08504b2d050f8d221c1a67dcfc1eea089f93154437
|
| 3 |
+
size 3424862208
|
onnx/decoder_model_merged_int8.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:861dcec66dc59cd9e7f2622cf28b60917020f23ac43f11ab179893773da5dbda
|
| 3 |
+
size 1716222232
|
onnx/decoder_model_merged_q4.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:79e171c9285756185c74ed67e0f598d97bae71d2996f3752fb62dd08db4cbba6
|
| 3 |
+
size 1074331012
|
onnx/decoder_model_merged_q4f16.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:247de27f420790b553b94b29713c56278aedca18b8d68d63dd2e7d72cca397ef
|
| 3 |
+
size 965077981
|
onnx/decoder_model_merged_quantized.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9614d219c614af85de470c8870be65e8a3a1d00a8163fb3df8abb6cecb612399
|
| 3 |
+
size 1716222303
|
onnx/decoder_model_merged_uint8.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9614d219c614af85de470c8870be65e8a3a1d00a8163fb3df8abb6cecb612399
|
| 3 |
+
size 1716222303
|