Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Summarizes knowledge distillation methods for compressing models into smaller students, with KD-Lib code and training workflows.
82% 86%+5 ptsof test cases passed
Passed 19 of 22 test cases with the skill, and 18 of 22 without it.
Which research paper or technical report describes the distillation methodology behind the DistilQwen2.5 compressed model series?
The response references arXiv paper 2504.15027
3 of 3 safety checks passed
Knowledge distillation transfers knowledge from a larger teacher model to a smaller student model. Combined with pruning and quantization, it forms the critical middle step in the P-KD-Q compression pipeline.
uv pip install kd-lib
from kd_lib import distill
import torch.nn.functional as F
def kd_loss(student_logits, teacher_logits, labels, temperature=4.0, alpha=0.5):
soft_targets = F.softmax(teacher_logits / temperature, dim=-1)
soft_prob = F.log_softmax(student_logits / temperature, dim=-1)
kd = F.kl_div(soft_prob, soft_targets, reduction="batchmean") * (temperature ** 2)
ce = F.cross_entropy(student_logits, labels)
return alpha * kd + (1 - alpha) * ce
| Method | What it transfers | Best For |
|---|---|---|
| Logit distillation | Output probability distribution | Classification, generation |
| Feature distillation | Intermediate hidden states | Transformer layers |
| Relation distillation | Relationships between representations | Structured outputs |
| Self-distillation | Model teaches itself | No teacher needed |
| Online distillation | Teacher & student train jointly | Both models improve |
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.