Models

What Is Knowledge Distillation?

A training method where a smaller student model learns to imitate a larger teacher model's behavior for cheaper inference.

What Is Knowledge Distillation?

Knowledge distillation is a model-compression training method where a smaller student model learns to imitate a larger teacher model’s outputs, probabilities, or reasoning traces. It belongs to the model family because it changes how a model is trained before inference, then shows up in production traces as a cheaper or faster model route. FutureAGI treats distillation as a release risk: compare the student against the teacher on quality, grounding, tool behavior, cost, and latency before serving users.

Why Knowledge Distillation Matters in Production LLM and Agent Systems

Knowledge distillation can turn an expensive frontier-model workflow into a lower-cost specialized model, but the risk is a student that copies surface behavior and loses the teacher’s edge cases. The most common failure mode is capability regression: the student answers common support questions well but misses rare policy clauses, multilingual phrasing, or numerical constraints. The second is safety and calibration drift: the student becomes more confident than the teacher on uncertain answers, which increases hallucinated claims or weak refusals.

Developers feel this when a distilled model passes demo prompts but fails held-out traces. SREs see attractive p50 latency and cost numbers while retry rate, fallback rate, or p99 latency rises under real traffic. Product teams see short answers that look efficient but receive more thumbs-down feedback. Compliance teams care because a student may compress away disclaimers, citation habits, or refusal boundaries that were present in the teacher.

Symptoms appear across evals and logs: lower FactualAccuracy on long-tail prompts, lower Groundedness on RAG answers, more JSONValidation failures in structured outputs, and a higher escalation rate for cohorts routed to the student. In 2026 multi-step agent systems, small student errors compound. A distilled planner that chooses the wrong tool once can poison memory, skip a retrieval step, or hand a bad argument to the next span.

How FutureAGI Handles Knowledge Distillation Risk

Knowledge distillation is not a standalone FutureAGI evaluator. FutureAGI’s approach is to treat the student model as a candidate release that must prove it preserves the production contract of the teacher. The workflow starts with a held-out dataset in fi.datasets.Dataset: prompts, retrieved context, expected tool calls, teacher outputs, and cohort tags such as billing, out_of_domain, long_context, or regulated_answer.

The engineer attaches FactualAccuracy, Groundedness, TaskCompletion, JSONValidation, and, for agents, ToolSelectionAccuracy through Dataset.add_evaluation. The student is then scored against the teacher and against any human gold answers. If the student improves token cost but loses Groundedness on policy-heavy questions, it is not promoted globally.

For live evidence, traceAI instruments the serving path through traceAI-langchain or traceAI-openai. Spans carry the model route, prompt version, latency, and token fields such as llm.token_count.prompt and llm.token_count.completion. Agent Command Center can mirror traffic with traffic-mirroring, route low-risk cohorts through a routing policy: cost-optimized, and keep a model fallback to the teacher when thresholds fail.

Unlike a single Hugging Face benchmark score, this compares the student on the exact tasks, tools, contexts, and safety boundaries that production users hit. The next engineering action is concrete: add harder teacher examples, reject the student, route only safe cohorts, or keep mirroring until eval deltas stay below threshold.

How to Measure or Detect Knowledge Distillation Regressions

Measure distillation as a teacher-versus-student delta on the same inputs, not as an isolated student score.

  • Evaluator deltas: compare FactualAccuracy, Groundedness, HallucinationScore, TaskCompletion, and ToolSelectionAccuracy by cohort.
  • Trace fields: tag spans with teacher model, student model, route, prompt version, llm.token_count.prompt, and llm.token_count.completion.
  • Dashboard signals: watch eval-fail-rate-by-cohort, latency p99, token-cost-per-trace, retry rate, fallback rate, and timeout rate.
  • User proxies: compare thumbs-down rate, correction rate, escalation rate, and abandoned-task rate between teacher and student traffic.
from fi.evals import FactualAccuracy, Groundedness

facts = FactualAccuracy().evaluate(input=question, output=student_output)
grounded = Groundedness().evaluate(input=context, output=student_output)
print(facts.score, grounded.score)

The student is ready only when quality deltas remain within the release threshold for the cohorts that will receive traffic.

Common Mistakes

Common mistakes come from treating distillation as compression only:

  • Training on teacher outputs that contain hallucinations. The student learns the defect and may repeat it with higher confidence.
  • Evaluating only common prompts. Distilled students often fail rare policies, long-context tasks, multilingual inputs, and edge-case tool calls.
  • Ignoring structured outputs. A student can sound correct while breaking JSONValidation or required tool argument schemas.
  • Changing prompt and model together. You lose the baseline needed to identify whether the regression came from distillation.
  • Routing all traffic after one benchmark win. Start with cohort gates, trace tags, traffic-mirroring, and fallback to the teacher.

Frequently Asked Questions

What is knowledge distillation?

Knowledge distillation trains a smaller student model to imitate a larger teacher model's behavior. It is mainly used to lower inference cost or latency while preserving task quality.

How is knowledge distillation different from fine-tuning?

Fine-tuning adapts one model with task data. Knowledge distillation uses a teacher model as the target, so the student learns from teacher outputs, probabilities, or generated rationales.

How do you measure knowledge distillation?

Use FutureAGI evaluators such as FactualAccuracy, Groundedness, TaskCompletion, and ToolSelectionAccuracy, then compare teacher and student traces by model route, latency p99, and eval-fail-rate-by-cohort.