[Paper Review] REPOFUSE: Repository-Level Code Completion with Fused Dual Context
RepoFuse introduces a novel repository-level code completion framework that fuses analogy and rationale contexts using rank truncated generation (RTG) to deliver high-accuracy code completions with reduced inference latency. It achieves a 59.75% improvement in exact match accuracy and a 26.8% speedup over prior methods while using only 75.4% of the context length.
The success of language models in code assistance has spurred the proposal of repository-level code completion as a means to enhance prediction accuracy, utilizing the context from the entire codebase. However, this amplified context can inadvertently increase inference latency, potentially undermining the developer experience and deterring tool adoption - a challenge we termed the Context-Latency Conundrum. This paper introduces REPOFUSE, a pioneering solution designed to enhance repository-level code completion without the latency trade-off. REPOFUSE uniquely fuses two types of context: the analogy context, rooted in code analogies, and the rationale context, which encompasses in-depth semantic relationships. We propose a novel rank truncated generation (RTG) technique that efficiently condenses these contexts into prompts with restricted size. This enables REPOFUSE to deliver precise code completions while maintaining inference efficiency. Through testing with the CrossCodeEval suite, REPOFUSE has demonstrated a significant leap over existing models, achieving a 40.90% to 59.75% increase in exact match (EM) accuracy for code completions and a 26.8% enhancement in inference speed. Beyond experimental validation, REPOFUSE has been integrated into the workflow of a large enterprise, where it actively supports various coding tasks.
Motivation & Objective
- To address the Context-Latency Conundrum in repository-level code completion, where richer context increases inference latency.
- To improve code completion accuracy by leveraging two complementary types of cross-file context: analogy and rationale context.
- To enable efficient, low-latency code completion by compressing relevant context into concise prompts using a novel prompt construction technique.
- To validate the approach on real-world benchmarks and in production-scale enterprise workflows.
Proposed method
- RepoFuse extracts two types of cross-file context: analogy context from code similarity analysis and rationale context from semantic relationships in classes and APIs.
- It employs a rank truncated generation (RTG) technique to filter and condense the most relevant context into a compact prompt, minimizing token usage.
- The method integrates few-shot prompting with the fused context to guide the language model for accurate code completion.
- RTG dynamically ranks and truncates context snippets based on relevance to the current code completion task, ensuring high precision within limited context windows.
- The framework is designed to be compatible with existing code LMs, avoiding the need for retraining or fine-tuning.
- It was evaluated using the CrossCodeEval benchmark and deployed in a large enterprise setting to validate real-world performance.
Experimental results
Research questions
- RQ1Can fusing analogy and rationale contexts improve code completion accuracy without increasing inference latency?
- RQ2How effective is rank truncated generation (RTG) in compressing repository-level context while preserving predictive performance?
- RQ3To what extent can RepoFuse reduce context length and inference time compared to existing retrieval-augmented code completion methods?
- RQ4Can the proposed method maintain high accuracy in real-world enterprise development environments?
Key findings
- RepoFuse achieves a 40.90% to 59.75% improvement in exact match (EM) accuracy over state-of-the-art models on the CrossCodeEval benchmark.
- It improves inference speed by 26.8% compared to traditional context-based methods, enhancing real-time usability.
- The model uses only 75.4% of the context length typically required by other methods, significantly reducing prompt size.
- RepoFuse has been successfully integrated into a large enterprise’s software development pipeline, demonstrating production readiness.
- The approach maintains high accuracy while avoiding the computational cost of retraining large language models.
- The method shows strong generalization, with measurable gains in both accuracy and efficiency across diverse code completion scenarios.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.