Retrieval Augmented Generation (RAG) is a highly effective paradigm for keeping LLM-based responses up-to-date and reducing the likelihood of hallucinations. Yet, RAG was recently shown to be quite vulnerable to corpus knowledge poisoning: an attacker injects misleading documents to the corpus to steer an LLMs' output to an undesired response. We argue that the standard causal attention mechanism in LLMs enables harmful cross-document interactions, specifically in cases of attacks. Accordingly, we introduce a novel defense approach for RAG: Sparse Document Attention RAG (SDAG). This is a block-sparse attention mechanism that disallows cross-attention between retrieved documents. SDAG requires a minimal inference-time change to the attention mask; furthermore, no fine-tuning or additional architectural changes are needed. We present an empirical evaluation of LLM-based question answering (QA) with a variety of attack strategies on RAG. We show that our SDAG method substantially outperforms the standard causal attention mechanism in terms of attack success rate. We further demonstrate the clear merits of integrating SDAG with state-of-the-art RAG defense methods. Specifically, the integration results in performance that is statistically significantly better than the state-of-the-art.


翻译:检索增强生成(RAG)是一种极为有效的范式,能够保持基于大型语言模型(LLM)的响应与时俱进,并降低产生幻觉的可能性。然而,近期研究表明,RAG极易受到语料库知识投毒攻击:攻击者通过向语料库中注入误导性文档,从而操控LLM输出非预期的响应。我们认为,LLM中标准的因果注意力机制在遭受攻击时,会促成有害的跨文档交互。为此,我们提出一种针对RAG的新型防御方法:稀疏文档注意力RAG(SDAG)。这是一种块稀疏注意力机制,它禁止检索到的文档之间进行交叉注意力计算。SDAG仅需在推理时对注意力掩码进行最小程度的修改,且无需微调或额外的架构调整。我们基于LLM的问答(QA)任务,在多种针对RAG的攻击策略下进行了实证评估。结果表明,我们的SDAG方法在攻击成功率方面显著优于标准的因果注意力机制。我们进一步证明了将SDAG与最先进的RAG防御方法相结合具有明显优势。具体而言,这种集成方案在性能上取得了统计意义上显著优于当前最优方法的结果。

0
下载
关闭预览

相关内容

检索增强生成(RAG)技术,261页slides
专知会员服务
41+阅读 · 2025年10月16日
【新书】Essential GraphRAG: 知识图谱增强的RAG
专知会员服务
32+阅读 · 2025年7月17日
【新书】检索增强生成(RAG)入门指南
专知会员服务
29+阅读 · 2025年6月25日
检索增强生成(RAG)与推理的协同作用:一项系统综述
专知会员服务
15+阅读 · 2025年4月27日
智能体检索增强生成:关于智能体RAG的综述
专知会员服务
89+阅读 · 2025年1月21日
赛尔笔记 | Attention!注意力机制可解释吗?
哈工大SCIR
23+阅读 · 2019年9月27日
NLP-Progress记录NLP最新数据集、论文和代码: 助你紧跟NLP前沿
中国人工智能学会
12+阅读 · 2018年11月15日
NLG ≠ 机器写作 | 专家专栏
量子位
13+阅读 · 2018年9月10日
深度学习中的注意力机制
CSDN大数据
24+阅读 · 2017年11月2日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2016年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
国家自然科学基金
11+阅读 · 2012年12月31日
VIP会员
相关VIP内容
检索增强生成(RAG)技术,261页slides
专知会员服务
41+阅读 · 2025年10月16日
【新书】Essential GraphRAG: 知识图谱增强的RAG
专知会员服务
32+阅读 · 2025年7月17日
【新书】检索增强生成(RAG)入门指南
专知会员服务
29+阅读 · 2025年6月25日
检索增强生成(RAG)与推理的协同作用:一项系统综述
专知会员服务
15+阅读 · 2025年4月27日
智能体检索增强生成:关于智能体RAG的综述
专知会员服务
89+阅读 · 2025年1月21日
相关基金
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2016年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
国家自然科学基金
11+阅读 · 2012年12月31日
Top
微信扫码咨询专知VIP会员