[论文解读] SEMAG: Self-Evolutionary Multi-Agent Code Generation
SEMAG 展现了一个自我进化的多智能体代码生成框架,能够在实时环境中自适应调整规划、调试和骨干模型,在七个基准上实现最先进的 Pass@1。
Large Language Models (LLMs) have made significant progress in handling complex programming tasks. However, current methods rely on manual model selection and fixed workflows, which limit their ability to adapt to changing task complexities. To address this, we propose SEMAG, a Self-Evolutionary Multi-Agent code Generation framework that mimics human coding practices. It decomposes programming tasks into stages, including planning, coding, debugging, and discussion, while adapting workflows to task difficulty. Its self-evolutionary agents can access the latest models in real time and automatically upgrade the backbone model. SEMAG sets new state-of-the-art Pass@1 accuracy across benchmarks. Using identical backbone models, SEMAG outperforms prior methods by 3.3% on CodeContests. When augmented with self-evolutionary model selection that automatically identifies optimal backbones, SEMAG reaches 52.6%, showcasing both framework effectiveness and adaptability to evolving LLM capabilities.
研究动机与目标
- 在基于大语言模型的代码生成中,说明对自适应、动态工作流的需求。
- 提出一个分层次的多智能体框架,根据任务复杂度调整推理深度和工作流。
- 引入自我进化机制,实时自动选择并升级骨干模型。
- 在七个文本到代码基准上展示最先进的 Pass@1 准确率,并分析效率提升。
提出的方法
- 提出一个四级分层的代码合成框架,从直接生成到多智能体精炼。
- 引入基于轨迹相似度的自适应层级切换机制,实现动态切换层级。
- 实现自我进化:并行的模型选择代理进行搜索、筛选和投票,实时选择最佳骨干模型。
- 使用规划、验证、调试和辩论代理,以及讨论–决策模块以跳出局部最优并细化解决方案。

实验结果
研究问题
- RQ1自我进化的多智能体工作流是否能够提升在多样基准上的代码生成性能?
- RQ2自适应规划深度和协同调试是否能在减少 token 使用的同时提高准确性?
- RQ3随着任务难度和模型能力演变,自动的骨干模型切换是否能维持高性能?
- RQ4在规划中包含工具使用以及各种消融对总体性能的影响是什么?
主要发现
| 模型/方法 | HumanEval(GPT-3.5) | MBPP(GPT-3.5) | HumanEval-ET(GPT-3.5) | MBPP-ET(GPT-3.5) |
|---|---|---|---|---|
| SEMAG(我们的方法) | 91.5% | 76.2% | 79.9% | 64.4% |
- SEMAG 在七个基准上实现了新的最先进 Pass@1,以 GPT-4o 为骨干(如 HumanEval 98.8% 与 MBPP 87.6%)。
- 在 CodeContests 上,SEMAG 达到 38.0% 的 Pass@1,与固定骨干基线(LPW)相比提升 3.3%,自我进化将其提升至 52.6%。
- 自适应分层提示在数据集上相较固定深度基线显著降低 token 消耗并提升准确率。
- 消融研究表明,完整的 SEMAG(Plan-Verifier-Discuss-Decide 组件)优于部分配置(如 GPT-3.5 条件下 HumanEval 的 Pass@1 为 91.5%)。
- 通过并行选择器实现的自我进化能够识别强力骨干(如 Claude-3.7-Sonnet 在 CodeContests 达到 52.6%,其他达到 48.7%~48.7%)。
- 在规划中加入工具使用带来可观增益(在 GPT-3.5 的 HumanEval 上 Pass@1 提升 3.7%)。

更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。