arXiv:2604.10516cs.CL2026-04

用代码依赖关系找知识,让大模型做多步数据分析更准

Structure-Grounded Knowledge Retrieval via Code Dependencies for Multi-Step Data Reasoning

论文配图:Structure-Grounded Knowledge Retrieval via Code Dependencies for Multi-Step Data Reasoning
图 1 · 摘自论文原文
  • 构建函数调用依赖图,按计算路径找相关知识
  • 在多个数据推理任务上准确率显著高于传统检索方法
  • 适合需要精确代码逻辑的编程类大模型应用

在使用大语言模型(LLMs)解决领域特定的数据分析任务时,选择正确知识至关重要。然而,大多数检索增强方法主要依赖词汇或嵌入相似性,这往往无法有效捕捉多步推理所需的关键知识。在许多任务中,相关知识并非仅与查询文本相关,而是根植于可执行代码及计算过程中的依赖结构。为此,我们提出SGKR(Structure-Grounded Knowledge Retrieval),一种基于函数调用依赖生成的图结构组织领域知识的检索框架。给定问题后,SGKR提取语义输入输出标签,识别连接它们的依赖路径,并构建任务相关的子图。相关知识及对应函数实现被整合为结构化上下文,供基于LLM的代码生成使用。在多个多步数据推理基准上的实验表明,无论使用通用LLM还是编码代理,SGKR在解决方案正确率上均持续优于无检索和基于相似性的基线方法。

原文摘要 · Abstract (English)

Selecting the right knowledge is critical when using large language models (LLMs) to solve domain-specific data analysis tasks. However, most retrieval-augmented approaches rely primarily on lexical or embedding similarity, which is often a weak proxy for the task-critical knowledge needed for multi-step reasoning. In many such tasks, the relevant knowledge is not merely textually related to the query, but is instead grounded in executable code and the dependency structure through which computations are carried out. To address this mismatch, we propose SGKR (Structure-Grounded Knowledge Retrieval), a retrieval framework that organizes domain knowledge with a graph induced by function-call dependencies. Given a question, SGKR extracts semantic input and output tags, identifies dependency paths connecting them, and constructs a task-relevant subgraph. The associated knowledge and corresponding function implementations are then assembled as a structured context for LLM-based code generation. Experiments on multi-step data analysis benchmarks show that SGKR consistently improves solution correctness over no-retrieval and similarity-based retrieval baselines for both vanilla LLMs and coding agents.

知识检索代码依赖多步推理大模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。