Instructions to use HuggingFaceTB/SmolVLM-500M-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceTB/SmolVLM-500M-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="HuggingFaceTB/SmolVLM-500M-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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("HuggingFaceTB/SmolVLM-500M-Instruct") model = AutoModelForMultimodalLM.from_pretrained("HuggingFaceTB/SmolVLM-500M-Instruct", 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 HuggingFaceTB/SmolVLM-500M-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceTB/SmolVLM-500M-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-500M-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-500M-Instruct
- SGLang
How to use HuggingFaceTB/SmolVLM-500M-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-500M-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-500M-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-500M-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-500M-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-500M-Instruct with Docker Model Runner:
docker model run hf.co/HuggingFaceTB/SmolVLM-500M-Instruct
Commit History
-
[work in progress] Upload optimized language model w/ WebGPU-compatible GQA
Verified signaturea955a18
-
Update README.md
Verified signaturebfbdfca
-
Update tokenizer_config.json
Verified signaturec4ecf4f
-
Wrap fp16 inputs for ONNX decoder (#3)
Verified signature- Wrap fp16 inputs for ONNX decoder (9ab0f879a3f2beb9a7137b197f7e9c3ba9cd6dbe)a588b62 -
Update config.json
Verified signature1f54d91 -
Update chat template (#2)
Verified signature- Update chat template (dfffb6e7622a286a500146106027bc181c99a80e)8ae59b6 -
Update README.md
Verified signature7a8ac21 -
Update README.md
Verified signature401eccf -
Update README.md
Verified signature77dd960 -
Update README.md
Verified signature63e61a6 -
Update README.md
Verified signaturec7ecde1
-
Upload ONNX weights (#1)
Verified signature- Upload ONNX weights (95d34b65f278eeef13485331c9290fc8af68f5d2) Co-authored-by: Joshua <Xenova@users.noreply.huggingface.co>81ab8f4 -
Update README.md
Verified signaturecb498da -
Update README.md
Verified signatureb2c53bd -
Update README.md
Verified signature46d6298
-
Create chat_template.json
Verified signature6eccbc1 -
Update generation_config.json
Verified signature0c2e2b5 -
Update preprocessor_config.json
Verified signaturebd4470f -
Update tokenizer_config.json
Verified signature7aea535 -
Upload processor
Verified signaturee2d2124 -
Upload Idefics3ForConditionalGeneration
Verified signaturefcf5534 -
initial commit
Verified signaturec365bd7