arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2605.12975cs.AI
收藏

检索成本低廉,展示代码:可执行多跳推理的检索增强生成

Retrieval is Cheap, Show Me the Code: Executable Multi-Hop Reasoning for Retrieval-Augmented Generation

University of Illinois Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校);Hong Kong University of Science and Technology(香港科学与技术大学);Texas A&M University(德克萨斯农工大学)

Jiashuo Sun, Jimeng Shi, Yixuan Xie, Saizhuo Wang, Jash Rajesh Parekh, Pengcheng Jiang, Zhiyi Shi, Jiajun Fan, Qinglong Zheng, Peiran Li, Shaowen Wang, Ge Liu, Jiawei Han

AI总结:

本文提出PyRAG框架,将多跳检索增强生成转化为程序合成与执行,通过可执行Python代码实现可调试的推理过程,提升多跳问答性能。

摘要:

检索增强生成(RAG)已成为知识密集型问答的标准方法,但现有系统在多跳问题上仍脆弱,需链式多个检索和推理步骤。关键挑战是当前方法用自然语言表示推理过程,中间状态隐式,检索查询可能偏离目标实体,且错误由同一模型检测,自我反思不可靠。我们观察到多跳问答是典型的逐步计算形式,与代码专精语言模型的训练方式一致。受此启发,我们引入PyRAG框架,将多跳RAG转化为程序合成与执行。不同于自由形式推理轨迹,PyRAG将推理过程表示为可执行的Python程序,暴露中间状态为变量,通过执行产生确定性反馈,并产生整个推理过程的可检查轨迹。此方法进一步支持基于编译器的自我修复和基于执行的自适应检索,无需额外训练。在五个QA基准(PopQA、HotpotQA、2WikiMultihopQA、MuSiQue和Bamboogle)上的实验表明,PyRAG在无训练和RL训练设置下均优于强基线,尤其在组合性多跳数据集上收益显著。我们的代码、数据和模型在https://github.com/GasolSun36/PyRAG公开。

英文摘要:

Retrieval-Augmented Generation (RAG) has become a standard approach for knowledge-intensive question answering, but existing systems remain brittle on multi-hop questions, where solving the task requires chaining multiple retrieval and reasoning steps. Key challenges are that current methods represent reasoning through free-form natural language, where intermediate states are implicit, retrieval queries can drift from intended entities, and errors are detected by the same model that produces them making self-reflection an unreliable, ungrounded signal. We observe that multi-hop question answering is a typical form of step-by-step computation, and that this structured process aligns closely with how code-specialized language models are trained to operate. Motivated by this, we introduce \pyrag, a framework that reformulates multi-hop RAG as program synthesis and execution. Instead of free-form reasoning trajectories, \pyrag represents the reasoning process as an executable Python program over retrieval and QA tools, exposing intermediate states as variables, producing deterministic feedback through execution, and yielding an inspectable trace of the entire reasoning process. This formulation further enables compiler-grounded self-repair and execution-driven adaptive retrieval without any additional training. Experiments on five QA benchmarks (PopQA, HotpotQA, 2WikiMultihopQA, MuSiQue, and Bamboogle) show that \pyrag consistently outperforms strong baselines under both training-free and RL-trained settings, with especially large gains on compositional multi-hop datasets. Our code, data and models are publicly available at https://github.com/GasolSun36/PyRAG.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑