让大模型在隐空间中高效复用经验,提升推理与规划能力。
ExpWeaver: LLM Agents Learn from Experience via Latent RAG

- 用模型自身隐藏状态编码经验,在隐空间直接检索并融合。
- 13项任务中12项达顶尖水平,零样本迁移性能领先16.32%。
- 无需额外模块,端到端优化,节省1.5到2倍上下文 tokens。
经验学习通过整合过往交互作为可复用知识,显著提升了大语言模型代理的规划与推理能力。然而,现有方法局限于显式文本空间,依赖语义相似性检索并将经验拼接进上下文窗口,造成大量 token 消耗且检索与生成分离。为此,我们提出 ExpWeaver,一种基于隐空间检索增强生成的经验学习框架,无需独立 RAG 模块。ExpWeaver 利用模型自身隐藏状态编码经验,在每个解码步骤中直接于隐空间检索相关经验,并通过交叉注意力聚合与门控残差机制融合。整个流程通过强化学习端到端优化,支持生成与排序任务。我们在涵盖问答、推理、编程、科学预测和推荐等13个多样化任务上评估该方法。结果表明,ExpWeaver 在13项任务中12项达到最先进水平,较最强基线提升超6.8%;在保持与非检索基线相当的 token 效率的同时,文本检索方法需1.5至2倍更多 token;在跨领域泛化上表现更优,零样本迁移下领先16.32%,少样本迁移下领先15.21%。代码已开源:https://github.com/ulab-uiuc/ExpWeaver。
原文摘要 · Abstract (English)
Experience learning has achieved promising results in enhancing LLM agent planning and reasoning by integrating past interactions as reusable knowledge. However, existing methods remain confined to explicit text space, retrieving experiences via semantic similarity and concatenating them into the context window, leading to substantial token overhead and a decoupled architecture that separates retrieval from generation. To address these limitations, we propose ExpWeaver, a framework that enables LLM agents to learn from experience via latent retrieval-augmented generation, without requiring a separate RAG module. ExpWeaver encodes experiences using the LLM's own hidden states, retrieves relevant experiences directly in latent space at each decoding step, and integrates them through cross-attention aggregation and gated residual mechanisms. The entire pipeline is optimized end-to-end with reinforcement learning, supporting both generative and ranking tasks. We evaluate ExpWeaver on 13 diverse tasks spanning question answering, reasoning, coding, scientific prediction, and recommendation. Results demonstrate that ExpWeaver achieves state-of-the-art performance on 12 out of 13 tasks, outperforming the strongest baseline by over 6.8%; maintains token efficiency comparable to non-retrieval baselines while text-based retrieval methods require 1.5 to 2 times more tokens; and exhibits superior cross-domain generalization, outperforming the strongest baseline by 16.32% under zero-shot transfer and 15.21% under few-shot transfer. Our code for ExpWeaver is released at https://github.com/ulab-uiuc/ExpWeaver.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。