DDK: Distilling Domain Knowledge for Efficient Large Language Models

Jiaheng Liu, Chenchen Zhang, Jinyang Guo, Yuanxing Zhang, Haoran Que, Ken Deng, ZhiqiBai, Jie Liu, Ge Zhang, JiakaiWang, Yanan Wu, Congnan Liu, Jiamang Wang, Lin Qu, Wenbo Su, Bo Zheng

TL;DR

DDK (Distilling Domain Knowledge) is a novel framework that optimizes Large Language Model (LLM) distillation by dynamically rebalancing the training data. Instead of treating all training examples equally, DDK identifies specific domains (like math, coding, or literature) where the student model lags furthest behind its teacher and prioritizes those areas, leading to significant performance gains across diverse benchmarks.

What Problem Does This Paper Address?

Knowledge Distillation (KD) is the go-to strategy for creating "compact" models—taking the "wisdom" of a massive teacher model (like Qwen-14B) and squeezing it into a smaller student model (like Qwen-1.8B).

However, current KD methods have a critical "blind spot": they assume the student model struggles equally across all types of data. In reality, a small model might be nearly as good as its teacher at summarizing general web text but significantly worse at solving complex calculus or writing Python code. Standard distillation spends too much time on "easy" domains where the gap is already small and not enough on the "hard" domains where the student is failing. This inefficiency limits how much intelligence we can actually pack into a small model.

Methods

To address this imbalance, the authors introduce a dynamic, three-step loop to manage the distillation process:

DDK Framework Architecture
  1. Domain Discrepancy Factor ($r$): The system periodically evaluates both the teacher and student on a small validation set across different domains (e.g., ArXiv, Wikipedia, Github). It calculates a "discrepancy factor" based on the difference in Perplexity (PPL)—a measure of how "surprised" a model is by a piece of text. A higher gap means the student needs more help in that specific domain.
  2. Domain Knowledge Guided Sampling: Based on these factors, DDK adjusts the "recipe" of the training data for the next interval. Domains with larger performance gaps are sampled more frequently, forcing the student to focus on its weaknesses.
  3. Factor Smooth Updating: To prevent training instability, DDK doesn't make radical jumps in data distribution. It uses a smoothing mechanism (inspired by optimization algorithms like Adam) to transition the data mixture gradually. This ensures the model doesn't "forget" previous knowledge while pivoting to new challenges.

For the actual learning, DDK uses a "white-box" approach, minimizing the difference between the teacher’s and student’s output probabilities (logits) alongside standard cross-entropy loss.

Datasets

The researchers used a diverse mix of high-quality data to train and test DDK:

  • Training/Distillation: Primarily RedPajama, covering seven domains: CommonCrawl, C4, GitHub (The Stack), Wikipedia, Books, ArXiv, and StackExchange.
  • Domain Expansion: To boost specific skills, they added Chinese Books, Chinese CommonCrawl, and OpenWebMath.
  • Evaluation: A massive battery of benchmarks including C-Eval and MMLU (general knowledge), GSM8K (math), and HumanEval/MBPP (coding).

Key Insights and Ideas

  • The "Gap" is Variable: The performance gap between a 1.8B model and a 14B model is not a flat line. It’s a jagged landscape where domains like "Books" and "Math" often represent the deepest valleys for the student.
Perplexity across different domains
  • Data Mixture is a Bottleneck: The authors argue that the composition of the distillation dataset is just as important as the loss function used. Even advanced KD methods like MiniLLM can be held back by a sub-optimal data mix.
  • Stability over Speed: The "Factor Smooth Updating" is a critical "aha moment." Without it, the training becomes erratic. By incorporating historical mixture information, DDK keeps the optimization path stable while remaining adaptive.
  • Orthogonality: DDK is "orthogonal" to other KD techniques. This means you could theoretically combine DDK's data-sampling strategy with other researchers' novel loss functions for even better results.

Key Results

DDK consistently outperformed standard distillation and competitive baselines (like MiniLLM and TED):

  • Qwen-1.5 Series: When distilling a 14B teacher into a 1.8B student, DDK achieved an average score of 55.41% across benchmarks, significantly higher than standard KD (52.87%) and MiniLLM (52.58%).
  • LLaMA Series: Distilling LLaMA2-13B into TinyLLaMA-1.1B, DDK reached 29.32% average accuracy, compared to 26.18% for standard KD.
  • Reasoning Gains: The most dramatic improvements were seen in reasoning-heavy tasks. On the HumanEval (coding) benchmark, the DDK-distilled Qwen-1.8B model jumped from a baseline of 11.87% to 27.13%.

Limitations and Future Work

  • Hyperparameter Sensitivity: DDK introduces new parameters, such as the distillation interval ($K$) and the smoothing coefficient ($\alpha$), which require careful tuning to balance stability and adaptivity.
  • Resource Constraints: Due to GPU limits, the study focused on student models up to 4B parameters. The authors acknowledge that testing DDK on much larger scales (e.g., 70B+ teachers) is a necessary next step.
  • Vertical Distillation: While they tested on Code LLMs (StarCoder), further exploration into highly specialized "vertical" domains (medical, legal) could show even more pronounced benefits from domain-aware sampling.

Summary updated

BibTeX
@inproceedings{liu2024ddk,
  author = {Jiaheng Liu and Chenchen Zhang and Jinyang Guo and Yuanxing Zhang and Haoran Que and Ken Deng and ZhiqiBai and Jie Liu and Ge Zhang and JiakaiWang and Yanan Wu and Congnan Liu and Jiamang Wang and Lin Qu and Wenbo Su and Bo Zheng},
  title = {{DDK: Distilling Domain Knowledge for Efficient Large Language Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=xgiurUq0ss},
}
Figure