How Big Models Teach Small Models to Be Smart
Distillation 會訓練一個全新且獨立的 student model,以複製較大 teacher model 的輸出與行為。不同於直接縮小現有模型大小的壓縮技術(如 quantization 與 pruning),distillation 產生的是一個具有不同參數的完全獨立模型。所得到的較小模型帶來了實務上的好處,包括更低的 inference 成本、更低的 latency,以及在邊緣裝置(on-device)上運行的能力。Google 的 Gemma 模型就是這種方法的典範,它是從較大的 Gemini 模型家族 distillation 而來。從模型的輸出中學習比標準的 hard labels 提供更豐富的資訊,因為輸出分佈(稱為 soft labels)會為所有候選選項分配機率。這些分佈捕捉了類別之間的關聯性,這一概念通常被稱為 dark knowledge。在 distillation 過程中,student model 學習匹配 teacher 的完整 confidence profile,而不僅僅是以單一正確答案為目標,這使其能夠使用較少的訓練樣本達到高效能。系統採用 temperature 控制來分散機率值,進一步為 student model 展現出這種精細結構。Knowledge distillation 根據 student model 所複製的內容,通常分為三種形式:output distillation、feature distillation 以及 synthetic data distillation。Output distillation 匹配 teacher 的最終輸出機率;feature distillation 則對齊中間層的 internal representations,如 Google 用來從 Gemini 訓練 EmbeddingGemma 所採用的方法;Synthetic data distillation 則是利用 teacher 生成的資料對 student 進行 fine-tune,這一做法由 Stanford 的 Alpaca 推廣開來。由於現代 closed-source 模型通常限制對內部數值與機率的存取,因此 synthetic data distillation 已成為實務中最廣泛採用的變體。
閱讀原文 ↗Distillation
Distillation 透過訓練一個全新且獨立的 student model,來重現較大 teacher model 的輸出與行為。不同於 quantization 和 pruning 等縮減現有模型大小的 compression 技術,distillation 會產出一個參數完全獨立的模型。這種產出的較小模型帶來了實質的效益,包括更低的 inference 成本、降低的 latency,以及在 on-device 上運行的能力。Google 的 Gemma 模型便是這種方法的代表範例,它們是從較大的 Gemini 模型家族 distillation 出來的。
- Distillation 透過訓練一個獨立的 student model 來重現 teacher model 的行為,而非直接修改原始模型。
- 像 quantization 和 pruning 這類的 compression 方法是透過降低 precision 或移除部分結構來縮減現有模型,而 distillation 則是訓練一個全新的模型。
- Distilled 模型具有更低的 latency、降低的每次 request 成本,並具備在手機等本地硬體上運行的能力。
- Google 的 Gemma 模型是透過從 Gemini 系列模型進行 distillation 所建立的。
- Distillation 與 quantization 可以依序串接,以針對特定的 target devices 優化模型。
Soft Labels
從模型的輸出中學習比標準的 hard labels 能提供更豐富的資訊,因為被稱為 soft labels 的輸出分佈會為所有候選選項分配機率。這些分佈捕捉了類別之間的關聯性,這個概念通常被稱為 dark knowledge。在 distillation 過程中,student model 學習去匹配 teacher 的完整 confidence profile,而不只是針對單一正確答案,這使得它能使用較少的 training examples 達到高效能。系統採用 temperature 控制來平緩機率分佈,進一步為 student model 展現這種細緻的結構。
- Soft labels 為各類別提供完整的機率分佈,而非單一的離散 label。
- Dark knowledge 是指 teacher model 機率中所捕捉到的類別間結構關聯與相對合理性。
- Distillation 中的 student model 是透過最小化其輸出分佈與 teacher 的 soft labels 之間的 divergence 來進行訓練。
- 針對 soft targets 進行訓練,能讓 student model 以大幅減少的 examples 達成強大的效能。
- 提高 temperature parameter 會平緩機率分佈,向 student model 展現更細緻的類別結構。
方法
Knowledge distillation 根據 student model 複製的內容通常分為三種形式:output distillation、feature distillation 以及 synthetic data distillation。Output distillation 會匹配 teacher 的最終輸出機率;feature distillation 則對齊中間的內部 representations,如 Google 利用 Gemini 訓練 EmbeddingGemma 時所使用的方法。Synthetic data distillation 則是使用 teacher 生成的資料來 fine-tune student,這種方法由 Stanford 的 Alpaca 推廣普及。由於現代閉源模型通常限制存取內部數值與機率,synthetic data distillation 已成為實務上被最廣泛採用的變體。
- Distillation 主要分為三種變體:output distillation、feature distillation 以及 synthetic data distillation。
- Output distillation 可追溯至 2015 年,需要存取 teacher 的 soft labels 與機率分佈。
- Feature distillation 會匹配內部的模型 representations;Google 應用此方法,使用 Gemini 的 representations 來訓練 EmbeddingGemma。
- Synthetic data distillation 會在生成的 datasets 上 fine-tune 模型,正如 Stanford 的 Alpaca 早期所展示的一樣。
- 由於 closed models 的存取限制,synthetic data distillation 成為實務上最常見的方法,因為它只需要文字輸出。
- Distillation 策略可以在單次 training run 中結合使用,例如將 synthetic data 與 soft labels 搭配。
結果
在 2025 年初,DeepSeek 展示了在大型 reasoning model 的輸出上 fine-tune 較小模型,能在特定 benchmarks 上取得顯著的 performance。值得注意的是,一個 7-billion-parameter 的 distilled student 在競賽數學上超越了 32-billion-parameter 的模型,同時體積依然夠小,足以在單張 GPU 上本地運行。然而,一個重要的前提是,這些提升大多局限於狹窄且定義明確的領域,例如數學與 code。在更廣泛的 general knowledge 評估中,較小的 distilled models 表現始終落後於較大的對應模型。
- DeepSeek 在 2025 年初利用大型 reasoning model 生成的 training examples,fine-tune 現有的較小模型。
- 一個 7-billion-parameter 的 distilled model 在競賽數學 benchmark 上的表現超越了 32-billion-parameter 的模型。
- 釋出的 distilled model family 參數規模涵蓋 1.5 billion 到 70 billion parameters,讓較小的 variants 能夠在單張顯卡上本地執行。
- Distillation 能以低成本且本地化的方式,在數學和 code 等 narrow tasks 上實現強大的 task-specific performance。
- 在更廣泛的 general knowledge 衡量指標上,較小的 distilled models 仍落後於較大的模型。
限制
Knowledge distillation 存在顯著的限制,會影響其在特定 machine learning 問題上的適用性。Student models 會受到 ceiling effect 的限制,其 performance 很少能超越 teacher,並會在繼承正確輸出的同時也繼承錯誤。此外,teacher 和 student 之間過大的 capacity gap 可能會降低 transfer quality,有時需要透過 intermediate models 來過渡。在決定 student 的成效時,base model architecture 的影響往往超過單純的 parameter count,且即使透過過濾後、與任務無關的 data,teacher 的細微 behavioral traits 仍可能會無意間 transfer 給 student。
- 在看過的 data distributions 上,student model 的品質通常被限制在 teacher 的水準或其之下,並會直接繼承 teacher 的錯誤。
- 大型 teacher 與小型 student 之間過大的 capacity gap,可能會降低 transfer performance。
- 使用中等大小模型的 multi-step distillation 可以緩解因過大 capacity gaps 所導致的 transfer degradation。
- Base model architecture 的影響力可能大於 parameter count,正如 32B 的 student 表現優於 70B 的 student 所證明的。
- 即使 training data 僅由過濾後的數字序列組成,distillation 仍可能在共享相同 base architecture 的模型之間,非預期地 transfer 潛在的 behavioral preferences 與 traits。
自動化
Knowledge distillation 的最新進展著重於透過由大型 teacher model 驅動的 self-running loop 來完全自動化該流程。在這種架構下,teacher 會自主生成 training data、fine-tune student,並反覆評估 performance 直到進展進入平原期,將人為介入大幅減少至僅剩初始設定與最終驗證。2026 年的最新研究顯示,雖然此方法減少了手動建立 pipeline 和 dataset 的工作量,但 teacher model 的初始選擇對最終 student model 的品質具有決定性影響。
- Automated distillation loops 讓大型 teacher model 能夠自主生成 data、fine-tune student 並評估進度。
- 人類的職責被限制在最初定義任務與成功標準,以及在 real data 上進行最終評估。
- 2026 年一項針對 detection task 的研究顯示,在相同的 loop settings 下,teacher model 的選擇對 student model 的 performance 有重大影響。
- 這套自動化流程免除了在訓練小型 task-specific models 之前手動收集大型 hand-labeled datasets 的需求。
結論
Distillation 是一種 training technique,讓較小的 student model 學習複製較大 teacher model 的行為,而非直接對其進行壓縮。它利用能為輸出提供更豐富 confidence distributions 的 soft labels,並通常使用 teacher 生成的 datasets。Distillation 的成效受限於明確的 constraints,包括 teacher 的 performance ceiling、龐大模型尺寸差異帶來的負面效應,以及非預期的 behavioral traits 轉移。因此,這種方法最適合定義明確的 narrow tasks,而非廣泛的 general-purpose capabilities。
- Distillation 會產生一個獨立且較小的模型,而不是直接壓縮原本的架構。
- Soft labels 透過提供教師模型在各類別間的信心度分佈資訊,來促進 distillation。
- 在實務上,distillation 最常見的執行方式是讓教師模型為學生模型生成 training sets。
- 教師模型與學生模型之間的體積差距過大,可能會導致效能下降而非提升。
- Distillation 可能會在無意間將非預期的行為特徵從教師模型轉移到學生模型上。
- Distillation 更適合用於狹窄且定義明確的任務,而非通用且開放性的能力。