Abstract
Supervised Fine-Tuning (SFT) is the standard approach for adapting Large Language Models (LLMs) to specific tasks, yet it often fails to leverage the rich learning signals present in a model's errors. During training, once a gradient update is performed, the specific context of a mistake is typically discarded. We present Transformer Copilot, a framework that introduces a "Mistake Log" to capture an LLM’s internal states and discrepancies during fine-tuning. By training a lightweight auxiliary "Copilot" model to predict and rectify these errors, the framework enhances inference performance by up to 34.5% with minimal computational overhead. Our results demonstrate that learning from past failures allows smaller model ensembles to outperform significantly larger monolithic models.
Introduction
In traditional Supervised Fine-Tuning (SFT), the model learns through backpropagation: when a prediction deviates from the ground truth, the loss function triggers a weight adjustment. However, this process lacks a "reflective" component. The model does not explicitly store the internal cognitive state—the specific hidden representations—that led to a hallucination or a logic error. Consequently, at inference time, the model often repeats the same patterns of failure.
Transformer Copilot addresses this "memory problem" by treating the fine-tuning process as a source of diagnostic data. By maintaining a Mistake Log, the system allows an auxiliary model to learn the specific "traps" the primary model (the Pilot) falls into, providing real-time corrections during generation.
The Transformer Copilot Framework
The framework consists of two primary components: the Pilot (the base LLM) and the Copilot (a smaller, auxiliary transduction network).
1. The Mistake Log
During the fine-tuning phase, the system systematically records a Mistake Log. This log is composed of three critical elements:
- Input (Question): The prompt or query provided to the model.
- Rationale (Hidden States): The internal representations generated by the Pilot’s layers during the erroneous prediction.
- Mistakes: The token-level discrepancy between the Pilot’s predicted probability distribution and the actual ground truth.
2. Copilot Architecture
The Copilot is initialized from the Pilot’s decoder to ensure architectural compatibility. Its structure varies based on the Pilot's design:
- Encoder-Decoder Models: The Copilot utilizes a modified cross-attention mechanism to monitor the Pilot’s internal hidden states.
- Decoder-only Models: The Copilot employs an alternating layer structure. Odd layers focus on intra-sequence dependencies, while even layers attend directly to the Pilot’s internal representations.
3. Joint Training and Logit Rectification
The Pilot and Copilot are trained in tandem. As the Pilot evolves, the Copilot learns to map the Pilot’s hidden states to the required corrections. At inference time, the Pilot generates its initial raw prediction scores (logits). The Copilot simultaneously generates a "rectification signal" based on the Pilot’s current state. These signals are fused using the formula:
$$\tilde{p} = \hat{p} + \lambda f^C$$
where $\hat{p}$ is the Pilot's distribution, $f^C$ is the Copilot's correction, and $\lambda$ is a scaling factor. This produces a corrected probability distribution for the next token.
Experimental Evaluation
Datasets and Models
The researchers evaluated the framework across 12 benchmarks covering:
- Commonsense Reasoning: PIQA, HellaSwag, WinoGrande, BoolQ, SIQA, and OpenbookQA.
- Arithmetic Reasoning: AQuA, GSM8K, MAWPS, and SVAMP.
- Recommendation Tasks: Amazon Beauty and LastFM.
The framework was tested using several backbone architectures, including the T5/FLAN-T5 family, LLaMA-3, and Qwen2.5.
Key Findings
- Performance Gains: Transformer Copilot consistently outperformed standard SFT. The most significant improvements were seen in arithmetic tasks, where performance increased by up to 34.5% (FLAN-T5-small).
- Parameter Efficiency: The framework allows for "over-performance" relative to model size. For instance, a Qwen2.5-7B model paired with a 3B Copilot (10B total parameters) outperformed a standalone Qwen2.5-14B model, despite having 4 billion fewer parameters.
- Theoretical Robustness: Theorem 4.1 in the study posits that the Copilot does not need to be as accurate as the Pilot to be effective. As long as the Copilot correctly identifies the direction of the Pilot's error, it provides a net benefit.
- Low Latency: Despite the dual-model architecture, the framework only adds approximately 4% to inference time. This efficiency is achieved because the Copilot consumes the Pilot's hidden states directly, avoiding redundant computations.
Discussion and Insights
The Reflection Analogy
The core philosophy of Transformer Copilot mirrors human pedagogy. A student who maintains a "mistake notebook" to review their errors before an exam typically performs better than one who simply completes exercises without reflection. The Copilot acts as this notebook, providing a specialized mechanism for the model to "remember" its past failures and avoid them in real-time.
Transferability
One of the most surprising findings was the Copilot's transferability. A Copilot trained on one Pilot model can be integrated with a different, independently trained Pilot of the same architecture. This suggests that the error patterns captured in the Mistake Log are somewhat universal to the architecture itself, rather than being strictly tied to a specific set of weights.
Limitations and Future Work
While effective, the framework's performance is inherently limited by the diversity of the Mistake Log. If the fine-tuning data is narrow, the Copilot may not encounter enough varied error patterns to generalize to out-of-distribution tasks. Future research will focus on data augmentation for the Mistake Log and the development of adaptive logging policies to prioritize the most informative errors during training.
Conclusion
Transformer Copilot represents a shift from simply training models to reach a target, to training models to understand their own failure modes. By leveraging the internal signals of the fine-tuning process, the framework provides a scalable, efficient, and highly effective method for boosting LLM performance across reasoning and mathematical tasks.
Summary updated