knowledge-distillation
Expert-level knowledge about AI/ML knowledge distillation — a training paradigm where a student model learns from a teacher model. Use this skill whenever the user asks about knowledge distillation, teacher-student learning, model compression via distillation, soft targets, KD loss, on-policy distillation, off-policy distillation, self-distillation, multi-teacher distillation, sequence-level KD, GKD (Generalized Knowledge Distillation), OPD (On-Policy Distillation), MOPD (Multi-Teacher On-Policy Distillation), OPSD (On-Policy Self-Distillation), DistilBERT, soft labels, temperature scaling, KL divergence in distillation, or any RL–distillation hybrid method. Also trigger when asked about compressing large LLMs into smaller ones, transferring capabilities from frontier models, exposure bias in autoregressive models fixed via student rollouts, or synthetic data pipelines for model training.
Best use case
knowledge-distillation is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Expert-level knowledge about AI/ML knowledge distillation — a training paradigm where a student model learns from a teacher model. Use this skill whenever the user asks about knowledge distillation, teacher-student learning, model compression via distillation, soft targets, KD loss, on-policy distillation, off-policy distillation, self-distillation, multi-teacher distillation, sequence-level KD, GKD (Generalized Knowledge Distillation), OPD (On-Policy Distillation), MOPD (Multi-Teacher On-Policy Distillation), OPSD (On-Policy Self-Distillation), DistilBERT, soft labels, temperature scaling, KL divergence in distillation, or any RL–distillation hybrid method. Also trigger when asked about compressing large LLMs into smaller ones, transferring capabilities from frontier models, exposure bias in autoregressive models fixed via student rollouts, or synthetic data pipelines for model training.
Teams using knowledge-distillation should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/llm-distillation/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How knowledge-distillation Compares
| Feature / Agent | knowledge-distillation | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Expert-level knowledge about AI/ML knowledge distillation — a training paradigm where a student model learns from a teacher model. Use this skill whenever the user asks about knowledge distillation, teacher-student learning, model compression via distillation, soft targets, KD loss, on-policy distillation, off-policy distillation, self-distillation, multi-teacher distillation, sequence-level KD, GKD (Generalized Knowledge Distillation), OPD (On-Policy Distillation), MOPD (Multi-Teacher On-Policy Distillation), OPSD (On-Policy Self-Distillation), DistilBERT, soft labels, temperature scaling, KL divergence in distillation, or any RL–distillation hybrid method. Also trigger when asked about compressing large LLMs into smaller ones, transferring capabilities from frontier models, exposure bias in autoregressive models fixed via student rollouts, or synthetic data pipelines for model training.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Knowledge Distillation — Expert Reference
## What is Distillation?
Distillation is a training paradigm where a **student** model is optimized to reproduce behavior from a **teacher** model — typically to get a model that is cheaper, faster, smaller, or more specialized.
**Core token-level objective:**
$$\mathcal{L}_{KD}(\theta) = \mathbb{E}_{(x,y)}\left[D\left(p_T(\cdot \mid x, y_{<t}) \,\Vert\, p_S^\theta(\cdot \mid x, y_{<t})\right)\right]$$
where $D$ is a divergence (forward KL, reverse KL, JSD, or hybrid).
---
## Taxonomy Overview
Distillation is best understood along **four orthogonal axes**:
| Axis | Options | What It Determines |
|---|---|---|
| **Teacher update pattern** | Offline, Online, Semi-Online | Whether teacher is frozen, co-trained, or partially adapted |
| **Trajectory source** | Off-policy, On-policy | Whether sequences come from datasets/teachers or from the student |
| **Target type** | Hard, Soft, Feature, Preference, Reward-like | Type of supervision signal |
| **Teacher identity** | External, Self, Multi-teacher, Peer ensemble | Where the teacher signal comes from |
---
## Reference Files
For deep dives, read the appropriate reference:
- **`references/foundations.md`** — Temperature scaling, divergences, token-level distillation, teacher-student formulation, implementation notes
- **`references/offline-online.md`** — Offline distillation, online distillation (Deep Mutual Learning), semi-online hybrids
- **`references/off-policy.md`** — Off-policy distillation, sequence-level KD, logit distillation, synthetic data pipelines
- **`references/on-policy.md`** — GKD, OPD, REOPOLD, ExOPD, RL–distillation hybrids (SDPO, RLSD, SRPO, OpenClaw-RL), failure modes
- **`references/self-distillation.md`** — Self-distillation forms, OPSD, RL via self-distillation, hindsight alignment, agentic SD
- **`references/multi-teacher.md`** — MOPD, see-saw problem, teacher routing, Nemotron-Cascade 2
- **`references/decision-guide.md`** — When to use each method, comparison tables, practical progressions
---
## Quick Method Lookup
### Off-Policy Distillation
- Student trains on **fixed external trajectories** (teacher-generated, human-labeled, or synthetic)
- Simple, stable, scalable; canonical starting point
- Weakness: train–inference mismatch (exposure bias)
- Key papers: Hinton et al. 2015, Kim & Rush 2016 (Seq-KD), Sanh et al. 2019 (DistilBERT)
### On-Policy Distillation (OPD)
- Student **generates its own rollouts**; teacher evaluates those exact trajectories
- Mitigates exposure bias; dense token-level feedback over student-visited states
- More compute-intensive but better for long-horizon reasoning
- Key papers: Agarwal et al. 2024 (GKD), Ko et al. 2026 (REOPOLD), Yang et al. 2026 (ExOPD)
### Self-Distillation (SD)
- **No separate external teacher** — teacher signal derived from same model (earlier checkpoint, privileged context, ensemble view)
- Modern forms use contextual asymmetry: student sees only the problem; teacher sees verified solution
- Key papers: Zhao et al. 2026 (OPSD), Hübotter et al. 2026 (RLSD), Yang et al. 2026 (RLSD-RLVR)
### Multi-Teacher Distillation (MOPD)
- Student learns from **multiple specialist teachers** simultaneously
- Solves the "see-saw problem" — gaining in one domain without regressing in others
- Key papers: MOPD article (yumo.dev), Yang et al. 2026 (Nemotron-Cascade 2)
### Online Distillation
- **Teacher co-evolves** with student during training (peers teach each other)
- Adaptive supervision; no single superior teacher required
- Key papers: Zhang et al. 2017 (Deep Mutual Learning), Li et al. 2022 (Shadow KD)
---
## Divergence Quick Reference
| Divergence | Formula | Behavior | Best Used When |
|---|---|---|---|
| **Forward KL** | $D_{KL}(p_T \| p_S)$ | Mean-seeking; covers all teacher modes | Off-policy, classical KD |
| **Reverse KL** | $D_{KL}(p_S \| p_T)$ | Mode-seeking; penalizes unlikely student tokens | On-policy (student rollouts) |
| **JSD** | $\beta D_{KL}(p_T\|m) + (1-\beta)D_{KL}(p_S\|m)$ | Symmetric, bounded, stable | Stability-critical settings |
**RL Interpretation of Reverse KL (per-token advantage):**
$$A_t = \log p_T(y_t \mid x, y_{<t}) - \log p_S(y_t \mid x, y_{<t})$$
Positive = teacher prefers this token; Negative = teacher rates it worse than student.
---
## Common Training Progressions
**Standard Modern LLM Pipeline:**
1. **Off-Policy SFT** — Train on teacher-generated synthetic data (broad capability acquisition)
2. **Reinforcement Learning** — RLHF or RLVR for alignment/reasoning (sparse rewards)
3. **On-Policy Distillation** — Dense token-level feedback over student rollouts (capability consolidation)
**Multi-Domain Post-Training:**
1. Parallel RL training across domains → specialist teacher checkpoints
2. MOPD to merge specialists into one student without see-saw regression
3. Optional: OPSD / hindsight alignment for further self-improvement
---
## Key RL–Distillation Hybrids (2026)
| Paper | Core Idea |
|---|---|
| **GKD** (Agarwal 2024) | Unifies off/on-policy via λ mixture; reverse KL on student rollouts |
| **SDPO** (Hübotter 2026) | Converts textual feedback into dense self-distillation signal (RLRF) |
| **ExOPD** (Yang 2026) | OPD + reward extrapolation → student can exceed teacher |
| **REOPOLD** (Ko 2026) | Relaxed OPD; clips over-imitation; log-ratio as token rewards |
| **RLSD** (Yang 2026) | RLVR sets direction; self-distillation sets magnitude |
| **SRPO** (Li 2026) | Routes correct→GRPO, incorrect→self-distillation correction |
| **OpenClaw-RL** (Wang 2026) | Agentic hindsight OPD; tool outputs → dense supervision |
| **OPSD** (Zhao 2026) | Same model as teacher+student; teacher sees verified solution |
| **MOPD** (Xu 2026) | Multiple specialist teachers score same student rollout |
---
## OPD Failure Modes & Fixes
Three critical failure patterns (read `references/on-policy.md` for full detail):
1. **Token Overlap Failure** (Li et al. 2026) — Teacher and student thinking patterns must be compatible; use off-policy cold start before OPD
2. **Length Inflation / Repetition Collapse** (Luo et al. 2026 / StableOPD) — Add reference-based divergence constraint; mix on-policy with clean reference rollouts
3. **Sampled-Token Bias** (Fu et al. 2026) — Replace single-token supervision with teacher top-K local support matching
---
## Chess Analogy (Intuition)
- **Off-policy distillation** = watching grandmaster games → learn strong moves but only in expert positions
- **Reinforcement learning** = play games, get win/loss at the end → on-policy but sparse
- **On-policy distillation** = chess engine evaluates every move in *your own* games → dense feedback on self-generated states
This is the clearest intuition for why OPD outperforms off-policy KD on long-horizon reasoning tasks.Related Skills
voice-inference-optimization
语音推理优化参考技巧库。当用户提问与语音推理、语音 AI 性能、实时语音系统延迟、ASR/TTS 优化相关时触发。包含 RTF、流式 pipeline、VAD、量化、模型选型等实战技巧。即使用户只是问"怎么让语音更快"、"TTS 延迟太高怎么办"、"ASR 流式怎么做"也应触发。
simd-optimization
SIMD (Single Instruction Multiple Data) 优化技巧知识库,蒸馏自 Daniel Lemire 博客(lemire.me/blog) 的数百篇性能工程文章与研究论文。覆盖 x86 (SSE/AVX2/AVX-512) 和 ARM (NEON/SVE2) 的实战优化 模式、代码范例与性能直觉。当用户提问涉及 SIMD 向量化、性能优化、数据并行、字节解析、 JSON/文本/UTF-8/base64 加速、位图操作、整数压缩、prefix sum、字符串扫描、 类型转换加速时触发。也适用于"为什么我的循环慢"、"如何用 intrinsic 优化"、"AVX vs NEON" 等问题。只要涉及批量数据处理性能就应优先查阅本 skill。
nsight-compute
使用 Nsight Compute 对 CUDA kernel 进行性能分析和优化的完整指南。 当用户提到 CUDA 性能分析、kernel 调优、ncu 命令、profiler 数据解读、 瓶颈诊断、SOL 指标、占用率分析、DRAM Throughput、L1/L2 Cache Throughput、 Compute Throughput、Roofline 图、Warp Stall、Memory Chart、Section Sets、 Scheduler Statistics、Warp State、Branch Divergence、Register Spilling 等话题时, 主动使用此 skill。也适用于用户粘贴 ncu 输出数据需要解读的场景。 资料来源:NVIDIA 官方文档 2026.1、Kernel Profiling Guide、NERSC Roofline 文档。
gpu-glossary
GPU 术语速查手册,基于 Modal GPU Glossary(CC BY 4.0)。当用户提问涉及 GPU 硬件结构、CUDA 编程模型、GPU 性能分析、内核优化、内存带宽、屋顶线模型、 SM 占用率、Warp 分化、算术强度等概念时触发。也适用于"为什么我的 kernel 慢"、 "compute-bound 和 memory-bound 怎么区分"等实际调优问题。
complexity-optimizer
Analyze a software codebase for algorithmic complexity and performance hotspots, then propose or implement safe optimizations without breaking behavior. Use when Codex is asked to scan many files, find inefficient loops, nested iteration, repeated scans, costly rendering/recomputation, N+1 queries, avoidable O(n^2) or O(n) operations, or reduce complexity such as O(n^2) to O(n log n) / O(n), while preserving tests, APIs, outputs, and maintainability.
teach
Teach the user a new skill or concept, within this workspace.
refactor
Find deepening opportunities in a codebase, informed by the domain language in CONTEXT.md and the decisions in docs/adr/. Use when the user wants to improve architecture, find refactoring opportunities, consolidate tightly-coupled modules, or make a codebase more testable and AI-navigable.
xray
深度分析统一入口。处理概念、英文单词、URL 页面、研究论文、项目/创业透视审查。用户要求分析论文、解释单词、拆网页、评估项目或"帮我想想这个"时使用。
feedly-daily
每日自动化阅读 Feedly Today 文章、标记已读、生成中文总结报告。当用户说"打开 Feedly 看新闻"、"帮我看今天的 Feedly"、"获取 Feedly 文章"、"标记 Feedly 已读"、"生成今日阅读报告"、"总结今天的技术新闻"时使用此 skill。
implementing-zero-knowledge-proof-for-authentication
Zero-Knowledge Proofs (ZKPs) allow a prover to demonstrate knowledge of a secret (such as a password or private key) without revealing the secret itself. This skill implements the Schnorr identificati
cfn-knowledge-base
MUST BE USED after every CFN Loop execution to capture successful patterns. Query before repeating any task type to retrieve prior learnings and avoid re-solving solved problems. Organizational learning from CFN Loop execution - workflow codification and playbooks.
domain-knowledge
Manages the user's personal domain knowledge registry — company intelligence seeded per sector that the India Proxy Agent uses before searching. Activates when user runs /curiosity-stack:knowledge, says "manage my domain knowledge", "add company to my knowledge", or clicks the "missed company" add form after an India Proxy Agent run. Also activates after any India Proxy Agent output to surface the inline add prompt.