Instructions to use HuggingFaceTB/SmolVLM2-500M-Video-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceTB/SmolVLM2-500M-Video-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="HuggingFaceTB/SmolVLM2-500M-Video-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/SmolVLM2-500M-Video-Instruct") model = AutoModelForMultimodalLM.from_pretrained("HuggingFaceTB/SmolVLM2-500M-Video-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/SmolVLM2-500M-Video-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceTB/SmolVLM2-500M-Video-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/SmolVLM2-500M-Video-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/SmolVLM2-500M-Video-Instruct
- SGLang
How to use HuggingFaceTB/SmolVLM2-500M-Video-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/SmolVLM2-500M-Video-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/SmolVLM2-500M-Video-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/SmolVLM2-500M-Video-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/SmolVLM2-500M-Video-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/SmolVLM2-500M-Video-Instruct with Docker Model Runner:
docker model run hf.co/HuggingFaceTB/SmolVLM2-500M-Video-Instruct
Commit History
-
Fix code typo in code examples
Verified signatureHello 👋 Based on [this PR for 2.2B version](https://huggingface.co/HuggingFaceTB/SmolVLM2-2.2B-Instruct/discussions/9) and [this for 256M version](https://huggingface.co/HuggingFaceTB/SmolVLM2-256M-Video-Instruct/discussions/6). I have included param `dtype=torch.bfloat16` when moving the processed inputs to CUDA (this is included in some examples, but not all). This should avoid mismatched tensor types between model weights and inputs. Sorry for spreading this over 3 PRs, I am not sure if there's a better way for such change🙂 Cheers, Michalb50c9b1
-
torch import missed in example (#9)
Verified signature- torch import missed in example (e85be16a7bb2c3c189881a5038df9dbf691246ea) Co-authored-by: Ahamed Musthafa R S <amrs-tech@users.noreply.huggingface.co>cd1ccdf
-
update readme dtype (#8)
Verified signature- update readme dtype (93cbb498ebc09b1d8190ba51c2d9f556c5d7a50a) Co-authored-by: Orr Zohar <orrzohar@users.noreply.huggingface.co>3444947
-
Update README.md
Verified signature9cc1eb8
-
Update README.md
Verified signature7399a56 -
Update README.md
Verified signaturecb25377 -
Added snippets (#7)
Verified signature- Added snippets (155b0bd93b0c48e156afe5fa74c55ffb45a2a845) Co-authored-by: Merve Noyan <merve@users.noreply.huggingface.co>e9c2a70 -
video_sampling.longest_edge -> 512 (#6)
Verified signature- video_sampling.longest_edge -> 512 (301708974d1f4a3d0d4f7fd4ba57bf1b2c235bfc) Co-authored-by: Pedro Cuenca <pcuenq@users.noreply.huggingface.co>4da1f23
-
Add missing config value (num_hidden_layers) (#4)
Verified signature- Add missing config value (num_hidden_layers) (11ca7ef66fc6450f9c97a753834aebad1e0274d6) Co-authored-by: Joshua <Xenova@users.noreply.huggingface.co>edf555f -
README update (#5)
Verified signature- README update (ea4bc575c05ed1426de6625984439dca3064a19a) Co-authored-by: Orr Zohar <orrzohar@users.noreply.huggingface.co>eb8cd98
-
Update README.md
Verified signaturef730b73
-
Add cast node to inputs_embeds (#3)
Verified signature- Add cast node to inputs_embeds (96c434406edf1a124c925a4667182d419c166f8a)a3992d5 -
Upload ONNX weights (#2)
Verified signature- Upload ONNX weights (fdf1f00ae1363019e28c4f74d5343fc0a35c2c3b) Co-authored-by: Joshua <Xenova@users.noreply.huggingface.co>fccdbb7 -
Upload processor
Verified signature2fb535e -
Update README.md
Verified signature82fc17e -
Update README.md
Verified signature2fa62eb -
Misc nits (#1)
Verified signature- Misc nits (624ec44992ebc2f1bb54958d64c4bcfd3db28fb6) Co-authored-by: Merve Noyan <merve@users.noreply.huggingface.co>65732f7
-
Upload 3 files
Verified signatured52b9cd -
Update README.md
Verified signature5761ea8 -
Update README.md
Verified signature0c4f490 -
Update README.md
Verified signatureb338671 -
Update README.md
Verified signature070aa5f -
Update README.md
Verified signaturec0282b1 -
Update README.md
Verified signatured0232c9 -
Update README.md
Verified signature5361082 -
Upload SmolVLMForConditionalGeneration
Verified signature3d70c32
-
Upload processor
Verified signature77df350 -
Upload SmolVLMForConditionalGeneration
Verified signature887618c -
initial commit
Verified signature85335e4