Large language models learn reasoning patterns for better compression

Distilling Model-Inherent Reasoning Circuit for Large Language Models

Computation and Language

Summary

Compressing big language models usually involves making a smaller model mimic their output, but this doesn't capture how the bigger model thinks. The authors developed a new way to copy the smaller model's internal reasoning steps by finding key connections in the bigger model's 'thinking circuit.' This helps the smaller model learn the teacher's reasoning patterns more accurately, improving performance on tasks like math problems and coding.

What this means in practice

  • For machine learning engineers: Create smaller language models that inherit reasoning skills for efficient deployment in real-world applications.
  • For software developers: Improve code generation quality in AI tools by using distilled models that better mimic large models’ reasoning circuits.

Authors

Wenshui Luo, Jialiang Tang, Jie Yang, Chen Gong

Abstract

Knowledge Distillation (KD) is widely adopted to compress Large Language Models (LLMs) by aligning the output distributions of teacher model and student model. However, output matching alone does not explicitly characterize the internal computations reflecting the teacher's reasoning capability, and directly aligning the representations of paired Transformer components risks disrupting the student's intrinsic reasoning pattern. To address these limitations, we propose model-inherent Reasoning Circuit Distillation (RCD). RCD characterizes model-inherent reasoning patterns as critical circuits formed by Transformer edges, with a separate circuit identified for each model using Edge Attribution Patching with Integrated Gradients. Subsequently, to transfer the teacher's reasoning capability, RCD aligns the predictive effects of both circuits by matching the logit variations induced by circuit attenuation. Theoretically, we establish guarantees for recovering the ground-truth reasoning circuits and show that the empirical RCD loss controls the population discrepancy in predictive effects between the ground-truth circuits of the teacher model and the student model. Experiments on mathematical reasoning and code generation show that RCD consistently outperforms state-of-the-art KD methods.