CodeCoR: An LLM-Based Self-Reflective Multi-Agent Framework for Code Generation

· Source: cs.SE updates on arXiv.org · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Software Development & Engineering · Depth: Expert, quick

Summary

CodeCoR is a novel multi-agent framework designed to enhance the reliability of LLM-based code generation by mitigating error propagation. Addressing the common challenge where Large Language Models often produce syntactically or semantically incorrect code, CodeCoR introduces a pruning mechanism for intermediate outputs within its sequential workflow. The framework employs four specialized agents responsible for generating prompts, code, test cases, and repair advice. Each agent produces multiple outputs, discarding low-quality options to refine the process. Generated code undergoes local testing; failures trigger a repair cycle where the coding agent regenerates code based on repair advice. CodeCoR demonstrated superior performance on HumanEval, HumanEval-ET, MBPP, and MBPP-ET datasets, achieving an average Pass@1 score of 77.13%, outperforming existing baselines such as CodeCoT and MapCoder.

Key takeaway

For Machine Learning Engineers developing LLM-based code generation systems, CodeCoR's approach offers a robust strategy to enhance output quality. You should consider integrating intermediate output pruning and iterative self-correction mechanisms into your multi-agent frameworks. This can significantly reduce error propagation and improve the syntactic and semantic correctness of generated code, as demonstrated by CodeCoR's 77.13% Pass@1 score. Evaluate similar multi-agent architectures to boost your system's reliability.

Key insights

CodeCoR improves LLM code generation robustness by pruning intermediate outputs in a multi-agent self-reflective framework.

Principles

Method

CodeCoR uses four agents (prompt, code, test, repair) that each generate multiple outputs, prune low-quality ones, and iteratively refine code based on local test failures and repair advice.

In practice

Topics

Best for: AI Engineer, Research Scientist, AI Scientist, Machine Learning Engineer, NLP Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by cs.SE updates on arXiv.org.