Introduction
Retrieval-Augmented Generation (RAG) is a powerful technique to address knowledge gaps in Large Language Models (LLMs) by pulling relevant documents from external databases. However, RAG systems often struggle when retrieved context is "noisy"—irrelevant, contradictory, or incorrect. Standard techniques like Context-Aware Decoding (CAD) use a fixed weight to amplify context, which can force models to hallucinate or ignore their own correct internal knowledge when faced with bad data. This paper proposes Adaptive Contrastive Decoding (ACD), a method that dynamically weights context based on the model's own uncertainty.
Methods: The ACD Innovation
Standard contrastive decoding relies on a fixed hyperparameter $\alpha$ to control the influence of context: $$P \propto \text{softmax}(z_{param} + \alpha(z_{context} - z_{param}))$$
ACD replaces this static weight with a dynamic, token-level weight based on Entropy ($H$). At each decoding step, the model calculates its uncertainty without context ($H(Y_t)$) and with context ($H(Y_t^c)$). The adaptive weight is then defined as: $$\alpha_{ACD} = \frac{H(Y_t)}{H(Y_t) + H(Y_t^c)}$$
This approach uses the LLM's internal state as a built-in relevance detector. If the context is helpful, uncertainty drops ($H(Y_t^c)$ is small), and $\alpha$ increases to trust the context. If the context is noisy, uncertainty remains high or increases, leading to a smaller $\alpha$ that favors the model's internal parametric knowledge.
Experimental Setup
The researchers evaluated ACD across three major open-domain Question Answering (QA) benchmarks: TriviaQA, Natural Questions (NQ), and PopQA. They also utilized NQ-swap, a dataset specifically designed to test "knowledge conflict" by providing context with intentionally swapped, incorrect answers. The method was tested on several open-weights models, including Llama 2 (7B/13B), Llama 3 (8B), and Mistral 7B.
Key Results
ACD demonstrated superior robustness, particularly in the "Known-Noisy" scenario where the model possesses the correct internal knowledge but is presented with distracting context.
As shown in the results, ACD consistently achieved the highest "All" data EM scores. For instance, on the TriviaQA noisy subset with Llama 2 7B, ACD reached an EM of 42.06, nearly doubling the 24.75 achieved by standard CAD. Furthermore, ACD showed a significantly higher correlation between the adaptive weight $\alpha$ and actual context quality compared to previous dynamic methods like MICD.
Discussion and Insights
- Dynamic vs. Static: ACD avoids the compromise of fixed weights, which usually trade off performance between gold and noisy data. By shifting weights token-by-token, it provides the "best of both worlds."
- Handling Knowledge Conflict: In NQ-swap tests, ACD proved resilient to explicit misinformation by recognizing the resulting increase in uncertainty and falling back on parametric knowledge.
- Limitations: The primary drawback is inference cost; ACD requires two forward passes per token, doubling the computational requirement. Future work is needed to assess its performance on instruction-tuned models and long-form generation tasks.
Summary updated