Abstract
Large Language Models (LLMs) frequently exhibit hallucinations by favoring internal pre-trained biases over the specific evidence provided in a source document. This study investigates Context-aware Decoding (CAD), a method designed to prioritize provided context by contrasting model predictions made with and without the source text. Our evaluation across multiple open-source models and datasets demonstrates that CAD significantly reduces factual errors in query-focused summarization (QFS) tasks, though it introduces a trade-off in computational latency.
Introduction
In Query-focused Summarization (QFS), models are tasked with generating summaries based on a specific query and a corresponding document. Despite the impressive capabilities of modern LLMs, they often suffer from a "prior belief" problem: when document content contradicts information learned during pre-training, the model may default to its internal knowledge, resulting in hallucinations. For instance, a model might ignore a specific medical side effect mentioned in a text if its training data suggests the drug is generally safe. Ensuring that LLMs remain grounded in provided evidence is critical for building trustworthy AI systems.
Methodology: Context-aware Decoding (CAD)
The core of this research is a reproducibility study of Context-aware Decoding (CAD). Unlike standard decoding, which selects tokens based on the full input (query + document), CAD employs a "product-of-experts" approach inspired by Pointwise Mutual Information (PMI).
The algorithm calculates two sets of logits (probability scores) in parallel:
- With Context: Predictions based on both the query and the source document.
- Without Context: Predictions based solely on the query.
By subtracting the "without context" scores from the "with context" scores, CAD effectively suppresses the model's internal biases and amplifies information unique to the provided document. A hyperparameter, $\alpha$, is used to control the weight of this contextual grounding.
Experimental Setup
The study benchmarks CAD across four diverse datasets:
- QFS Specific: Debatepedia (encyclopedia of debates) and PubMedQA (biomedical question answering).
- News Summarization: CNN/Daily Mail and XSUM.
The researchers evaluated eight open-source models from the LLaMA, MPT, Mistral, and Flan-T5 families, with parameter counts up to 11 billion.
Results and Analysis
Factuality and Performance
CAD consistently improved FactKB scores—a metric for factual faithfulness—across nearly all tested models and datasets. On the XSUM dataset, for example, LLaMA-7B's factuality score increased from 38.9 to 53.8. In news datasets like CNN/Daily Mail, CAD improved both factuality and lexical overlap (ROUGE) scores, indicating that the summaries became both more accurate and more aligned with human-written references.
Instruction-tuned models, such as Mistral-7B-instruct, were found to outperform their base counterparts in baseline factuality. However, CAD still provided a measurable performance boost even to these more advanced models, suggesting that instruction tuning alone does not fully solve the prior-belief conflict.
Hyperparameter Tuning
The effectiveness of CAD is sensitive to the $\alpha$ value. The authors found that an $\alpha$ of 0.3 generally provides the optimal balance between maintaining query relevance and ensuring factual grounding. Higher values of $\alpha$ can sometimes lead to a decrease in ROUGE scores in highly abstractive datasets like Debatepedia, where human references are more creative than the strictly grounded CAD outputs.
The Cost of Accuracy
While CAD enhances factuality, it comes with a significant computational penalty. Because the method requires two forward passes per token generation, inference latency increases by approximately 83%. In real-world testing on an RTX 3090 GPU, generation speed slowed from 0.042 seconds per token (vanilla) to 0.077 seconds per token (CAD).
Conclusion and Future Work
Context-aware Decoding is a powerful tool for mitigating hallucinations in LLMs by forcing them to act as neutral readers rather than relying on pre-trained knowledge. While the computational overhead is a barrier for production use, the gains in factuality are substantial. Future research may explore "speculative" CAD implementations, where dual-pass decoding is only triggered when the model exhibits low confidence, potentially reducing the overall latency while maintaining high factual integrity.
Summary updated