Possible mistake in the chat template?
I was trying out the chat template over here: https://huggingface.co/spaces/huggingfacejs/chat-template-playground?modelId=HuggingFaceTB%2FSmolLM3-3B&example=reasoning
I noticed that the assistant messages aren't being rendered into the final prompt - only the user messages. Is that intentional behavior?
Meaning, in a conversation user-assistant-user, only the two users messages are included in the prompt.
There seems to be an issue with the Chat Template Playground that omits the template block enclosed in {% generation %}...{% endgeneration %}
. You can check in the chat template that we include the assistant message, so it should work as expected outside the Chat Template Playground.
@cmpatino while on the topic, is there a mistake on the tool response template?
{%- elif message.role == "tool" -%}
{{ "<|im_start|>" + "user\n" + content + "<|im_end|>\n" }}
{%- endif -%}
It is being formatted as a user message. I was testing tool usage (fyi with mlx-community/SmolLM3-3B-4bit) and the model is indeed getting confused between user and tool messages, below i will put an example. I wasn't sure whether the problem is due to quantization or the chat template so wanted to ask...
<|im_start|>system
## Metadata
Knowledge Cutoff Date: June 2025
Today Date: 10 July 2025
Reasoning Mode: /think
## Custom Instructions
You are a helpful AI assistant. Your goal is to provide fast and accurate information.
**Instructions:**
1. First, decide whether a tool call is needed.
2. If a tool call is needed, use the appropriate tool.
3. When you have all the information, repond directly without further tool calls.
**Context:**
- Current date and time is 2025-07-10 14:16:42.
- The user locates in Italy.
- Preferred language is English.
<|im_start|>user
What is the weather in Milano right now?<|im_end|>
<|im_start|>assistant
<think>
Okay, the user is asking for the current weather in Milano, Italy. Let me check the available tools. There's a function called get_current_weather that can provide weather information for a city. The parameters needed are the city name and the unit of temperature. The user didn't specify the unit, so I should default to Celsius, which is the most common.
I need to make sure that the function call is correct. The city name is Milano, and the unit is Celsius. Let me structure the arguments properly. The function parameters are 'city' and 'unit', with 'unit' having an enum of 'celsius' and 'fahrenheit'. Since the user didn't specify, I'll use 'celsius' as the default.
Now, I should return the result in the specified format. The response should include the function name and arguments. So the JSON would be {"name": "get_current_weather", "arguments": {"city": "Milano", "unit": "celsius"}}.
Wait, the user wrote "Milano" with an 'o' instead of 'o' with an 'a'. Let me confirm the correct spelling. Milano is the Italian spelling, so it's correct.
I don't see any other tools needed here. The get_current_weather function should suffice. Let me put that together in the XML response as specified.
Final check: The function is available, the parameters are correct, and the unit is set to Celsius. All set. Time to return the response.
</think>
<tool_call>
{"name": "get_current_weather", "arguments": {"city": "Milano", "unit": "celsius"}}
</tool_call><|im_end|>
<|im_start|>user
The current temperature in Milano is 24°C.<|im_end|>
<|im_start|>assistant
<think>
Okay, the user asked for the weather in Milano, and I provided the current temperature. Now they're asking me to confirm the temperature again. Let me check the previous response. I said 24°C, so I should just repeat that. But wait, maybe they want more details? The user might be testing if I can provide consistent information. Since the initial response was based on the get_current_weather function, which should return accurate data, I can safely confirm the temperature again. No need for further action. Just respond with the same information.<|im_end|>