[논문 리뷰] CodeT: Code Generation with Generated Tests
CodeT는 코드 생성을 위해 사용된 것과 동일한 사전 학습된 언어 모델로 테스트 케이스를 자동으로 생성한 다음, 여러 샘플 중 최적의 코드 해답을 선택하기 위해 이중 실행 합의를 사용하여 pass@1을 여러 벤치마크와 모델에 걸쳐 향상시킵니다.
The task of generating code solutions for a given programming problem can benefit from the use of pre-trained language models such as Codex, which can produce multiple diverse samples. However, a major challenge for this task is to select the most appropriate solution from the multiple samples generated by the pre-trained language models. A natural way to evaluate the quality and correctness of a code solution is to run it against a set of test cases, but the manual creation of such test cases is often costly and time-consuming. In this paper, we propose a novel method, CodeT, that leverages the same pre-trained language models to automatically generate test cases for the code samples, thus reducing the human effort and increasing the coverage of the test scenarios. CodeT then executes the code samples using the generated test cases, and performs a dual execution agreement, which considers both the consistency of the outputs against the generated test cases and the agreement of the outputs with other code samples. We conduct comprehensive experiments on four benchmarks, HumanEval, MBPP, APPS and CodeContests, using five different pre-trained language models with varying sizes and capabilities. Our results show that CodeT can significantly improve the performance of code solution selection over previous methods, achieving remarkable and consistent gains across different models and benchmarks. For instance, CodeT improves the pass@1 metric on HumanEval to 65.8%, which represents an absolute improvement of 18.8% over the code-davinci-002 model, and an absolute improvement of more than 20% over the previous state-of-the-art results.
연구 동기 및 목표
- 코드 생성에 사용된 것과 동일한 LM으로 자동으로 테스트 케이스를 생성하여 수동으로 작성된 테스트 케이스에 대한 의존성을 줄인다.
- 실행 기반 합의에 기반한 코드 해답 선택을 개선한다.
- 테스트 결과와 교차 해답 일관성 간의 이중 합의를 활용하여 평가의 견고성과 커버리지를 높인다.
- 제로샷 설정에서 다수의 벤치마크 및 모델 패밀리에서 효과를 시연한다.
제안 방법
- 코드 생성에 사용되는 동일한 사전 학습 LM으로 각 프로그래밍 문제의 입력-출력 쌍을 출력하도록 프롬프트를 작성하여 테스트 케이스를 생성한다.
- 레이블링된 데이터 없이 LM을 사용하여 문제 맥락에서 다수의 코드 해답 X를 생성한다.
- RANSAC에서 영감을 받은 이중 실행 합의를 적용하여 일반 테스트 케이스를 통과하고 서로 일치하는 (코드, 테스트) 쌍의 컨센서스 집합을 찾는다.
- f(S) = |Sx| * |Sy|로 컨센서스 집합의 순위를 매기고 상위 컨센서스 집합에서 최적의 코드 해답을 선택한다.
- 선택 해답을 중복 제거하고 중복 제거 여부에 따른 성능 차이를 비교한다(비교 실험에서 효과가 미미하다는 결과가 나옴).
- 생성된 테스트 케이스를 실제 정답 레이블 데이터 대신 사용하여 제로샷 설정에서 여러 벤치마크 및 LM 가족에 대해 pass@k로 평가한다.
실험 결과
연구 질문
- RQ1LM이 생성한 테스트 케이스의 질과 커버리지는 코드 선정을 얼마나 잘 이끄는가?
- RQ2이중 실행 합의가 서로 다른 모델과 벤치마크에서 올바른 해답 선택을 개선하는가?
- RQ3CodeT는 다양한 벤치마크와 모델 규모에서 제로샷 설정으로 얼마나 잘 작동하는가?
- RQ4생성되는 테스트 케이스의 수와 테스트 케이스의 질(독성, 정확성, 커버리지)에 CodeT가 얼마나 민감한가?
주요 결과
- CodeT는 벤치마크와 모델 전반에서 pass@1을 크게 향상시키며, 예를 들어 HumanEval에서 code-davinci-002를 사용할 때: 47.0%(베이스라인)에서 65.8%(CodeT)로 향상되었습니다.
- MBPP에서 code-davinci-002를 사용할 때 pass@1이 58.1%에서 67.7%로 향상되었습니다.
- APPS Introductory에서 CodeT를 사용하면 pass@1이 27.2%에서 34.6%로 향상됩니다.
- CodeContests에서 CodeT를 사용하면 pass@1이 0.7%에서 2.1%로 향상됩니다(제로샷).
- CodeT는 Codex, InCoder, CodeGen 계열 전반에서 일관된 이득을 달성하며 보고된 모든 설정에서 AlphaCode-C를 능가합니다.
- 테스트 케이스의 질(정확성, 독성, 커버리지)이 CodeT의 이득과 상관관계가 있으며, 예를 들어 code-davinci-002의 고품질 테스트 케이스가 더 큰 개선을 가져옵니다.
더 나은 연구,지금 바로 시작하세요
연구 설계부터 논문 작성까지, 연구 시간을 획기적으로 줄여보세요.
카드 등록 없음 · 무료 플랜 제공
이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.