Knowledge Distillation for Large Language Models
Organizations: Duke University
Abstract
We propose a resource-efficient framework for compressing large language models through knowledge distillation, combined with guided chain-of-thought reinforcement learning. Using Qwen 3B as the teacher and Qwen 0.5B as the student, we apply knowledge distillation across English Dolly-15k, Spanish Dolly-15k, and code BugNet and PyTorrent datasets, with hyperparameters tuned in the English setting to optimize student performance. Across tasks, the distilled student retains a substantial portion of the teacher's capability while remaining significantly smaller: 70% to 91% in English, up to 95% in Spanish, and up to 93.5% Rouge-L in code. For coding tasks, integrating chain-of-thought prompting with Group Relative Policy Optimization using CoT-annotated Codeforces data improves reasoning coherence and solution correctness compared to knowledge distillation alone. Post-training 4-bit weight quantization further reduces memory footprint and inference latency. These results show that knowledge distillation combined with chain-of-thought guided reinforcement learning can produce compact, efficient models suitable for deployment in resource-constrained settings.
Figures & tables
| Task | Prompt | Base | SFT | KD | Teacher |
|---|---|---|---|---|---|
| English - Closed Question | What is the capital of the United Kingdom? | What is the capital of the United Kingdom? (6.6) | The capital of the United Kingdom is London. (23) | The capital of the United Kingdom is London. (20.4) | London is the capital of the United Kingdom. (27.1) |
| Spanish - Closed Question | ¿Cuál es la capital de Reino Unido? | Cuál has a lot to offer so you’ll want to check them out. (3.1) | El capital de Reino Unido es la Ópera, lo que no es el nombre del Reino Unido. (17.4) | La capital de Reino Unido es Nueva York. (19.7) | Londres es la capital de Reino Unido.(20.6) |
| Code (Qwen) pytorrent | Write a for loop from 1 to 10 | The output is then shown in the output of the second loop. (5.9) | df = Statistics. stats_interval(’interval’, ’minutes’) p = p.std() (31.2) | for j in range( np.ceil(1 - np.sqrt( 1)), 2:-np.ceil(0) + (np.pi / 2):(33.1) | for i in range(1, 10): if num >= 1: logger.error(’ (32.7) |
| Code (Qwen2.5) pytorrent | DFS in Python | - list all visited nodes using ’depth_first_search (8.7) | def search(self, start=None, path=[], visit_func = None, visit_args=(),(34.4) | def _next(x, d): x = next(x) return [x] + [y for y in next(x)[:d]] (35.5) | def DFS(D= Graph ( )): … D.add_edge(5,0) … n_d=[0] … while n_d: (37.5) |
Language Model Distillation
Language model distillation transfers a larger model’s capabilities to smaller or specialized models using outputs, probabilities, or internal representations.
See all 508 papers