NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

LFD: Layer Fused Decoding to Exploit External Knowledge in Retrieval-Augmented Generation

Yang Sun, Lixin Zou, Dan Luo, Zhiyong Xie, Long Zhang, Liming Dong, Yunwei Zhao, Xixun Lin, Yanxiong Lu, Chenliang Li · OpenReview

Abstract

Retrieval-augmented generation (RAG) incorporates external knowledge into large language models (LLMs), improving their adaptability to downstream tasks and enabling information updates. Surprisingly, recent empirical evidence demonstrates that injecting noise into retrieved relevant documents paradoxically facilitates exploitation of external knowledge and improves generation quality. Although counterintuitive and challenging to apply in practice, this phenomenon enables granular control and rigorous analysis of how LLMs integrate external knowledge. Therefore, in this paper, we intervene on noise injection and establish a layer-specific functional demarcation within the LLM: shallow layers specialize in local context modeling, intermediate layers focus on integrating long-range external factual knowledge, and deeper layers primarily rely on parametric internal knowledge. Building on this insight, we propose Layer Fused Decoding (LFD), a simple decoding strategy that directly combines representations from an intermediate layer with final-layer decoding outputs to fully exploit the external factual knowledge. To identify the optimal intermediate layer, we introduce an internal knowledge score (IKS) criterion that selects the layer with the lowest IKS value in the latter half of layers. Experimental results across multiple benchmarks demonstrate that LFD helps RAG systems more effectively surface retrieved context knowledge with minimal cost.

Introduction

Retrieval-Augmented Generation (RAG) has become the standard for providing Large Language Models (LLMs) with access to up-to-date or private information. Despite its success, LLMs often face a "tug-of-war" between their internal parametric knowledge (learned during pre-training) and the external context provided during retrieval. This conflict frequently results in the model ignoring retrieved documents in favor of hallucinations based on internal memory.

Conceptual framework of LFD illustrating how middle layers focus on retrieved facts while deep layers are often confounded by internal parametric knowledge.

Recent studies have uncovered a counterintuitive phenomenon: adding "noise" (irrelevant documents) to a prompt can actually improve a model's grounding in the correct information. However, this brute-force approach significantly increases computational costs. This paper explores the mechanistic reasons for this effect and introduces Layer Fused Decoding (LFD), a training-free strategy that achieves superior grounding without the overhead of noise injection.

Functional Demarcation of LLM Layers

By analyzing how LLMs process information layer-by-layer, the authors identified a clear functional demarcation:

  1. Shallow Layers: Specialize in local context and basic language modeling.
  2. Middle Layers: Focus on integrating long-range external factual knowledge. This is where the model is most sensitive to the retrieved context.
  3. Deep Layers: Shift back toward internal parametric knowledge, often overriding the external facts gathered in the middle layers.
Cosine similarity across layers under different noise levels, showing that middle-to-late layers are most sensitive to external context interventions.

This "U-shaped" knowledge flow suggests that the final layers of an LLM can act as a filter that inadvertently discards the very facts the RAG system was designed to provide.

Layer Fused Decoding (LFD)

LFD exploits this layer-specific behavior by identifying the "sweet spot" intermediate layer and fusing its representations with the final output. The process involves:

  • Internal Knowledge Score (IKS): A metric used to select the optimal layer. By projecting hidden states into vocabulary space (LogitLens), the authors measure how much the Feed-Forward Network (FFN) at each layer transforms the prediction. A low IKS in the latter half of the model identifies a layer strongly grounded in retrieved context.
  • Fusion Mechanism: LFD combines the log-probabilities from the optimal intermediate layer with the final layer's output, ensuring the final prediction is anchored in factual grounding.
  • Dynamic Gating: To prevent errors, a thresholding mechanism ensures fusion only occurs when the intermediate layer's confidence aligns with the model's overall reasoning.

Key Results and Discussion

LFD was evaluated across diverse benchmarks including Natural Questions (NQ), RGB, HotpotQA, and 2WikiMultihopQA using models like Llama-2, Mistral, and DeepSeek.

  • Superior Accuracy: LFD consistently outperformed standard greedy decoding and noise-injection strategies. For example, on DeepSeek-7B using 2WikiMultihopQA, LFD improved accuracy by 16.76% over the baseline.
  • Efficiency Gains: LFD achieved 2.5x higher throughput than noise-injection methods while using significantly less GPU memory (~203MB vs ~1426MB overhead).
  • Robustness: Unlike noise injection, which can degrade performance in certain models like Mistral-7B, LFD provided consistent gains across all tested architectures.

Conclusion

Layer Fused Decoding (LFD) offers a powerful, training-free method to enhance RAG systems. By recognizing that factual grounding often peaks in intermediate layers, LFD allows models to bypass the parametric interference of deeper layers, resulting in more accurate and efficient information generation.

Summary updated

BibTeX
@misc{sun2025lfd,
  author = {Yang Sun and Lixin Zou and Dan Luo and Zhiyong Xie and Long Zhang and Liming Dong and Yunwei Zhao and Xixun Lin and Yanxiong Lu and Chenliang Li},
  title = {{LFD: Layer Fused Decoding to Exploit External Knowledge in Retrieval-Augmented Generation}},
  year = {2025},
  eprint = {2508.19614},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.19614},
}
Figure