Making RALM Robust to Irrelevant Contexts via Layer Knowledge Guided Attention (2025)

Abstract: Retrieval-augmented language models (RALMs) aim to incorporate external knowledge to address the issues of factual hallucination and knowledge obsolescence faced by large language models (LLMs). Inevitably, the retrieved passages based on similarity search may be irrelevant to the given question, and the aggregation of these passages can confuse the model to give a correct answer. To improve the performance of RALM in such conditions, we propose layer-knowledge guided attention for RALMs, which harnesses the layer-wise knowledge of LLMs to optimize per-layer attention on useful passages, making the model pay attention to the most relevant content and ignore irrelevant ones. Specifically, we first systematically study LLM’s attention patterns and their relationship with the accuracy of RALM responses, where middle-focus attentions play a crucial role in selectively gathering relevant information. Based on this, a layer-wise passage estimator leverages the varied knowledge encoded across LLM layers to assess not only passage relevance scores but also associated confidences. Finally, a relevance-aware passage fusion enables selective attention to relevant passages, mitigating distractibility and positional bias of causal attention. Experiments show that our method outperforms existing methods on RALM benchmarks.

## introduction large language models (llms) have demonstrated remarkable performance, scalability, and adaptability in various natural language processing tasks @xcite @xcite . however, llms encounter significant challenges when tackling knowledge-intensive * co-authors: hao chen, yao zhao † email: wshiah@connect.ust.hk ‡ corresponding authors: yazhong zhang, qijin chen, jiajie xu, jia zhu tasks, including factual hallucination @xcite @xcite , knowledge obsolescence @xcite , and a lack of domain-specific expertise @xcite . to address these issues, retrievalaugmented language model (ralm) has emerged as a mainstream approach, which leverages a retrieval-then-read pipeline to supply external information for the llm answering questions. despite ralm's potential, llms struggle to handle retrieved passages, which contain irrelevant ones, hindering performance in two aspects: while @xcite attempts to address these issues by filtering irrelevant passages and optimizing passage placement, these serve as compromised strategies rather than fundamental fixes to llm attention processing retrieved passages. in this paper, we propose layer-knowledge guided attention for ralm (lkg-ralm), which harnesses the layer-wise knowledge of llms to optimize attention on useful passages. to effectively guide llm's attention, accurately assessing the relevance of retrieved passages is crucial. recent works demonstrate that llm-based embeddings significantly outperform bert-like models on the mteb leaderboard due to superior scaling and comprehensive pre-training. furthermore, @xcite ; @xcite indicate that different llm layers encode varied knowledge, from grammatical understanding in lower layers to reasoning capabilities in higher ones. building on these insights, we propose a layer-wise passage estimator, which fully leverages varied knowledge of llm layers to accurately predict both relevance and estimation confidence. since not all layers' knowledge contributes equally to relevance assessment, an entropy-based layer-knowledge selection is proposed to dynamically determine which layers' knowledge is suitable for passages. to mitigate distractibility and positional bias from irrelevant passages, a relevance-aware passage fusion employs a relevance-guided attention mask to enable question tokens to selectively attend to retrieved passages for middle-focused attention patterns. experiments demonstrate that lkg-ralm achieves substantial performance improvements across ralm datasets. our contributions are summarized as: ## conclusion in this work, we proposed lkg-ralm, which leverages layer-wise knowledge within llms to guide attention toward relevant passages, addressing distractibility and positional bias in handling retrieved passages. a layer-wise passage estimator evaluates passage relevance by utilizing diverse layer knowledge within the llm. entropy-based layer-knowledge selection dynamically identifies the most relevant layers for accurate passage assessment. relevance-aware passage fusion selectively prioritizes crucial content, reducing the impact of irrelevant passages and overcoming positional bias. extensive experiments across multiple datasets demonstrate that lkg-ralm achieves notable improvements in accuracy and robustness for knowledge-intensive tasks.