论文精选73°

ACToR框架实现代码生成关键令牌感知检索

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

精选理由

DeepSoftwareAnalytics团队推出ACToR框架,能精准定位代码生成中的关键点,比现有方法表现更好。

AI 摘要

ACToR框架针对仓库级代码生成任务,在生成过程中识别关键令牌并按需触发检索。该方法在RepoExec和CoderEval两个基准测试中分别实现了8.4%和15.4的相对性能提升。研究还量化了关键令牌对生成失败的影响,突显了针对性检索策略的必要性。

原文 · arXiv cs.AI

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

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.