将检索增强生成视为上下文优化,用梯度下降思想提升推理效果
In-Context Optimization for Retrieval-Augmented Generation: A Gradient-Descent Perspective
- 用线性自注意力实现梯度下降式更新,打通检索与优化的机制联系
- 在7个问答任务上,仅需前向计算就接近测试时微调性能
- 适用于冻结模型场景,低成本提升检索信息使用效率
近期研究表明,线性自注意力模型中的上下文学习可被理解为隐式梯度下降。检索增强生成(RAG)同样依赖上下文,但通常将检索文档视为静态证据而非可调整信号。本文将RAG建模为上下文优化过程:首先证明单层线性自注意力可实现统一线性化RAG目标的一次梯度下降步骤,确立了检索增强预测与上下文优化完全对应的确切情形。该结果不作为大模型计算的直接解释,而是指导查询与检索证据间的交互优化。进一步验证该对应关系在可控线性扩展下保持稳定,但在非线性架构下依赖特征分布。最后,基于此视角提出一种轻量级方法,仅对生成端的证据使用接口进行上下文条件更新,保持检索器和主干模型固定。在七个QA基准、两种检索器和两种冻结大模型上,该方法优于共享接口基线,跨任务泛化良好,且以极低每查询开销逼近测试时梯度适应效果。
原文摘要 · Abstract (English)
In-context learning has recently been linked to implicit gradient descent in linear self-attention models, suggesting that context can induce a forward-pass update. Retrieval-augmented generation (RAG) also relies on context, but retrieved documents are usually treated as static evidence rather than signals for adaptation. We study RAG as an in-context optimization process. First, we show that one linear self-attention layer can implement one gradient-descent step on a unified linearized RAG objective covering both projection-based and dot-product retrieval interfaces. This gives an exact regime where retrieval-augmented prediction and in-context optimization coincide. We use this result not as a literal model of LLM computation, but as a guide for adapting the interaction between queries and retrieved evidence. We then test the boundary of this correspondence: it remains stable under controlled linear extensions, but becomes feature-distribution dependent under nonlinear architectures. Finally, we turn this view into a lightweight method for frozen RAG LLMs. The method keeps the retriever and backbone fixed, and predicts a context-conditioned update to a generator-side evidence-use interface. Across seven QA benchmarks, two retrievers, and two frozen LLM backbones, this forward-only update improves a shared-interface baseline, transfers to held-out tasks, and approaches test-time gradient adaptation at much lower per-query cost.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。