arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2212.10007cs.CLcs.SE
收藏

CoCoMIC:通过联合建模文件内和跨文件上下文进行代码补全

CoCoMIC: Code Completion By Jointly Modeling In-file and Cross-file Context

Columbia University(哥伦比亚大学);AWS AI Labs(AWS人工智能实验室)

Yangruibo Ding, Zijian Wang, Wasi Uddin Ahmad, Murali Krishna Ramanathan, Ramesh Nallapati, Parminder Bhatia, Dan Roth, Bing Xiang

AI总结:

针对代码补全仅依赖文件内上下文而忽略跨文件上下文的问题,提出 CoCoMIC 框架,利用 CCFINDER 检索跨文件上下文并联合建模,使精确匹配相对提升 33.94%,标识符匹配提升 28.69%。

摘要:

尽管用于代码的预训练语言模型(LM)在代码补全中取得了巨大成功,但它们生成代码时仅以文件内的内容为条件,即文件内上下文,却忽略了同一项目中其他文件中的丰富语义,即跨文件上下文,这是在现代模块化软件开发中尤为有用的关键信息源。这种忽视限制了代码语言模型在代码补全中的能力,导致意外行为,如生成幻觉类成员函数或带有意外参数的函数调用。在这项工作中,我们开发了一个跨文件上下文查找工具 CCFINDER,它能有效地定位并检索最相关的跨文件上下文。我们提出了 CoCoMIC,这是一个在预训练代码 LM 之上结合跨文件上下文来联合学习文件内和跨文件上下文的框架。当提供跨文件上下文时,CoCoMIC 成功地改进了现有的代码 LM,在代码补全的精确匹配上实现了 33.94% 的相对提升,在标识符匹配上实现了 28.69% 的相对提升。

英文摘要:

While pre-trained language models (LM) for code have achieved great success in code completion, they generate code conditioned only on the contents within the file, i.e., in-file context, but ignore the rich semantics in other files within the same project, i.e., cross-file context, a critical source of information that is especially useful in modern modular software development. Such overlooking constrains code language models' capacity in code completion, leading to unexpected behaviors such as generating hallucinated class member functions or function calls with unexpected arguments. In this work, we develop a cross-file context finder tool, CCFINDER, that effectively locates and retrieves the most relevant cross-file context. We propose CoCoMIC, a framework that incorporates cross-file context to learn the in-file and cross-file context jointly on top of pretrained code LMs. CoCoMIC successfully improves the existing code LM with a 33.94% relative increase in exact match and a 28.69% relative increase in identifier matching for code completion when the cross-file context is provided.

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

↑