[논문 리뷰] Teaching Large Language Models to Self-Debug
SELF-DEBUGGING은 LLM이 몇-shot 프롬프트를 통해 자신의 생성 코드 디버깅을 배우고, 코드 실행과 자연어 설명을 활용하여 반복적으로 오류를 수정하며, Spider (text-to-SQL), TransCoder (code translation), MBPP (text-to-Python)에서 샘플 효율성을 개선한 상태 최첨단 성과를 달성합니다.
Large language models (LLMs) have achieved impressive performance on code generation. However, for complex programming tasks, generating the correct solution in one go becomes challenging, thus some prior works have designed program repair approaches to improve code generation performance. In this work, we propose Self-Debugging, which teaches a large language model to debug its predicted program via few-shot demonstrations. In particular, we demonstrate that Self-Debugging can teach the large language model to perform rubber duck debugging; i.e., without any human feedback on the code correctness or error messages, the model is able to identify its mistakes by investigating the execution results and explaining the generated code in natural language. Self-Debugging achieves the state-of-the-art performance on several code generation benchmarks, including the Spider dataset for text-to-SQL generation, TransCoder for C++-to-Python translation, and MBPP for text-to-Python generation. On the Spider benchmark where there are no unit tests to verify the correctness of predictions, Self-Debugging with code explanation consistently improves the baseline by 2-3%, and improves the prediction accuracy on problems of the hardest level by 9%. On TransCoder and MBPP where unit tests are available, Self-Debugging improves the baseline accuracy by up to 12%. Meanwhile, by leveraging feedback messages and reusing failed predictions, Self-Debugging notably improves sample efficiency, and can match or outperform baseline models that generate more than 10x candidate programs.
연구 동기 및 목표
- 추가 학습 없이 LLM이 자신의 출력물을 디버깅하도록 함으로써 코드 생성 성능 향상을 촉진한다.
- 생성, 실행, 설명 및 피드백을 사용해 코드를 반복적으로 수정하는 SELF-DEBUGGING 프레임워크를 제안한다.
- 여러 코드 생성 작업과 다양한 LLM에 걸쳐 이 접근법을 평가하여 성능 및 샘플 효율성 향상을 확립한다.
제안 방법
- 세 단계의 SELF-DEBUGGING 루프: 후보 프로그램의 생성, 코드의 설명, 정답 여부에 대한 피드백.
- 시연 데모를 제공하고 모델이 디버깅 반복을 거치도록 Few-shot 프롬프팅을 활용한다.
- 실행 결과가 있을 때 여러 샘플 중에서 실행 기반으로 최종 예측을 선택한다.
- 문제 설명에 제시된 경우 후보 프로그램을 필터링/검증하기 위해 단위 테스트를 활용한다.
- Simple Feedback, Unit Test (UT) Feedback, Code Explanation (Expl), Execution Trace (Trace) 등 피드백 형식 제공; 고무 오리 디버깅(rubber-duck debugging)과 유사한 스타일.
- 피드백이 정답 여부를 나타내거나 최대 턴 수에 도달할 때까지 반복적으로 개선한다.
실험 결과
연구 질문
- RQ1SELF-DEBUGGING이 서로 다른 LLM에서 텍스트-투-SQL, 코드 번역, 텍스트-투-파이썬 작업의 코드 생성 정확도를 향상시킬 수 있는가?
- RQ2다양한 피드백 형식(간단 피드백, 설명, 실행 추적, 단위 테스트 통합)이 성능에 어떤 영향을 미치는가?
- RQ3단위 테스트가 SELF-DEBUGGING의 효과와 샘플 효율성에 미치는 영향은 무엇인가?
- RQ4일반적으로 필요한 디버깅 턴 수는 얼마이며, 실행 피드백이 개선을 주도하는가?
주요 결과
- 여러 벤치마크에서 SOTA를 달성: Spider (text-to-SQL), TransCoder (C++-to-Python 번역), MBPP (text-to-Python).
- Spider에서(단위 테스트 없음), SELF-DEBUGGING으로 코드 설명이 정확도를 약 2–3% 향상시키고 가장 어려운 쿼리에서 최대 9%까지 향상.
- TransCoder와 MBPP(단위 테스트 포함)에서 SELF-DEBUGGING이 기본 정확도를 최대 약 12% 향상.
- 코드 설명만으로도 작업 간에 일관된 이득(대략 2–3%)을 제공하며; 단위 테스트 피드백을 추가하면 종종 더 큰 이득이 생긴다.
- SELF-DEBUGGING은 샘플 효율성을 향상시켜 10배 이상 후보 프로그램을 생성하는 베이스라인과 비슷하거나 그 이상을 능가한다.
- 효과는 모델에 따라 다르다; 실행 피드백(Trace)이 일반적으로 도움이 되며 이 접근법은 Codex, GPT-3.5, GPT-4, StarCoder에서 모두 효과적이지만 이득은 작업과 모델에 따라 다르다.
- 실행 기반 최종 예측 선택은 다수의 샘플이 있을 때 특히 성능에 기여한다.
더 나은 연구,지금 바로 시작하세요
연구 설계부터 논문 작성까지, 연구 시간을 획기적으로 줄여보세요.
카드 등록 없음 · 무료 플랜 제공
이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.