Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generation
Not on the map. Why?
Abstract (arXiv)
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.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 54 of its 67 references that are in the map. First posted on arXiv 1 Sep 2026.
Builds on
54 of 67 references.
References · 54
- 2017Attention Is All You Needcited by 59,932
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2022Competition-Level Code Generation with AlphaCodecited by 1,427
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
- 2023StarCoder: may the source be with you!cited by 790
- 2024BigCodeBench: Benchmarking Code Generation with Diverse Function Calls and Complex Instructionscited by 527
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
- 2024StarCoder 2 and The Stack v2: The Next Generationcited by 484
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 389
38 more
- 2022CodeT: Code Generation with Generated Testscited by 369
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 355
- 2020IntelliCode Compose: Code Generation Using Transformercited by 225
- 2024CacheBlend: Fast Large Language Model Serving for RAG with Cached Knowledge Fusioncited by 211
- 2023CacheGen: KV Cache Compression and Streaming for Fast Large Language Model Servingcited by 199
- 2023Compressing Context to Enhance Inference Efficiency of Large Language Modelscited by 185
- 2023Large Language Models for Software Engineering: Survey and Open Problemscited by 178
- 2024MAGIS: LLM-Based Multi-Agent Framework for GitHub Issue Resolutioncited by 132
- 2022Repository-Level Prompt Generation for Large Language Models of Codecited by 106
- 2024LLM Hallucinations in Practical Code Generation: Phenomena, Mechanism, and Mitigationcited by 92
- 2023Towards an Understanding of Large Language Models in Software Engineering Taskscited by 67
- 2023A Survey of Large Language Models for Code: Evolution, Benchmarking, and Future Trendscited by 66
- 2022CoCoMIC: Code Completion By Jointly Modeling In-file and Cross-file Contextcited by 64
- 2024Agents in Software Engineering: Survey, Landscape, and Visioncited by 60
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completioncited by 55
- 2023No Need to Lift a Finger Anymore? Assessing the Quality of Code Generation by ChatGPTcited by 45
- 2024RLCoder: Reinforcement Learning for Repository-Level Code Completioncited by 44
- 2024Dataflow-Guided Retrieval Augmentation for Repository-Level Code Completioncited by 40
- 2021Code Completion by Modeling Flattened Abstract Syntax Trees as Graphscited by 30
- 2024Towards Understanding the Characteristics of Code Generation Errors Made by Large Language Modelscited by 28
- 2022RACE: Retrieval-Augmented Commit Message Generationcited by 27
- 2024HumanEvo: An Evolution-aware Benchmark for More Realistic Evaluation of Repository-level Code Generationcited by 26
- 2025OmniGIRL: A Multilingual and Multimodal Benchmark for GitHub Issue Resolutioncited by 24
- 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyondcited by 22
- 2024On the Impacts of Contexts on Repository-Level Code Generationcited by 21
- 2024When to Stop? Towards Efficient Code Generation in LLMs with Excess Token Preventioncited by 21
- 2024RepoTransBench: A Real-World Multilingual Benchmark for Repository-Level Code Translationcited by 21
- 2024Prompt-based Code Completion via Multi-Retrieval Augmented Generationcited by 16
- 2026RealSec-bench: A Benchmark for Evaluating Secure Code Generation in Real-World Repositoriescited by 13
- 2025RepoST: Scalable Repository-Level Coding Environment Construction with Sandbox Testingcited by 12
- 2024CoSQA+: Pioneering the Multi-Choice Code Search Benchmark with Test-Driven Agentscited by 11
- 2024You Augment Me: Exploring ChatGPT-based Data Augmentation for Semantic Code Searchcited by 11
- 2025Towards an Understanding of Context Utilization in Code Intelligencecited by 10
- 2024R2C2-Coder: Enhancing and Benchmarking Real-world Repository-level Code Completion Abilities of Code Large Language Modelscited by 9
- 2024Let the Code LLM Edit Itself When You Edit the Codecited by 8
- 2026AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completioncited by 7
- 2025SWE-Factory: Your Automated Factory for Issue Resolution Training Data and Evaluation Benchmarkscited by 6
50 most cited of 54 All 54 (JSON)
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches
- 2026Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
- 2025FastCoder: Accelerating Repository-level Code Generation via Efficient Retrieval and Verification
- 2026TICoder: A Repository-Level Code Generation Framework with Test-Driven Planning and Implementation-Aware Reuse ↗
- 2026MRCoder: An Efficient Context Selecting Approach for Repository-Level Code Generation ↗
- 2026In Line with Context: Repository-Level Code Generation via Context Inlining
- 2025RepoScope: Leveraging Call Chain-Aware Multi-View Context for Repository-Level Code Generation