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

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Sun, Jiashuo, Shi, Jimeng, Xie, Yixuan, Wang, Saizhuo, Parekh, Jash Rajesh, Jiang, Pengcheng, Shi, Zhiyi, Fan, Jiajun, Zheng, Qinglong, Li, Peiran, Wang, Shaowen, Liu, Ge, Han, Jiawei
Formato: Preprint
Publicado: 2026
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866916008586903552
author Sun, Jiashuo
Shi, Jimeng
Xie, Yixuan
Wang, Saizhuo
Parekh, Jash Rajesh
Jiang, Pengcheng
Shi, Zhiyi
Fan, Jiajun
Zheng, Qinglong
Li, Peiran
Wang, Shaowen
Liu, Ge
Han, Jiawei
author_facet Sun, Jiashuo
Shi, Jimeng
Xie, Yixuan
Wang, Saizhuo
Parekh, Jash Rajesh
Jiang, Pengcheng
Shi, Zhiyi
Fan, Jiajun
Zheng, Qinglong
Li, Peiran
Wang, Shaowen
Liu, Ge
Han, Jiawei
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2605_12975
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Retrieval is Cheap, Show Me the Code: Executable Multi-Hop Reasoning for Retrieval-Augmented Generation
Sun, Jiashuo
Shi, Jimeng
Xie, Yixuan
Wang, Saizhuo
Parekh, Jash Rajesh
Jiang, Pengcheng
Shi, Zhiyi
Fan, Jiajun
Zheng, Qinglong
Li, Peiran
Wang, Shaowen
Liu, Ge
Han, Jiawei
Artificial Intelligence
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.
title Retrieval is Cheap, Show Me the Code: Executable Multi-Hop Reasoning for Retrieval-Augmented Generation
topic Artificial Intelligence
url https://arxiv.org/abs/2605.12975