通过相对位置编码的代码块分割,提升仓库级代码补全效果
Relative Positioning Based Code Chunking Method For Rich Context Retrieval In Repository Level Code Completion Task With Code Language Model
- 将代码库分块并保留相对位置信息以构建上下文
- 相比原始上下文,补全准确率显著提升
- 适合需要精准上下文理解的代码生成场景
代码补全能提升开发效率,缩短开发周期。尽管现代集成开发环境(IDE)已支持代码补全,但如何基于IDE提供的信息确定高质量上下文仍缺乏研究,尤其针对大语言模型(LLMs)在代码补全任务中的表现。本文提出一种有效的上下文构建策略,旨在提升LLMs在代码补全任务中的性能。核心思路是将代码仓库预处理为较小的代码块,并基于语法与语义相似性进行检索,同时保留代码块间的相对位置信息。实验表明,采用代码块分割与相对位置编码的上下文构建方式,显著提升了代码补全任务的性能。
原文摘要 · Abstract (English)
Code completion can help developers improve efficiency and ease the development lifecycle. Although code completion is available in modern integrated development environments (IDEs), research lacks in determining what makes a good context for code completion based on the information available to the IDEs for the large language models (LLMs) to perform better. In this paper, we describe an effective context collection strategy to assist the LLMs in performing better at code completion tasks. The key idea of our strategy is to preprocess the repository into smaller code chunks and later use syntactic and semantic similarity-based code chunk retrieval with relative positioning. We found that code chunking and relative positioning of the chunks in the final context improve the performance of code completion tasks.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。