
Knowledge Distillation
This is a solid implementation guide for compressing large language models using knowledge distillation, with working code for the main techniques. You get standard teacher-student training with temperature scaling and soft targets, plus MiniLLM's reverse KLD approach which actually works better for generative models because it's mode-covering instead of mode-seeking. The examples show real transfers like 70B to 7B LLaMA models and include response distillation for creating synthetic training data. Good coverage of the alpha hyperparameter for balancing soft and hard losses. If you're trying to deploy a cheaper model or transfer GPT-4 capabilities to something you can run locally, this gives you the core techniques with reasonable defaults.
- skills.sh installs
- 1K
- GitHub stars
- 14.4K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add orchestra-research/ai-research-skills --skill knowledge-distillation --agent claude-codeInstalls into .claude/skills of the current project.
Files
Knowledge Distillation: Compressing LLMs
When to Use This Skill
Use Knowledge Distillation when you need to:
- Compress models from 70B → 7B while retaining 90%+ performance
- Transfer capabilities from proprietary models (GPT-4) to open-source (LLaMA, Mistral)
- Reduce inference costs by deploying smaller student models
- Create specialized models by distilling domain-specific knowledge
- Improve small models using synthetic data from large teachers
Key Techniques: Temperature scaling, soft targets, reverse KLD (MiniLLM), logit distillation, response distillation
Papers: Hinton et al. 2015 (arXiv 1503.02531), MiniLLM (arXiv 2306.08543), KD Survey (arXiv 2402.13116)
Installation
# Standard transformers
pip install transformers datasets accelerate
# For training
pip install torch deepspeed wandb
# Optional: MiniLLM implementation
git clone https://github.com/microsoft/LMOps
cd LMOps/minillm
pip install -e .
Quick Start
Basic Knowledge Distillation
import torch
import torch.nn.functional as F
from transformers import AutoModelForCausalLM, AutoTokenizer, Trainer, TrainingArguments
Sponsors
Details
- Repository
- github.com/orchestra-research/ai-research-skills
- Categories
- AI & Agent Building, Data Science & ML, Debugging
- First seen
- Jun 3, 2026
More from orchestra-research/ai-research-skills
All 95- Ray Data1K
- Fine Tuning With Trl1K
- Llama Cpp1K
- Tensorboard1K
- Deepspeed1K
- Qdrant Vector Search1K
- Grpo Rl Training1K
- Optimizing Attention Flash1K
- Quantizing Models Bitsandbytes1K
- Verl Rl Training1K
- Dspy1K
- Langchain1K
- Pytorch Lightning1K
- Axolotl1K
- Hqq Quantization1K
- Sentence Transformers1K
- Clip1K
- Huggingface Tokenizers1K
- Long Context1K
- Nanogpt1K
- Pytorch Fsdp21K
- Awq Quantization1K
- Modal Serverless Gpu1K
- Moe Training1K