Hard vs. Soft Trace Distillation for LLMs: Reusing Traces or Rebuilding Training Data
Trace distillation turns a teacher model’s intermediate behavior—reasoning steps, tool calls, self-corrections, and final answers—into training data for smaller student models. This article compares hard distillation, which reuses existing traces almost verbatim, with soft distillation, which generates, rewrites, and filters candidates with a stronger model, and covers data composition, validation, evaluation, and common failure modes.
When teams deploy LLM applications, they often want a student model to approach a stronger teacher on tasks such as code completion, multi-step reasoning, and tool calling while keeping inference latency and compute cost within an acceptable range. Trace distillation converts the intermediate process a teacher leaves on specific problems—thinking steps, tool calls, self-corrections, and final answers—into trainable samples. It does not copy weights directly. Instead, it uses behavioral data to constrain the student model’s output distribution.
The discussion often stops at whether distillation was done. A more useful engineering split is between hard and soft trace distillation. Hard distillation directly reuses existing traces. Soft distillation first uses a strong model to construct or filter data, then trains on it. Both can improve performance on specific tasks, but their data sources, bias amplification patterns, and compliance risks are very different.
What Is in a Trace?
A usable trace usually contains four types of information.
- Task context: the user’s goal, constraints, and existing code or document snippets.
- Process signals: step-by-step plans, retrieval or tool-call records, and error recovery.
- Supervision targets: the final answer and, optionally, process labels such as “whether this step cites the provided material.”
- Metadata: difficulty, domain, language, and whether the trace passed human spot checks.
During training, not every part of the process should be treated as a label that must be reproduced verbatim. A safer approach is to apply standard supervised learning to the final answer and use intermediate steps as auxiliary targets only on subsets that can be verified. Otherwise, the student learns to imitate the teacher’s tone and long explanations rather than to produce correct results under constraints.
Hard Distillation: Reusing Existing Traces
Hard distillation writes existing traces into the training set almost as-is: prompts, intermediate reasoning, tool returns, and answers keep their original structure, with only minimal cleaning such as removing obvious garbled text and normalizing line breaks. Its advantages are fast implementation and low labeling cost. On task types close to the source distribution, it can often raise automated evaluation scores quickly.
Its limitations are equally direct.
- The distribution is locked. The task types, error types, and phrasing habits the student sees all come from the same batch of traces. Generalization is poor after changing domains or tool protocols.
- Errors are amplified. Occasional teacher hallucinations, outdated interface assumptions, and unsafe code snippets enter the training set because they “look complete.”
- Process and answer may be inconsistent. Some traces contain long reasoning but a conclusion reached by guessing. Hard distillation learns that inconsistency as well.
- Licensing and privacy are unclear. If traces contain user code, key samples, internal documents, or long copyrighted text, loading them as-is turns compliance issues into training-data issues.
Hard distillation fits narrow scenarios: internal Q&A logs with authorization, highly fixed-format tickets, and traces that can each be verified by rules or unit tests. Even then, de-identification, secret scanning, and deduplication should come first rather than dumping in the entire batch.
A schematic flow can be written as a data pipeline rather than tied to a specific training framework:
raw_trace -> redact(secrets, pii)-> validate(answer, tests_or_rules)-> drop_if(process_contradicts_answer)-> dedupe(by task_signature)-> mix(with human_gold, ratio)-> train(student, loss=answer + optional_process)
A “task signature” can use a normalized prompt hash plus key constraints to prevent slight rewrites of the same problem from filling a batch. Process loss should be downweighted: if the answer is wrong, a process that looks similar has no supervision value.
Soft Distillation: Construction, Rewriting, and Filtering
Soft distillation does not treat a single trace as a standard answer that must be copied. It treats the strong model as a data factory: generate candidates, rewrite difficulty, add counterexamples, and keep high-quality samples using checkable criteria. The teacher’s role is to expand coverage and provide drafts; the student ultimately aligns to filtered targets.
Typical steps are as follows.
- Define the task specification. Input fields, output format, prohibited items (for example, do not invent an interface that was not provided), and what counts as “correct.” The specification comes before generation.
- Stratified sampling of seed problems. Bucket by domain, difficulty, language, and whether tool calling is required so that popular task types do not dominate.
- Multi-path generation. Produce multiple candidate traces for the same specification. Temperature and prompt focus can differ, but generation conditions should be recorded for later bias tracing.
- Independent validation. Use tests where tests can run; use citation consistency against source material; use human sampling where automatic judgment is not possible. The validator should not share the same unisolated prompt with the generator, or it may “prove itself.”
- Filtering and rewriting. Drop samples with wrong conclusions, contradictions between steps and conclusions, leaked placeholder secrets, or mere restatements of the prompt. When necessary, keep only the final answer and brief evidence, and remove long reasoning that cannot be verified.
- Mixing for training. Mix synthetic data with human gold labels and authorized business logs by bucket, and cap the synthetic share to prevent style monoculture.
The cost of soft distillation lies in validation, not in “one more generation call.” Synthetic data without validation is essentially another form of hard distillation: the traces are newly made, but the bias is more hidden.
Filtering can use simple, explainable rule-based scoring instead of adding another unauditable black box:
keep ifformat_okand tests_pass_or_citation_okand no_secret_patternand answer_supported_by_contextand length_within_budgetscore = pass_rate + novelty_vs_seed - style_penalty
Novelty suppresses near duplicates; style penalty reduces empty talk and fixed phrases. Scores are for ranking and quotas only. They cannot replace the hard gate of whether the answer is valid.
How to Choose Rather Than Pick a Side
Three questions can determine the primary path.
- Is there a standard for automatically judging correctness? If yes, soft distillation’s filtering benefits are large. If no, hard distillation only freezes uncertainty.
- Is the authorization boundary of the traces clear? If not, both approaches should stop at redaction and impact assessment. Training cannot come first with paperwork later.
- Is the goal to reproduce a batch of historical behavior or to be correct under new constraints? Reproducing historical logs can use a small proportion of hard distillation. For new interfaces and new specifications, soft distillation plus gold labels should dominate.
In practice, hybrid approaches are common: verified successful traces from business operations make up a small portion; synthetic data fills scarce buckets such as failure recovery, edge inputs, and multilingual cases; human gold labels calibrate the evaluation set; and the evaluation set is isolated from training seeds. Once the evaluation set has been seen by the generation process, scores no longer represent generalization.
Evaluation Should Not Only Check “Looks Like the Teacher”
At minimum, evaluate four categories of metrics.
- Task correctness: unit-test pass rate, exact match, or human spot-checked factual consistency.
- Process quality: whether steps cite the given material, whether tool calls follow the protocol, and whether the model stops after failure instead of looping and fabricating.
- Robustness: how much accuracy drops after rewriting prompts, shuffling irrelevant context, or replacing constraints with equivalent ones.
- Safety and compliance spot checks: whether the model emits secret-like patterns that should not appear in training, reproduces long protected text, or gives definitive conclusions without evidence.
“Literal similarity to teacher output” is only an auxiliary metric. High similarity without higher accuracy means the model learned style. Higher accuracy that collapses under a different phrasing means overfitting to trace templates.
On the training side, record the data recipe: bucket ratios, synthetic batches, filter rule versions, and gold-label versions. Without the recipe, online rollback cannot tell whether the student model degraded or a filter removed all hard negatives.
Common Failures and Corrections
Failure 1: Treating the entire long chain of thought as gold. Correction: supervise only verifiable segments; treat the rest as optional context, not as labels that must be reproduced.
Failure 2: Using the same model to generate questions and judge answers. Correction: prioritize programs, rules, or another independent standard for judging. Use humans only for disputed samples and a fixed proportion of each bucket.
Failure 3: Synthetic data overwhelms the real distribution. Correction: set quotas by online traffic buckets and preserve rare but critical failure paths separately rather than averaging by sample count.
Failure 4: Cleaning removes names but not secrets and internal paths. Correction: use pattern scanning plus sampled human review. When a hit occurs, discard the whole segment rather than masking it and continuing to train.
Failure 5: Reporting only one total score before and after distillation. Correction: report by bucket with a fixed evaluation set. A total score increase may simply reflect more easy questions.
How It Fits with General Training Components
Trace files are suitable for object storage with immutable batch writes. Cleaning and validation should be written as rerunnable tasks, with logs going to centralized logging and monitoring and alerts on filter rates and test pass rates. Training can use standard supervised fine-tuning: compute the main loss at answer positions and add auxiliary loss at process positions only when they are marked “verified.” At inference time, there is no need to force reproduction of long training traces unless the product explicitly requires evidence display. When evidence is shown, it should come from citations in the current context, not from memorized distillation corpora.
If using cloud training and data platforms, stay with general capabilities: object storage, task scheduling, containerized training, and logging and monitoring alerts. Do not assume undisclosed interfaces or metrics. The recipe, filter rules, and evaluation-set versions are the portable assets.
Conclusion
Hard distillation is low-cost behavior cloning. It suits traces with clear authorization, verifiability, and a narrow distribution. Soft distillation is data engineering around “generate, validate, and mix”: use a strong model to expand coverage, but use independent standards to decide what is retained. Neither replaces task specifications and an isolated evaluation set. Treat traces as auditable data rather than treating one complete output as the gold answer. Then the student model is more likely to be correct under new constraints instead of learning the teacher’s habits and errors along with its answers.
