arXiv:2512.16956cs.SEcs.LG2025-12

用代码结构信息增强检索,让大模型更准定位问题代码。

SpIDER: Spatially Informed Dense Embedding Retrieval for Software Issue Localization

  • 结合代码图结构与大模型推理,动态扩展候选代码
  • 在多个语言和数据集上召回率提升13%~27%
  • 可审计的检索结果,适合开发工具集成

从大型代码库中检索与用户查询、错误报告或功能请求相关的函数、类或文件,是基于大语言模型(LLM)的编码代理面临的核心挑战。现有方法多采用稀疏(如BM25)或密集嵌入策略,但均忽略代码库的图结构特性。为此,我们提出SpIDER(空间感知密集嵌入检索),将LLM推理与代码库的图结构探索相结合。我们还构建了SpIDER-Bench,一个来自SWEPolyBench、SWEBench-Verified和Multi-SWE-bench的图结构基准,涵盖Python、Java、JavaScript和TypeScript仓库。SpIDER通过图结构扩展候选函数,为每个结果附带包含原因(种子节点及连接边类型),实现可审计的检索,同时保持检索预算不变。代码图基于每仓库的语法树动态构建,可在开发者会话开始时实时生成,无需离线预计算。实验表明,SpIDER在所有语言和基准上均显著提升密集检索的Recall@20:沿包含边提升至少13%相对(绝对+0.05至+0.12),探索调用边后进一步提升至少27%相对(绝对+0.11至+0.19)。

原文摘要 · Abstract (English)

Retrieving code functions, classes or files relevant to a user query, bug report or feature request from large codebases is a fundamental challenge for Large Language Model (LLM)-based coding agents. Agentic approaches typically employ sparse methods like BM25 or dense embedding strategies to identify semantically relevant units. While dense embedding approaches can outperform BM25 by large margins, both ignore the graph-structured characteristics of the codebase. To address this, we propose SpIDER (Spatially Informed Dense Embedding Retrieval), a dense retrieval approach that integrates LLM-based reasoning with graph-based exploration of the codebase. We further introduce SpIDER-Bench, a graph-structured benchmark curated from SWEPolyBench, SWEBench-Verified and Multi-SWE-bench, spanning Python, Java, JavaScript and TypeScript repositories. SpIDER's graph-based candidate expansion attaches a structural reason for inclusion to each surfaced function (its seed and the edge type linking them), making the candidate set auditable while keeping the retrieval budget fixed. The graph is built from per-repository syntax trees, so it can be constructed on-demand at the start of a developer session rather than precomputed offline. Empirical results show that SpIDER consistently improves dense retrieval Recall@20 across every language and benchmark in SpIDER-Bench: by at least 13% relative (+0.05 to +0.12 absolute) along containment edges, rising to at least 27% relative (+0.11 to +0.19 absolute) once call edges are explored.

代码检索图神经网络LLM应用

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