Walk through one training example for SFT'ing a single weather-tool call.
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
A team wants to fine-tune a 7B chat model so it reliably calls a single `get_weather(city)` tool. Write out, end to end, what ONE training row in the SFT JSONL looks like, the message turns, the roles, what gets masked from the loss, and at least one important negative example you'd also include. Explain why each piece is there.
A positive row is four turns: user, assistant tool call, tool result, assistant grounded reply. Loss runs only on the two assistant turns, and the dataset must include negatives so the tool is not called for everything.
Picture training a new librarian to use one reference book. You stage a conversation where someone asks a real reference question, the librarian flips open the book, the book shows the page, and the librarian reads the answer aloud. You grade the librarian only on two moments: opening the right book and explaining the right page in plain words. You do not grade what the patron said or what the book literally printed. You also stage other conversations where the patron asks something the book cannot answer, and you teach the librarian to just talk normally without grabbing the book. Without those second kinds of conversations, the librarian learns to grab the book for every question and looks silly when someone asks the time.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
5 min: four-turn row shape + role of each turn + loss masking on user and tool turns + why both assistant turns matter + negative rows for over-invocation + argument variety + scaling considerations.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Training only on positives where the tool is called. The model latches on to the shape question equals tool call and starts firing get_weather at trivia questions, the classic over-invocation failure mode.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.