Hierarchical Context Pruning: Optimizing Real-World Code Completion with Repository-Level Pretrained Code LLMs
Lei Zhang, Yunshui Li, Jiaming Li, Xiaobo Xia, Jiaxi Yang, Run Luo,, Minzheng Wang, Longze Chen, Junhao Liu, Min Yang

TL;DR
This paper introduces Hierarchical Context Pruning (HCP), a method that improves code completion accuracy for repository-level Code LLMs by maintaining topological dependencies and reducing irrelevant code content, thus optimizing prompt length and performance.
Contribution
The paper proposes HCP, a novel strategy that models code repositories at the function level to enhance code completion accuracy and efficiency in large language models.
Findings
HCP significantly improves completion accuracy across six Repo-Code LLMs.
HCP reduces input length while maintaining high informational content.
Pruning function implementations in dependent files does not significantly impact accuracy.
Abstract
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…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
Taxonomy
TopicsService-Oriented Architecture and Web Services · Web Data Mining and Analysis · Software System Performance and Reliability
MethodsPruning
