Impact-driven Context Filtering For Cross-file Code Completion
On the map: Retrieval-augmented generation → RAG for code
Abstract (arXiv)
Retrieval-augmented generation (RAG) has recently demonstrated considerable potential for repository-level code completion, as it integrates cross-file knowledge with in-file preceding code to provide comprehensive contexts for generation. To better understand the contribution of the retrieved cross-file contexts, we introduce a likelihood-based metric to evaluate the impact of each retrieved code chunk on the completion. Our analysis reveals that, despite retrieving numerous chunks, only a small subset positively contributes to the completion, while some chunks even degrade performance. To address this issue, we leverage this metric to construct a repository-level dataset where each retrieved chunk is labeled as positive, neutral, or negative based on its relevance to the target completion. We then propose an adaptive retrieval context filtering framework, CODEFILTER, trained on this dataset to mitigate the harmful effects of negative retrieved contexts in code completion. Extensive evaluation on the RepoEval and CrossCodeLongEval benchmarks demonstrates that CODEFILTER consistently improves completion accuracy compared to approaches without filtering operations across various tasks. Additionally, CODEFILTER significantly reduces the length of the input prompt, enhancing computational efficiency while exhibiting strong generalizability across different models. These results underscore the potential of CODEFILTER to enhance the accuracy, efficiency, and attributability of repository-level code completion.
Key facts. Cited by 5 papers in the map (data through 14 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 39 of its 47 references that are in the map. First posted on arXiv 8 Aug 2025.
Builds on
39 of 47 references.
Closest ancestors · 5
Same direction, newest first
- 2024GraphCoder: Enhancing Repository-Level Code Completion via Code Context Graph-based Retrieval and Language Model11 Jun
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completion15 Mar
- 2022BashExplainer: Retrieval-Augmented Bash Code Comment Generation based on Fine-tuned CodeBERT27 Jun
- 2022ReACC: A Retrieval-Augmented Code Completion Framework15 Mar
- 2022RACE: Retrieval-Augmented Commit Message Generation5 Mar
Other references · 34
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,297
- 2025DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learningcited by 6,330
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,944
- 2020REALM: Retrieval-Augmented Language Model Pre-Trainingcited by 2,141
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2023Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflectioncited by 1,839
- 2021Improving language models by retrieving from trillions of tokenscited by 1,293
- 2020Leveraging Passage Retrieval with Generative Models for Open Domain Question Answeringcited by 1,210
- 2024Qwen2.5-Coder Technical Reportcited by 1,203
- 2022When Not to Trust Language Models: Investigating Effectiveness of Parametric and Non-Parametric Memoriescited by 1,128
- 2023StarCoder: may the source be with you!cited by 799
- 2023REPLUG: Retrieval-Augmented Black-Box Language Modelscited by 792
22 more
- 2023In-Context Retrieval-Augmented Language Modelscited by 702
- 2023Active Retrieval Augmented Generationcited by 516
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 367
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 361
- 2022The Stack: 3 TB of permissively licensed source codecited by 359
- 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 353
- 2023CrossCodeEval: A Diverse and Multilingual Benchmark for Cross-File Code Completioncited by 183
- 2023InferFix: End-to-End Program Repair with LLMscited by 114
- 2023LongCoder: A Long-Range Pre-trained Language Model for Code Completioncited by 112
- 2021Efficient Nearest Neighbor Language Modelscited by 93
- 2023Learning to Filter Context for Retrieval-Augmented Generationcited by 83
- 2024EvoCodeBench: An Evolving Code Generation Benchmark Aligned with Real-World Code Repositoriescited by 72
- 2023Self-Knowledge Guided Retrieval Augmentation for Large Language Modelscited by 69
- 2022Repair Is Nearly Generation: Multilingual Program Repair with LLMscited by 68
- 2022CoCoMIC: Code Completion By Jointly Modeling In-file and Cross-file Contextcited by 65
- 2022When Language Model Meets Private Librarycited by 54
- 2016Deep API Learningcited by 41
- 2023SkCoder: A Sketch-based Approach for Automatic Code Generationcited by 40
- 2023RepoFusion: Training Code Models to Understand Your Repositorycited by 40
- 2024Dataflow-Guided Retrieval Augmentation for Repository-Level Code Completioncited by 40
- 2024REPOFUSE: Repository-Level Code Completion with Fused Dual Contextcited by 32
- 2024Not All Contexts Are Equal: Teaching LLMs Credibility-aware Generationcited by 21
Built on by
Citing papers per year: 2025: 1; 2026: 4.
5 papers.
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approachescited by 23
- 2026RepoShapley: Shapley-Enhanced Context Filtering for Repository-Level Code Completioncited by 3
- 2026Memory Retrieval for Changing Preferencescited by 3
- 2026Repo0: Design-Driven Zero-to-All Code Generationcited by 3
- 2026When Retrieval Hurts Code Completion: A Diagnostic Study of Stale Repository Contextcited by 1
- 2026Repo0: Design-Driven Zero-to-All Code Generation20 Aug 2026
- 2026Memory Retrieval for Changing Preferences2 Jun 2026
- 2026When Retrieval Hurts Code Completion: A Diagnostic Study of Stale Repository Context14 May 2026
- 2026RepoShapley: Shapley-Enhanced Context Filtering for Repository-Level Code Completion6 Jan 2026
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches6 Oct 2025
Similar, not cited
Close in wording, no citation either way
- 2026How Does Chunking Affect Retrieval-Augmented Code Completion? A Controlled Empirical Study
- 2025A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChat
- 2025SaraCoder: Orchestrating Semantic and Structural Cues for Resource-Optimized Repository-Level Code Completion
- 2025CodeRAG: Finding Relevant and Necessary Knowledge for Retrieval-Augmented Repository-Level Code Completion
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
- 2026AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completion
- 2024A Lightweight Framework for Adaptive Retrieval In Code Completion With Critique Model
- 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyond