arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2306.03203cs.CLcs.SE
收藏

大型语言模型代码补全的静态评估

A Static Evaluation of Code Completion by Large Language Models

AWS AI Labs(AWS人工智能实验室)
Hantian Ding, Varun Kumar, Yuchen Tian, Zijian Wang, Rob Kwiatkowski, Xiaopeng Li, Murali Krishna Ramanathan, Baishakhi Ray, Parminder Bhatia, Sudipta Sengupta,… 展开作者

Hantian Ding, Varun Kumar, Yuchen Tian, Zijian Wang, Rob Kwiatkowski, Xiaopeng Li, Murali Krishna Ramanathan, Baishakhi Ray, Parminder Bhatia, Sudipta Sengupta, Dan Roth, Bing Xiang

AI总结:

本文提出基于抽象语法树的 Python 代码补全静态评估框架,通过百万函数体实验高效识别常见静态错误,并分析温度、模型规模与上下文的影响。

摘要:

在代码上训练的大型语言模型已展现出提高软件开发人员生产力的巨大潜力。已有若干基于执行的基准被提出,用于评估模型在简单编程问题上生成代码的功能正确性。然而,考虑到执行成本,在复杂的真实世界项目上进行同样的评估代价高昂。相比之下,诸如 linter 这类无需运行程序即可检测错误的静态分析工具,尚未在评估代码生成模型方面得到充分探索。在本研究中,我们提出一个静态评估框架,通过利用抽象语法树(Abstract Syntax Trees)来量化 Python 代码补全中的静态错误。与基于执行的评估相比,我们的方法不仅更高效,而且适用于真实环境中的代码。在实验方面,我们从开源仓库收集代码上下文,使用公开模型生成一百万个函数体。我们的静态分析表明,Undefined Name 和 Unused Variable 是语言模型所犯各类错误中最常见的错误。通过大量研究,我们还展示了采样温度、模型规模和上下文对代码补全中静态错误的影响。

英文摘要:

Large language models trained on code have shown great potential to increase productivity of software developers. Several execution-based benchmarks have been proposed to evaluate functional correctness of model-generated code on simple programming problems. Nevertheless, it is expensive to perform the same evaluation on complex real-world projects considering the execution cost. On the contrary, static analysis tools such as linters, which can detect errors without running the program, haven't been well explored for evaluating code generation models. In this work, we propose a static evaluation framework to quantify static errors in Python code completions, by leveraging Abstract Syntax Trees. Compared with execution-based evaluation, our method is not only more efficient, but also applicable to code in the wild. For experiments, we collect code context from open source repos to generate one million function bodies using public models. Our static analysis reveals that Undefined Name and Unused Variable are the most common errors among others made by language models. Through extensive studies, we also show the impact of sampling temperature, model size, and context on static errors in code completions.

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

↑