Instructions to use HuggingFaceTB/SmolLM3-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceTB/SmolLM3-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HuggingFaceTB/SmolLM3-3B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/SmolLM3-3B") model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM3-3B") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use HuggingFaceTB/SmolLM3-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceTB/SmolLM3-3B" # 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/SmolLM3-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/HuggingFaceTB/SmolLM3-3B
- SGLang
How to use HuggingFaceTB/SmolLM3-3B 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/SmolLM3-3B" \ --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/SmolLM3-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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/SmolLM3-3B" \ --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/SmolLM3-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use HuggingFaceTB/SmolLM3-3B with Docker Model Runner:
docker model run hf.co/HuggingFaceTB/SmolLM3-3B
Tool calls aren't rendered by the chat template
It seems like the tool calls aren't rendered by the chat template:
from transformers import AutoTokenizer
def multiply(a: int, b: int) -> int:
"""
Multiplies two integers.
Args:
a: The first integer.
b: The second integer.
Returns:
The product of the two integers.
"""
return a * b
tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/SmolLM3-3B")
messages = [
{"role": "user", "content": "Multiply 3 and 4"},
{"role": "assistant", "content": "", "tool_calls": [{"type": "function", "function": {"name": "multiply", "arguments": {"a": 3, "b": 4}}}]}, # this one won't be rendered
{ "role": "tool", "name": "multiply", "content": "12"},
]
print(tokenizer.apply_chat_template(messages, tools=[multiply], tokenize=False))
<|im_start|>system
## Metadata
Knowledge Cutoff Date: June 2025
Today Date: 25 November 2025
Reasoning Mode: /think
## Custom Instructions
You are a helpful AI assistant named SmolLM, trained by Hugging Face. Your role as an assistant involves thoroughly exploring questions through a systematic thinking process before providing the final precise and accurate solutions. This requires engaging in a comprehensive cycle of analysis, summarizing, exploration, reassessment, reflection, backtracking, and iteration to develop well-considered thinking process. Please structure your response into two main sections: Thought and Solution using the specified format: <think> Thought section </think> Solution section. In the Thought section, detail your reasoning process in steps. Each step should include detailed considerations such as analysing questions, summarizing relevant findings, brainstorming new ideas, verifying the accuracy of the current steps, refining any errors, and revisiting previous steps. In the Solution section, based on various attempts, explorations, and reflections from the Thought section, systematically present the final solution that you deem correct. The Solution section should be logical, accurate, and concise and detail necessary steps needed to reach the conclusion.
### Tools
You may call one or more functions to assist with the user query.
You are provided with function signatures within <tools></tools> XML tags:
<tools>
{'type': 'function', 'function': {'name': 'multiply', 'description': 'Multiplies two integers.', 'parameters': {'type': 'object', 'properties': {'a': {'type': 'integer', 'description': 'The first integer.'}, 'b': {'type': 'integer', 'description': 'The second integer.'}}, 'required': ['a', 'b']}, 'return': {'type': 'integer', 'description': 'The product of the two integers.'}}}
</tools>
For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
<tool_call>
{"name": <function-name>, "arguments": <args-json-object>}
</tool_call>
<|im_end|>
<|im_start|>user
Multiply 3 and 4<|im_end|>
<|im_start|>assistant
<|im_end|>
<|im_start|>user
12<|im_end|>
what I would expect vs what I get:
...
<|im_start|>assistant
+ <tool_call>
+ {"name": "multiply", "arguments": {"a": 3, "b": 4}}
+ </tool_call>
<|im_end|>
...
I think this is because in the training data, the messages for tool calls are not formatted like the ones in @qgallouedec ’s example. Looking at https://huggingface.co/datasets/HuggingFaceTB/smoltalk2/viewer/SFT/smolagents_toolcalling_traces_think?views%5B%5D=sft_smolagents_toolcalling_traces_think&conversation-viewer=0 it seem like the message is already formatted:
[
{
"content": "New task:\nAs of August 1 2024, what is the most recently described genus of Colosteidae?",
"role": "user"
},
{
"content": "<think>I need to search online for the latest scientific publications or announcements to determine which genus of Colosteidae was most recently described.</think>\n<tool_call>{'name': 'web_search', 'arguments': {'query': 'most recently described genus of Colosteidae'}}</tool_call>",
"role": "assistant"
},
]
I think we would need to adjust the chat template to be like the Qwen3 models in order to format messges with tool calls like the ones