通过多维度优化检索结果,提升代码补全的准确率与效率。
SaraCoder: Orchestrating Semantic and Structural Cues for Resource-Optimized Repository-Level Code Completion
- 分层特征优化模块融合语义与结构信息,增强候选代码多样性。
- 在CrossCodeEval和RepoEval-Updated上显著超越现有方法。
- 适合需要高效代码补全的开发者与研究者使用。
尽管检索增强生成提升了代码补全效果,传统检索方法在有限上下文窗口内仍面临信息冗余与多样性不足的问题。为此,我们提出资源优化的检索增强方法SaraCoder,旨在有限上下文中最大化信息多样性与代表性,显著提升仓库级代码补全的准确性与可靠性。其核心的分层特征优化模块通过提炼深层语义关系、剔除完全重复项、采用基于图的新度量评估结构相似性(权重考虑编辑的拓扑重要性),并重排序以兼顾相关性与多样性。此外,外部感知标识符消歧模块通过依赖分析精准解决跨文件符号歧义。在跨语言挑战性基准CrossCodeEval和RepoEval-Updated上的大量实验表明,SaraCoder在多种编程语言与模型上均优于现有基线。本工作证明,多维度系统化优化检索结果为构建更准确、资源高效的仓库级代码补全系统提供了新范式。
原文摘要 · Abstract (English)
Despite Retrieval-Augmented Generation improving code completion, traditional retrieval methods struggle with information redundancy and a lack of diversity within limited context windows. To solve this, we propose a resource-optimized retrieval augmentation method, SaraCoder. It maximizes information diversity and representativeness in a limited context window, significantly boosting the accuracy and reliability of repository-level code completion. Its core Hierarchical Feature Optimization module systematically refines candidates by distilling deep semantic relationships, pruning exact duplicates, assessing structural similarity with a novel graph-based metric that weighs edits by their topological importance, and reranking results to maximize both relevance and diversity. Furthermore, an External-Aware Identifier Disambiguator module accurately resolves cross-file symbol ambiguity via dependency analysis. Extensive experiments on the challenging CrossCodeEval and RepoEval-Updated benchmarks demonstrate that SaraCoder outperforms existing baselines across multiple programming languages and models. Our work proves that systematically refining retrieval results across multiple dimensions provides a new paradigm for building more accurate and resource-optimized repository-level code completion systems.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。