Zenaique

DeepSeek style reasoning distillation: what travels from teacher to student, and what gets cut from the loss?

Short answer·Medium·4.0 · 0·~3 min·Asked atGleanMeeshoRoblox·Relevant atAnthropicCoreweaveDatabricksFireworks Ai
Attempt it

In a DeepSeek style reasoning distillation recipe, describe what the teacher actually produces, what shape the student's training examples take, which tokens are inside the loss versus masked out, and why the distillation collapses if the chain-of-thought is dropped from the target.

Free · 2 AI evals / day
TL;DR

Teacher emits trace plus answer. Each example is a (problem, trace, answer) triple; SFT loss covers trace and answer with the prompt masked. Drop the trace and you teach answer-copying, not reasoning.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine learning math from a tutor in two different styles. In style one, the tutor solves problems on a whiteboard step by step, and you copy the whole working including every line of arithmetic. In style two, the tutor only writes the final answer at the bottom and erases the rest. After a week of style one, you can solve new problems because you internalised the procedure. After a week of style two, you can recite the answers to the problems you saw, but a new problem stumps you because you never saw how the tutor got there. DeepSeek-style distillation works because the student copies the whole whiteboard, including the messy middle. Skip the middle and the student learns to mimic the bottom line of a fixed list of problems.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

DeepSeek-style reasoning distillation looks superficially like ordinary supervised fine-tuning. The loss function is the same completion-only cross-entropy used in any chat-template SFT recipe. The optimizer, the schedule, and the gradient flow are unchanged. What makes the recipe distinctive is what is in the data and where the boundary between prompt and response is drawn. Everything load-bearing about the technique sits in those two design choices.

The data choice is to use a strong reasoning teacher to produce, for each hard problem, a complete chain-of-thought trace followed by a final answer. Both parts of the teacher's output become part of the supervised target. The boundary choice is to format the example so that the problem sits in the prompt span and the trace plus answer sits in the response span. Loss masking then leaves the trace and the answer both inside cross-entropy.

This sounds mundane, and that is the point. The recipe's leverage comes from forcing the student to predict every intermediate token of the teacher's reasoning, not just the final answer. Token-level prediction over the trace is what compresses the teacher's reasoning procedure into the student's weights. Strip the trace out of the target and the student is left with a shallow lookup table from problems to answers. Keep the trace in and the student inherits an entire reasoning policy. This deep dive walks through the data construction, the loss masking, the quality filtering, the mechanism by which trace inclusion produces generalisation, and the operational realities that come with very long response sequences.

What the teacher emits and how examples are assembled

The teacher is a strong reasoning model, typically a frontier system like DeepSeek R1, Claude Opus 4.7, GPT-5.5, or a comparably strong open-weight system. It is prompted on hard problems, often math, code, or multi-step reasoning, with an elicitation that asks for explicit step by step working. The output is a single token sequence that contains the reasoning trace followed by the final answer.

The trace is not a separate field. It is just the early part of the teacher's response, before the answer is stated. A typical math example might begin with the teacher restating the problem, sketching an approach, working through arithmetic over several paragraphs, and concluding with a boxed or labelled final number. The trace and answer are textually one continuous span in the teacher's output.

Each training example for the student is built by formatting this output through the student's chat template. The user turn holds the problem. The assistant turn holds the trace plus the answer as a single response. Standard tools like the TRL SFTTrainer or the OpenAI fine-tuning interfaces accept exactly this shape, so the assembly is mechanical once the teacher outputs are in hand.

Volumes matter for scaling. A typical DeepSeek-style distillation corpus runs from tens of thousands to millions of triples, depending on student size and target capability. The teacher passes are the expensive step. They are usually batched, often sampled at multiple temperatures with rejection on correctness, and cached aggressively because re-sampling the same problem to recover a lost trace is wasteful.

Loss masking: prompt out, trace and answer in
Why answer-only supervision collapses the recipe
Quality filtering and trace selection
Operational realities: long sequences and inference cost
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • DeepSeek's R1 distillation release publicly demonstrated this recipe by distilling reasoning behavior from R1 into smaller dense models, with the full chain-of-thought kept inside the supervised target.
  • Open-source replications such as OpenThoughts and DeepSeek V4 Reasoning distill curated trace plus answer datasets from strong teachers like Claude Opus 4.7 or GPT-5.5 into 7B to 70B students.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow does trace distillation compare to logit distillation on the same teacher?
A

Logit distillation matches the teacher's full output distribution per token, requiring teacher logits over the vocabulary; trace distillation only uses sampled token sequences. Trace distillation is cheaper to collect and store, more flexible across teachers, but loses the soft-label information that logit distillation preserves.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Treating the trace as part of the prompt rather than part of the response. The trace must sit inside the loss; the student is being graded on reproducing it, not conditioning on it.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • What the teacher emits per problem and how it is sampled

  • The (problem, trace, answer) triple as the unit of training data

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What is RLHF, and why is it used after pretraining?
MCQ·Easy