Skip to content
Preprint

Effective and Efficient Context Retrieval via Partial Dependency Graph for Repository-Level Code Generation

Aug 2026 · 1 citation · 56 references
Computer Science

TL;DR

DyRetriever is an efficient context retrieval method via partial dependency graphs that uses an LLM to first select a set of entry-point functions and then perform multi-hop reasoning along the code dependency graph, eliminating manually designed rules and enabling flexibility across scenarios.

Abstract

LLM-based repository-level code generation aims to generate code using the context available in a software repository, requiring LLMs to reason over complex code dependencies. Due to limited context windows and insufficient repository-specific understanding, LLMs typically rely on retrieval-augmented generation (RAG) to incorporate relevant code. Early RAG approaches primarily employ similarity-based retrieval, which often fails to retrieve code snippets that the target function depends on. Recent work introduces graph-based retrieval to model such dependencies, but typically relies on manually designed rules and static global graphs, leading to limited flexibility and high construction and maintenance costs. In contrast, human developers collect helpful context by implicitly constructing a partial dependency graph and iteratively inspecting along it. Inspired by this behavior, we propose DyRetriever, an efficient context retrieval method via partial dependency graphs. DyRetriever uses an LLM to first select a set of entry-point functions and then perform multi-hop reasoning along the code dependency graph. During multi-hop reasoning, it uses the LLM's semantic understanding to validate whether a function can help generate the target function, eliminating manually designed rules and enabling flexibility across scenarios. Instead of statically constructing a global dependency graph, DyRetriever builds a partial graph on demand and discards it after use, reducing construction and maintenance costs. We integrate DyRetriever with a similarity-based code retriever to build DyCoder and evaluate it on CoderEval and DevEval. Experimental results show that DyCoder achieves relative Pass@1 improvements of 25.63% and 59.73% on CoderEval and DevEval, respectively, compared with existing RAG-based methods, while being 7.4x faster than baselines based on static dependency graph construction.

View source

Similar papers

Preprint Sep 2026

Beyond Repository Boundaries: Cross-Repository Graph Retrieval for Code Generation

Repository-level code generation requires generated code to be compatible not only with the target repository but also with its dependency environment. Existing retrieval-based methods mainly retrieve context from the local repository, leaving external API usage dependent on the model's pretrained knowledge, which can be insufficient for unseen or version-specific APIs. Moreover, current retrieval strategies largely focus on one-hop evidence and overlook the structural relationships among code components. We propose CrossCoder, a cross-repository code generation framework that explicitly incorporates external libraries into the retrieval context through a unified knowledge graph over repository and library entities. CrossCoder identifies important nodes via planning and semantic retrieval, then selectively expands neighboring nodes to retrieve richer multi-hop contextual evidence for generation. To further evaluate dependency-version compatibility, we introduce VersionExec, an execution-based benchmark derived from BigCodeBench that evaluates generation under different dependency versions. Experimental results on RepoExec, DevEval, and VersionExec demonstrate that CrossCoder consistently improves both functional correctness (up to 6.3% on pass@1) and robustness to dependency-version changes.

Minh Le-Anh, Nam Le Hai, Quyen Tran et al. · 0 citations
#artificial intelligence Preprint Sep 2026

Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generation

ACToR identifies critical tokens during generation and triggers targeted retrieval on demand to provide repository context at these decisive positions, and designs a position-aware weighting method for dense retrievers to prioritize context that is more informative for generation.

Kefeng Duan, De-Wu Zheng, Yan-Lin Wang et al. · 0 citations
Jul 2026

OwlPath: Lossless Knowledge Compression for LLM Bug Repair

OwlPath is presented, an OWL2 reasoning layer atop CodeGraph, a widely used code intelligence platform with 500K+ GitHub stars, offering a unified CLI for structural code retrieval, with lossless knowledge compression.

Bo Zhang, Renke Pan, Huan Chen et al. · 0 citations
Preprint Aug 2026

Towards Automated Domain Model Extraction from Source Code using Heuristics and Open-Source LLMs

This paper proposes an automated approach to extract domain models from source code using lightweight, locally deployable LLMs and achieves high F1-scores on a dataset of ten projects, each comprising a curated domain model and its corresponding implementation, while remaining fully executable on locally deployable LLMs.

Alessandra Mancas, Mounir Ammam, Hyacinth Ali et al. · 0 citations
Open access Aug 2026

Optimizing Context and Cost in LLM‐Based Unit Test Generation: A Study on External Dependency Retrieval Strategies

A systematic empirical study of multiple strategies for context enrichment and optimization in LLM‐based unit test generation, conducted on seven diverse projects (three open‐source and four proprietary industrial systems), encompassing 261 distinct methods establish this optimized context strategy as a cost‐effective solution for scalable, industrial‐grade automated test generation.

Javier Ferrer, Francisco Chicano · 0 citations

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.