Skip to content

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

Sep 2026 · 0 citations · 67 references
Computer Science

TL;DR

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.

Abstract

The repository-level code generation task requires synthesizing code that satisfies task requirements while remaining consistent with the target repository context. Since real-world repositories often exceed the input length limits of LLMs, existing approaches commonly adopt retrieval-augmented generation (RAG) to provide repository-specific context. Despite improving repository-context retrieval, existing methods typically provide context as task-level support, without explicitly identifying the critical tokens that require fine-grained repository context during generation. During the autoregressive generation process of LLMs, errors often concentrate at a small number of decisive positions: once such tokens are generated incorrectly, subsequent code may follow an incorrect semantic path and eventually lead to functional failure. We refer to these positions as"critical tokens". In this paper, we propose ACToR, an adaptive critical token-aware retrieval framework 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. In addition, we design a position-aware weighting method for dense retrievers to prioritize context that is more informative for generation. We evaluate ACToR on two representative repository-level benchmarks, RepoExec and CoderEval. Experimental results show that ACToR consistently outperforms state-of-the-art methods, achieving relative improvements of 8.4% on RepoExec and 15.4% on CoderEval. Beyond performance gains, we systematically quantify the impact of critical tokens, revealing their central role in major generation failures and highlighting the necessity of targeted retrieval strategies. We provide the code and data at https://github.com/DeepSoftwareAnalytics/ACToR.

View source

Similar papers

Preprint Sep 2026

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

CrossCoder is proposed, 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 that consistently improves both functional correctness and robustness to dependency-version changes.

Minh Le-Anh, Nam Le Hai, Quyen Tran et al. · 0 citations
Open access Oct 2026

LLM See, LLM Do: Enhancing Repository-Aware Code Generation in LLMs Through Logical Context and Usage Knowledge

Large language models (LLMs) have significantly advanced automatic code generation. Although they have demonstrated remarkable ability in writing standalone code, they still struggle with real-world repository-level coding tasks due to the lack of repository-specific knowledge. Existing studies typically employ retriev...

Tanghaoran Zhang, Xin-Jun Mao, Yu-Xin Zhao et al. · 0 citations
Review Sep 2026

RCL: A Retrieval-Confidence Layer for Detecting Insufficient Context in Enterprise Retrieval-Augmented Code Generation

RCL (Retrieval-Confidence Layer), a lightweight module inserted between retrieval and generation that combines a call-graph-derived structural coverage score with a novelty score estimating a query's dependence on knowledge outside the model's prior, to detect insufficient retrieval before generation occurs.

Chandra Mohan Ravuri · 0 citations
Open access Oct 2026

Enhancing LLM-Based Bug Reproduction via Code Entity Retrieval and Test Case Repair

Automated bug reproduction from bug reports is a critical yet challenging step in software debugging. While LLM-based bug reproduction shows promise, its effectiveness is often hampered by insufficient contextual awareness of the relevant codebase and a tendency to produce invalid test cases. To address these limitatio...

Hao Ding, Yan-Jie Jiang, Yu-Xia Zhang et al. · 0 citations
Preprint Aug 2026

DeepRepro: State-Aware Subplanning for Paper-to-Code Reproduction in Evolving Repositories

DeepRepro dynamically transforms evolving repository states and runtime feedback into fine-grained implementation subplans, keeping planning aligned with execution throughout repository construction, and consistently outperforms strong scientific and commercial code-agent baselines.

Hong-Ru Song, Ru-Qing Zhang, Jia-Feng Guo et al. · 0 citations
Preprint Oct 2026

CARET: Training-Free Test-Time Scaling for Repository-Level Code Completion

Retrieval-augmented generation (RAG) dominates repository-level code completion: it retrieves cross-file context (R), then decodes one greedy completion (G). Existing work mainly focuses on retrieval and stops there. We argue both stages can be improved together, with generation in particular gaining from test-time sca...

Jia-Jie Wang, Yu-Tong Zhao, Ke-Bin Peng et al. · 0 citations

Related blog posts

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