대규모 언어 모델에 의한 코드 완성의 정적 평가
A Static Evaluation of Code Completion by Large Language Models
June 5, 2023
저자: 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
cs.AI
초록
코드를 학습한 대규모 언어 모델은 소프트웨어 개발자의 생산성을 높이는 데 큰 잠재력을 보여주고 있다. 단순한 프로그래밍 문제에서 모델이 생성한 코드의 기능적 정확성을 평가하기 위해 여러 실행 기반 벤치마크가 제안되었다. 그러나 복잡한 실제 프로젝트에서 동일한 평가를 수행하는 것은 실행 비용을 고려할 때 비용이 많이 든다. 반면, 프로그램을 실행하지 않고도 오류를 감지할 수 있는 린터(linter)와 같은 정적 분석 도구는 코드 생성 모델을 평가하는 데 잘 활용되지 않았다. 본 연구에서는 추상 구문 트리(Abstract Syntax Tree)를 활용하여 파이썬 코드 완성에서 발생하는 정적 오류를 정량화하는 정적 평가 프레임워크를 제안한다. 실행 기반 평가와 비교하여 우리의 방법은 더 효율적일 뿐만 아니라 실제 환경의 코드에도 적용 가능하다. 실험을 위해 오픈소스 저장소에서 코드 컨텍스트를 수집하여 공개 모델을 사용해 100만 개의 함수 본문을 생성했다. 정적 분석 결과, 언어 모델이 만드는 오류 중에서 '정의되지 않은 이름(Undefined Name)'과 '사용되지 않은 변수(Unused Variable)'가 가장 흔한 오류로 나타났다. 또한, 광범위한 연구를 통해 샘플링 온도, 모델 크기, 컨텍스트가 코드 완성에서의 정적 오류에 미치는 영향을 보여준다.
English
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.