[논문 리뷰] AgentCoder: Multi-Agent-based Code Generation with Iterative Testing and Optimisation
AgentCoder는 코드와 테스트를 반복적으로 생성하고, 로컬에서 실행하며, 실행 피드백을 기반으로 개선하는 세 가지 에이전트 프레임워크를 도입하여 단일 에이전트 및 기본 방법을 여러 데이터셋과 LLM에서 능가합니다.
The advancement of natural language processing (NLP) has been significantly boosted by the development of transformer-based large language models (LLMs). These models have revolutionized NLP tasks, particularly in code generation, aiding developers in creating software with enhanced efficiency. Despite their advancements, challenges in balancing code snippet generation with effective test case generation and execution persist. To address these issues, this paper introduces Multi-Agent Assistant Code Generation (AgentCoder), a novel solution comprising a multi-agent framework with specialized agents: the programmer agent, the test designer agent, and the test executor agent. During the coding procedure, the programmer agent will focus on the code generation and refinement based on the test executor agent's feedback. The test designer agent will generate test cases for the generated code, and the test executor agent will run the code with the test cases and write the feedback to the programmer. This collaborative system ensures robust code generation, surpassing the limitations of single-agent models and traditional methodologies. Our extensive experiments on 9 code generation models and 12 enhancement approaches showcase AgentCoder's superior performance over existing code generation models and prompt engineering techniques across various benchmarks. For example, AgentCoder (GPT-4) achieves 96.3\% and 91.8\% pass@1 in HumanEval and MBPP datasets with an overall token overhead of 56.9K and 66.3K, while state-of-the-art obtains only 90.2\% and 78.9\% pass@1 with an overall token overhead of 138.2K and 206.5K.
연구 동기 및 목표
- 코드와 테스트 품질을 함께 최적화하는 견고한 코드 생성의 필요성을 제시합니다.
- 코드 생성, 테스트 설계, 실행 간의 관심사를 분리하는 다중 에이전트 아키텍처를 제안합니다.
- 에이전트 간 협업이 단일 에이전트 설정보다 코드 정확성과 테스트 커버리지를 높인다는 것을 입증합니다.
제안 방법
- 시퀀스로 작동하는 세 가지 전문 에이전트: 코드 생성을 담당하는 프로그래머 에이전트, 다양한 테스트 케이스를 생성하는 테스트 디자이너 에이전트, 로컬 실행 및 피드백을 담당하는 테스트 실행자 에이전트.
- 프로그래머 에이전트는 Chain-of-Thought 프롬프트를 사용하여 단계별 프로그래밍을 시뮬레이션합니다: 이해, 알고리즘 선택, 의사코드, 구현.
- 테스트 디자이너 에이전트는 기본 테스트, 경계 테스트 및 대규모 테스트를 생성하도록 프롬프트됩니다.
- 테스트 실행자 에이전트는 디자이너의 테스트와 함께 로컬 환경에서 코드를 실행하고 런타임 및 어설션 피드백을 반환하여 개선을 촉진합니다.
- 모든 테스트가 통과하거나 예산이 소진될 때까지 반복 루프가 지속됩니다.
- 평가는 네 가지 데이터셋(HumanEval, MBPP 및 확장 버전)을 포함한 12개 LLM 및 13개 최적화 방식에 걸쳐 네 가지 데이터셋에서 수행됩니다.

실험 결과
연구 질문
- RQ1RQ1: AgentCoder가 기본 LLM 및 baselines와 비교하여 어떻게 수행합니까?
- RQ2RQ2: 세 가지 에이전트가 효과성에 어떻게 기여합니까?
- RQ3RQ3: 코드 정제 반복이 성능에 어떤 영향을 줍니까?
- RQ4RQ4: 테스트 디자이너 에이전트가 생성한 테스트의 정확성은 얼마나 됩니까?
- RQ5RQ5: 코드 커버리지 측면에서 테스트의 적합성은 얼마나 됩니까?
- RQ6RQ6: 프로그래머와 테스트 디자이너 역할을 서로 다른 에이전트로 분리하는 것이 바람직합니까?
주요 결과
- AgentCoder는 모든 데이터셋과 모델에서 일관되게 기본 LLM 및 최적화 baselines를 능가합니다.
- GPT-4를 사용할 때 AgentCoder는 데이터셋 전반에서 평균 pass@1이 91.5%에 달합니다(단독 GPT-4는 59.7%).
- AgentCoder는 GPT-3.5-turbo를 크게 향상시킵니다: HumanEval 및 MBPP에서 79.9% pass@1, GPT-3.5-turbo 단독의 57.3%와 비교됩니다.
- 테스트 디자이너 에이전트는 테스트 케이스를 매우 정확하게 생성합니다(HumanEval 87.8%, MBPP 89.9%) 및 높은 코드 커버리지(First-five 테스트 84.7–87.5%).
- 단일 에이전트 설정은 pass@1, 테스트 정확도 및 테스트 커버리지 측면에서 다중 에이전트 설계보다 성능이 낮습니다.
- 앳레이션은 코드 생성 및 테스트 디자인 역할을 분리하는 것이 통합된 단일 에이전트 구성보다 상당한 성능 향상을 가져옴을 보여줍니다.

이 논문 읽기
누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.
누빈트에서 이 논문 읽기이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.