Abstract
Fine-tuning significantly improves the performance of Large Language Models (LLMs), yet its underlying mechanisms remain poorly understood. This paper aims to provide an in-depth interpretation of the fine-tuning process through circuit analysis, a popular tool in Mechanistic Interpretability (MI). We develop a set of mathematical tasks where fine-tuning yields substantial performance gains, closer to practical settings. By identifying circuits at various checkpoints, we examine the interplay between circuit analysis, fine-tuning methods, and task complexities. We find that while circuits maintain high node similarity before and after fine-tuning, their edges undergo significant changes. Based on these observations, we develop CircuitLoRA, a circuit-aware Low-Rank Adaptation method that assigns ranks based on edge changes. Experimental results demonstrate that CircuitLoRA achieves an average performance improvement of 2.46% over standard LoRA. Furthermore, we explore how combining circuits from subtasks can enhance fine-tuning in compositional tasks.
Introduction
Fine-tuning is the standard paradigm for adapting Large Language Models (LLMs) to specific domains, yet the process is often treated as a "black box." While performance gains are easily measured, the internal structural changes that support new skills remain largely unknown. Previous research in Mechanistic Interpretability (MI) has often focused on tasks where models were already proficient. This study addresses a more challenging scenario: how LLMs evolve when fine-tuned on tasks they initially fail at, specifically mathematical reasoning—a known weak spot for many pre-trained models.
Methodology
The authors employ Circuit Analysis to treat the LLM as a computational graph where nodes are attention heads or MLPs, and edges represent the flow of information.
- Circuit Discovery (EAP-IG): Using Edge Attribution Patching with Integrated Gradients to identify specific edges and nodes responsible for a model's output.
- CircuitLoRA: A modified Low-Rank Adaptation (LoRA) that identifies "Critical Layers" (those with the most significant circuit changes) and assigns them higher ranks.
- Union Circuits: Testing if the circuit for a compositional task can be approximated by merging the circuits of its subtasks.
The study focuses on five challenging mathematical tasks: Addition/Subtraction, Multiplication/Division, Sequence recognition, Least Common Multiple (LCM), and Function Evaluation. Experiments were conducted using Pythia-1.4B, GPT-Neo-2.7B, and OPT-6.7B models.
Key Insights: The Re-wiring of LLMs
A central finding is that fine-tuning primarily modifies the connections (edges) between components rather than the components (nodes) themselves. Fine-tuning is less about finding new tools and more about building new pipelines between existing ones. Most of this structural "re-wiring" happens in the middle and later layers, while shallow layers remain remarkably stable. As accuracy improves during training, the internal circuit stabilizes, with the number of modifications decreasing as the model "locks in" the new mechanism.
Experimental Results
CircuitLoRA achieved an average performance improvement of 2.46% over standard LoRA across all tasks while maintaining a similar parameter budget. The identified circuits were highly "faithful," capturing over 80-90% of the full model's performance.
In compositional tasks, using a "Union Circuit" to identify critical layers resulted in 65.50% accuracy, nearly matching the performance of a circuit specifically discovered for that complex task (67.20%). This suggests that LLMs learn mathematical operations in a modular way.
Conclusion
This research provides a structural perspective on fine-tuning, revealing that it is a process of internal re-wiring. By leveraging circuit analysis, we can develop more efficient, "circuit-aware" training strategies like CircuitLoRA. Future work will explore if these mechanisms hold true for more abstract reasoning tasks beyond the structured domain of mathematics.
Summary updated