arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2412.08063cs.SEcs.AI
收藏

ContextModule: 利用仓库级上下文信息提升代码补全效果

ContextModule: Improving Code Completion via Repository-level Contextual Information

ByteDance(字节跳动)

Zhanming Guan, Junlin Liu, Jierui Liu, Chao Peng, Dexin Liu, Ningyuan Sun, Bo Jiang, Wenchao Li, Jie Liu, Hang Zhu

AI总结:

针对现有代码补全系统缺仓库级上下文、检索与延迟等问题,提出ContextModule框架,整合三类上下文信息并优化性能,显著提升补全准确率与用户接受度。

摘要:

大语言模型(LLMs)在代码补全任务中展现出出色的能力,可通过实时预测和生成新代码为开发者提供辅助。然而,现有基于LLM的代码补全系统主要依赖被编辑文件的即时上下文,往往遗漏了可提升建议准确率的宝贵仓库级信息、用户行为与编辑历史。此外,从大型仓库中高效检索相关代码片段、融合用户行为,以及在生产环境中平衡准确率与低延迟要求等挑战仍未得到解决。本文提出ContextModule框架,该框架通过检索并整合仓库中的三类上下文信息——基于用户行为的代码、相似代码片段和关键符号定义——来增强基于LLM的代码补全效果。通过捕获跨文件的用户交互并利用全仓库静态分析,ContextModule提升了生成代码的相关性与精确性。我们实现了索引缓存等性能优化,确保系统满足真实编码环境的延迟约束。实验结果与工业实践表明,ContextModule显著提升了代码补全准确率和用户接受度。

英文摘要:

Large Language Models (LLMs) have demonstrated impressive capabilities in code completion tasks, where they assist developers by predicting and generating new code in real-time. However, existing LLM-based code completion systems primarily rely on the immediate context of the file being edited, often missing valuable repository-level information, user behaviour and edit history that could improve suggestion accuracy. Additionally, challenges such as efficiently retrieving relevant code snippets from large repositories, incorporating user behavior, and balancing accuracy with low-latency requirements in production environments remain unresolved. In this paper, we propose ContextModule, a framework designed to enhance LLM-based code completion by retrieving and integrating three types of contextual information from the repository: user behavior-based code, similar code snippets, and critical symbol definitions. By capturing user interactions across files and leveraging repository-wide static analysis, ContextModule improves the relevance and precision of generated code. We implement performance optimizations, such as index caching, to ensure the system meets the latency constraints of real-world coding environments. Experimental results and industrial practise demonstrate that ContextModule significantly improves code completion accuracy and user acceptance rates.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑