Hierarchical Context Pruning: Optimizing Real-World Code Completion with Repository-Level Pretrained Code LLMs
Not on the map. Why?
Abstract (arXiv)
Some recently developed code large language models (Code LLMs) have been pre-trained on repository-level code data (Repo-Code LLMs), enabling these models to recognize repository structures and utilize cross-file information for code completion. However, in real-world development scenarios, simply concatenating the entire code repository often exceeds the context window limits of these Repo-Code LLMs, leading to significant performance degradation. In this study, we conducted extensive preliminary experiments and analyses on six Repo-Code LLMs. The results indicate that maintaining the topological dependencies of files and increasing the code file content in the completion prompts can improve completion accuracy; pruning the specific implementations of functions in all dependent files does not significantly reduce the accuracy of completions. Based on these findings, we proposed a strategy named Hierarchical Context Pruning (HCP) to construct completion prompts with high informational code content. The HCP models the code repository at the function level, maintaining the topological dependencies between code files while removing a large amount of irrelevant code content, significantly reduces the input length for repository-level code completion. We applied the HCP strategy in experiments with six Repo-Code LLMs, and the results demonstrate that our proposed method can significantly enhance completion accuracy while substantially reducing the length of input. Our code and data are available at https://github.com/Hambaobao/HCP-Coder.
Key facts. Cited by 13 papers in the map (data through 7 Oct 2026). Builds on 37 of its 48 references that are in the map. First posted on arXiv 26 Jun 2024.
Builds on
37 of 48 references.
References · 37
- 2022Training language models to follow instructions with human feedbackcited by 15,712
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,193
- 2023Efficient Streaming Language Models with Attention Sinkscited by 2,115
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2024SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineeringcited by 1,628
- 2022Competition-Level Code Generation with AlphaCodecited by 1,427
- 2023LongBench: A Bilingual, Multitask Benchmark for Long Context Understandingcited by 1,378
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
- 2021Measuring Coding Challenge Competence With APPScited by 879
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
25 more
- 2023StarCoder: may the source be with you!cited by 790
- 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
- 2023Extending Context Window of Large Language Models via Positional Interpolationcited by 721
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
- 2022DS-1000: A Natural and Reliable Benchmark for Data Science Code Generationcited by 442
- 2023How Far Can Camels Go? Exploring the State of Instruction Tuning on Open Resourcescited by 405
- 2024∞Bench: Extending Long Context Evaluation Beyond 100K Tokenscited by 360
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
- 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 346
- 2024LongRoPE: Extending LLM Context Window Beyond 2 Million Tokenscited by 302
- 2022Efficient Training of Language Models to Fill in the Middlecited by 248
- 2024OpenCodeInterpreter: Integrating Code Generation with Execution and Refinementcited by 242
- 2023InterCode: Standardizing and Benchmarking Interactive Coding with Execution Feedbackcited by 229
- 2023CrossCodeEval: A Diverse and Multilingual Benchmark for Cross-File Code Completioncited by 181
- 2023Self-Taught Optimizer (STOP): Recursively Self-Improving Code Generationcited by 128
- 2024LLM Agents can Autonomously Hack Websitescited by 108
- 2022Repository-Level Prompt Generation for Large Language Models of Codecited by 106
- 2022Execution-Based Evaluation for Open-Domain Code Generationcited by 89
- 2023An In-Context Learning Agent for Formal Theorem-Provingcited by 78
- 2023Lemur: Harmonizing Natural Language and Code for Language Agentscited by 71
- 2024EvoCodeBench: An Evolving Code Generation Benchmark Aligned with Real-World Code Repositoriescited by 71
- 2024Iterative Refinement of Project-Level Code Context for Precise Code Generation with Compiler Feedbackcited by 45
- 2024REPOFUSE: Repository-Level Code Completion with Fused Dual Contextcited by 32
- 2023L2MAC: Large Language Model Automatic Computer for Extensive Code Generationcited by 30
- 2023CoderEval: A Benchmark of Pragmatic Code Generation with Generative Pre-trained Modelscited by 28
Built on by
Citing papers per year: 2024: 1; 2025: 7; 2026: 5.
13 papers.
Sort:
By area:
- 2026SWE-Pruner: Self-Adaptive Context Pruning for Coding Agentscited by 40
- 2025Understanding and Enhancing the Transferability of Jailbreaking Attackscited by 22
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approachescited by 20
- 2025Continual Multimodal Contrastive Learningcited by 19
- 2026In Line with Context: Repository-Level Code Generation via Context Inliningcited by 18
- 2025L-MTP: Leap Multi-Token Prediction Beyond Adjacent Context for Large Language Modelscited by 14
- 2025OpenOmni: Advancing Open-Source Omnimodal Large Language Models with Progressive Multimodal Alignment and Real-Time Self-Aware Emotional Speech Synthesiscited by 10
- 2025Exploring the Challenges and Opportunities of AI-assisted Codebase Generationcited by 4
- 2025SpecAgent: A Speculative Retrieval and Forecasting Agent for Code Completioncited by 3
- 2024FDC: Fast KV Dimensionality Compression for Efficient LLM Inferencecited by 2
- 2026MHRC-Bench: A Multilingual Hardware Repository-Level Code Completion benchmarkcited by 1
- 2026Beyond Scaling: Self-Evolving LLM Agents for Hardware Kernel Optimization via an Experience-Driven Workflow and Experience Graph Memorycited by 0
- 2026VibeMemBench: Evaluating Memory Systems for Coding Agents on Real Repository Coding Tasks20 Sep 2026
- 2026Beyond Scaling: Self-Evolving LLM Agents for Hardware Kernel Optimization via an Experience-Driven Workflow and Experience Graph Memory26 Aug 2026
- 2026SWE-Pruner: Self-Adaptive Context Pruning for Coding Agents23 Jan 2026
- 2026MHRC-Bench: A Multilingual Hardware Repository-Level Code Completion benchmark7 Jan 2026
- 2026In Line with Context: Repository-Level Code Generation via Context Inlining1 Jan 2026
- 2025SpecAgent: A Speculative Retrieval and Forecasting Agent for Code Completion20 Oct 2025
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches6 Oct 2025
- 2025Exploring the Challenges and Opportunities of AI-assisted Codebase Generation11 Aug 2025
- 2025L-MTP: Leap Multi-Token Prediction Beyond Adjacent Context for Large Language Models23 May 2025
- 2025Continual Multimodal Contrastive Learning19 Mar 2025
- 2025Understanding and Enhancing the Transferability of Jailbreaking Attacks5 Feb 2025
- 2025OpenOmni: Advancing Open-Source Omnimodal Large Language Models with Progressive Multimodal Alignment and Real-Time Self-Aware Emotional Speech Synthesis8 Jan 2025
1 more
- 2026SWE-Pruner: Self-Adaptive Context Pruning for Coding Agentscited by 40
- 2025SpecAgent: A Speculative Retrieval and Forecasting Agent for Code Completioncited by 3
- 2026Beyond Scaling: Self-Evolving LLM Agents for Hardware Kernel Optimization via an Experience-Driven Workflow and Experience Graph Memorycited by 0
- 2026VibeMemBench: Evaluating Memory Systems for Coding Agents on Real Repository Coding Taskscited by 0
- 2026VibeMemBench: Evaluating Memory Systems for Coding Agents on Real Repository Coding Tasks20 Sep 2026
- 2026Beyond Scaling: Self-Evolving LLM Agents for Hardware Kernel Optimization via an Experience-Driven Workflow and Experience Graph Memory26 Aug 2026
- 2026SWE-Pruner: Self-Adaptive Context Pruning for Coding Agents23 Jan 2026
- 2025SpecAgent: A Speculative Retrieval and Forecasting Agent for Code Completion20 Oct 2025
- 2025Continual Multimodal Contrastive Learningcited by 19
- 2026In Line with Context: Repository-Level Code Generation via Context Inliningcited by 18
- 2025L-MTP: Leap Multi-Token Prediction Beyond Adjacent Context for Large Language Modelscited by 14
- 2025Exploring the Challenges and Opportunities of AI-assisted Codebase Generationcited by 4
- 2026MHRC-Bench: A Multilingual Hardware Repository-Level Code Completion benchmarkcited by 1
- 2026MHRC-Bench: A Multilingual Hardware Repository-Level Code Completion benchmark7 Jan 2026
- 2026In Line with Context: Repository-Level Code Generation via Context Inlining1 Jan 2026
- 2025Exploring the Challenges and Opportunities of AI-assisted Codebase Generation11 Aug 2025
- 2025L-MTP: Leap Multi-Token Prediction Beyond Adjacent Context for Large Language Models23 May 2025
- 2025Continual Multimodal Contrastive Learning19 Mar 2025