Skip to content

ikun-llm/ikun-Distill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

ikun-Distill

师傅带徒弟
Level 3 | 进阶篇


大模型是师傅,小模型是练习生。练习两年半,不如师傅带一带。

你将学到

  • 知识蒸馏 (Knowledge Distillation) 原理
  • 白盒蒸馏 vs 黑盒蒸馏
  • KL 散度损失函数
  • Temperature Scaling 的作用
  • 蒸馏 Loss = α × CE Loss + (1-α) × KL Loss
  • 蒸馏 vs 直接训练的效果对比

核心代码

基于 MiniMindtrainer/train_distillation.py

cd trainer && python train_distillation.py \
    --from_weight full_sft --hidden_size 512 \
    --temperature 2.0 --alpha 0.5

蒸馏直觉

直接训练:  小模型看"标准答案"学习 → 只学到 hard label
知识蒸馏:  小模型看"师傅的思考过程"学习 → 学到 soft distribution

例子:
标准答案: "鸡" 概率=1, 其他=0  (hard)
师傅输出: "鸡"=0.7, "你"=0.15, "太"=0.1, ... (soft) ← 包含更多信息!

Temperature ↑ → 概率分布更平滑 → 小模型能学到更多"暗知识"

系列导航

Level Repo 学什么
1 ikun-tokenizer 分词器原理
1 ikun-pretrain 从零预训练
1 ikun-2.5B SFT + LoRA 微调
2 ikun-DPO 偏好对齐
2 ikun-GRPO 强化学习
2 ikun-Reason 推理模型
3 ikun-MoE 混合专家
3 ikun-Distill ← 你在这里 知识蒸馏
3 ikun-V 多模态
4 ikun-deploy 部署

About

知识蒸馏 | Knowledge Distillation from teacher model 🎓

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors