Log inSign up

Learn / [Tutorial 4]

What changes when a chat frame is wrapped on

SmolLM2 360MchatM02
What you will learn
In chat mode the job is stopping it from adding words

Addition again. What changed this time is chat mode, meaning a chat template is wrapped on. The raw used in lessons 1 and 3 put your text in as it was. chat puts it in surrounded by special tokens.

What gets wrapped around it

Open the full prompt on the problem and you see the text that actually goes in. Roughly this shape.

What actually goes into the model in chat mode
<|im_start|>system
You are a helpful AI assistant named SmolLM, trained by Hugging Face<|im_end|>
<|im_start|>user
3 + 3<|im_end|>
<|im_start|>assistant

Things like <|im_start|> are those markers. Because conversations were shown to the model in this shape while it was being built, the model starts acting as an assistant when this shape arrives. Instead of carrying text on, it sets out to reply.

An assistant can be too helpful for its own good

Becoming an assistant is usually a good thing. It follows instructions far better. But judging on this site allows not one character of difference from the expected value. So the helpfulness becomes the deduction.

Expected value
6
What an assistant readily produces
정답은 6입니다.

3 + 3 = 6 이기 때문입니다.

The arithmetic was right and it is still wrong. On top of that, unlike raw mode, chat mode does not look at the first line only, it looks at everything produced. One extra line on the end and it is wrong.

The job in chat mode is not getting the answer right, it is making sure nothing but the answer can be written.

How to stop it

  • Spell out what not to do. Listing prohibitions like No words, No explanation is followed better than one Korean line saying 숫자만 출력해 (output only the number).

  • Write in English. SmolLM2 learned in English. For the same meaning, English gets through far better.

  • Max tokens is 16. Start adding an explanation and it cannot finish inside 16 tokens, so it is cut off partway. A cut off text is wrong too.

  • If it still sticks something like 정답은 (the answer is) on, write out that it must not use those words.

Try it yourself

After passing with the sample answer, put the same prompt into the raw version of the same problem (M01). Same text, completely different result. That difference is what this lesson is about.

Example answer

Copy this as is into the box with the same name on the problem page. ␣ is a space, ↵ marks a line break. What gets copied is the original text.

pre_prompt
Output␣only␣the␣number.␣No␣words,␣no␣punctuation,␣no␣explanation.↵
↵
post_prompt
(leave it empty)

Once it passes, change it on purpose. Seeing what breaks it sticks with you longer than knowing the answer.