[논문 리뷰] Code Generation Tools (Almost) for Free? A Study of Few-Shot, Pre-Trained Language Models on Code
이 논문은 Codex 기반의 few-shot 도구를 세 가지 코드 생성 작업에 대해 평가하고 이를 수동으로 구축된 도구와 비교하며, 모델 기반 도구가 개발 노력을 상당히 줄여도 전통 도구를 보완, 일치, 또는 능가할 수 있음을 시사한다.
Few-shot learning with large-scale, pre-trained language models is a powerful way to answer questions about code, e.g., how to complete a given code example, or even generate code snippets from scratch. The success of these models raises the question whether they could serve as a basis for building a wide range code generation tools. Traditionally, such tools are built manually and separately for each task. Instead, few-shot learning may allow to obtain different tools from a single pre-trained language model by simply providing a few examples or a natural language description of the expected tool behavior. This paper studies to what extent a state-of-the-art, pre-trained language model of code, Codex, may serve this purpose. We consider three code manipulation and code generation tasks targeted by a range of traditional tools: (i) code mutation; (ii) test oracle generation from natural language documentation; and (iii) test case generation. For each task, we compare few-shot learning to a manually built tool. Our results show that the model-based tools complement (code mutation), are on par (test oracle generation), or even outperform their respective traditionally built tool (test case generation), while imposing far less effort to develop them. By comparing the effectiveness of different variants of the model-based tools, we provide insights on how to design an appropriate input ("prompt") to the model and what influence the size of the model has. For example, we find that providing a small natural language description of the code generation task is an easy way to improve predictions. Overall, we conclude that few-shot language models are surprisingly effective, yet there is still more work to be done, such as exploring more diverse ways of prompting and tackling even more involved tasks.
연구 동기 및 목표
- 다양한 범주에 걸친 코드 생성 작업에 대해 few-shot, 사전 학습된 언어 모델이 일반 도구로 기능할 수 있는지 평가한다.
- 코드 변형, 자연어에서의 테스트 오라클 생성, 그리고 테스트 케이스 생성을 위한 모델 기반 도구를 수동으로 구축된 도구와 비교한다.
- 프롬프트 설계와 모델 크기가 이러한 도구의 효과에 어떤 영향을 미치는지 분석한다.
제안 방법
- 최신 코드 언어 모델(Codex)을 세 가지 작업에 적용: 코드 변형, 자연어 문서에서의 테스트 오라클 생성, 그리고 테스트 케이스 생성.
- few-shot 프롬프트와 경량의 자연어 설명을 사용하여 도구 동작의 프로토타입을 만들다.
- 효율성과 개발 노력 면에서 모델 기반 도구를 전통적이고 수작업으로 구축된 도구와 비교한다.
- 프롬프트 설계의 다양한 변형과 모델 크기가 성능에 미치는 영향을 조사한다.
실험 결과
연구 질문
- RQ1Codex 기반의 few-shot 도구가 코드 변형, 테스트 오라클 생성, 그리고 테스트 케이스 생성을 위한 전통 도구와 대등하거나 능가할 수 있는가?
- RQ2작업 전반에 걸쳐 NL 설명을 포함한 프롬프트 설계가 모델이 생성한 코드의 품질에 미치는 영향은 무엇인가?
- RQ3모델 크기가 few-shot 코드 생성 도구의 효과성에 어떤 영향을 미치는가?
주요 결과
- 모델 기반 도구는 전통적인 코드 변형 도구를 보완한다.
- 자연어 문서에서의 테스트 오라클 생성을 위한 모델 기반 도구는 전통적 도구와 동등하다.
- 모델 기반 도구는 테스트 케이스 생성에서 전통적 도구를 능가할 수 있으며, 개발 노력이 크게 감소한다.
- 작업에 대한 작은 자연어 설명을 제공하면 예측이 향상된다.
- 다양한 프롬프트 변형과 모델 크기가 효율성에 영향을 주어 프롬프트 최적화 및 더 큰/더 작은 모델 탐색의 여지가 있음을 시사한다.
이 논문 읽기
누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.
누빈트에서 이 논문 읽기이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.