Abstract
Large language models (LLMs) have shown significant promise in question-answering (QA) tasks, particularly in retrieval-augmented generation (RAG) scenarios and long-context applications. However, their performance is hindered by noisy reference documents, which often distract from essential information. Despite fine-tuning efforts, Transformer-based architectures struggle to prioritize relevant content. This is evidenced by their tendency to allocate disproportionate attention to irrelevant or later-positioned documents. Recent work proposes the differential attention mechanism to address this issue, but this mechanism is limited by an unsuitable common-mode rejection ratio (CMRR) and high computational costs. Inspired by the operational amplifier (OpAmp), we propose the OpAmp adaptation to address these challenges, which is implemented with adapters efficiently. By integrating the adapter into pre-trained Transformer blocks, our approach enhances focus on the golden context without costly training from scratch. Empirical evaluations on noisy-context benchmarks reveal that our Qwen2.5-OpAmp-72B model, trained with our OpAmp adaptation, surpasses the performance of state-of-the-art LLMs, including DeepSeek-V3 and GPT-4o.
1. Introduction
In the era of Retrieval-Augmented Generation (RAG) and massive context windows, LLMs are increasingly required to identify a "needle in a haystack." However, as context length grows, so does the "noise"—irrelevant documents that distract the model, leading to performance degradation or hallucinations. This is often referred to as the "lost in the middle" phenomenon, where models allocate disproportionate attention to irrelevant text or documents positioned at the end of a sequence.
Previous attempts to mitigate this, such as differential attention, required training models from scratch, which is computationally prohibitive. Furthermore, these methods often focused purely on the difference between signals, failing to account for the "common-mode" noise inherent in language processing. The challenge lies in finding an efficient way to "denoise" attention without rebuilding the model from the ground up.
2. Methodology: OpAmp Adaptation
We take inspiration from the Operational Amplifier (OpAmp), which in analog electronics amplifies the difference between two inputs (differential gain) while rejecting signals common to both (common-mode rejection).
2.1 The OpAmp Analogy
We reformulate the standard attention mechanism by introducing two sets of learned adapters that produce two distinct attention matrices, $M^+$ and $M^-$. These are combined using a formula that mimics an OpAmp circuit: $$\bar{M} = A_d(M^+ - M^-) + \frac{A_c}{2}(M^+ + M^-)$$ Where $A_d$ represents Differential Gain (focusing on unique, relevant features), $A_c$ represents Common-mode Gain (handling shared background noise), and the Common-Mode Rejection Ratio (CMRR, denoted as $\mathcal{K}$) balances these components.
2.2 Parameter-Efficient Implementation
Instead of full fine-tuning, we utilize Parameter-Efficient Fine-Tuning (PEFT). By integrating these OpAmp-inspired adapters into pre-trained Transformer blocks, we "teach" the model to denoise its attention efficiently. We employ Zero Initialization to ensure that at the start of training, the model behaves identically to the original Transformer before gradually learning to prioritize relevant content.
3. Experimental Setup
We curated a Noisy Context Fine-Tuning (NCFT) dataset, combining LongCite-45k for long-context citations, Neural-Bridge-RAG for retrieval scenarios, and Tulu3-SFT-Mix for general instruction following. Evaluation was conducted across a rigorous battery of benchmarks, including LongBench (LooGLE, NarrativeQA), Multi-Hop QA (HotpotQA, MuSiQue), and Noisy-RAG (CoQA, QuAC), specifically testing the ability to ignore distractor documents.
4. Results and Discussion
Empirical results demonstrate that "zooming in" on relevant context significantly improves performance across various tasks.
4.1 Benchmark Performance
The Qwen2.5-OpAmp-72B model achieved state-of-the-art results:
- LooGLE: Achieved an Exact Match (EM) score of 66.3%, surpassing GPT-4o (62.7%) and DeepSeek-V3 (63.4%).
- CoQA: Reached 92.4%, a significant lead over DeepSeek-V3 (88.4%).
- Model Scaling: Smaller models also benefited; a Llama-3.1-8B model with OpAmp adaptation saw a 3.0% average performance boost across noisy benchmarks compared to standard fine-tuning.
4.2 The "Goldilocks" Denoising Ratio
While an infinite CMRR is ideal in electronics, we found that for LLMs, a moderate CMRR ($\mathcal{K}=10$) is optimal. Excessive denoising causes the model to lose broader context, while insufficient denoising leaves it susceptible to distraction. Furthermore, improved attention denoising acts as a defense against hallucinations by forcing the model to focus on the "golden" document.
5. Conclusion
OpAmp adaptation provides a hardware-inspired, parameter-efficient method for enhancing LLM focus in noisy contexts. While the dual-adapter approach introduces a marginal parameter overhead and minor inference latency, the gains in accuracy and hallucination reduction are substantial. Future work will focus on optimizing these adapters to reduce latency and exploring the application of OpAmp logic to other Transformer components.
Summary updated