arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2510.01379cs.SE
收藏

多LLM协同生成高质量代码:利用互补模型优势

Multi-LLM Orchestration for High-Quality Code Generation: Exploiting Complementary Model Strengths

Chinese Academy of Science(中国科学院);University of Arizona(亚利桑那大学);Wuhan University(武汉大学);East Carolina University(东卡罗来纳大学);University of Georgia(佐治亚大学);University of Waterloo(滑铁卢大学)

Huashan Chen, Zhenyu Qi, Haotang Li, Hong Chen, Jinfu Chen, Kebin Peng, In Kee Kim, Kyu Hyung Lee, Sen He, Weiyi Shang

AI总结:

本文提出PerfOrch系统,通过分阶段、分类别的多模型协作提升代码生成质量,利用Memory模块选择最适合的模型,实现高准确率和效率。

摘要:

大型语言模型(LLMs)已成为自动化代码生成的核心,但现有方法局限于单一LLM范式。本文观察到不同LLM具有互补优势:无单一模型在所有编程语言、算法问题类别或开发阶段占优。多LLM协作,按阶段和类别路由而非多数投票,生成更高质量代码。基于此,提出PerfOrch多智能体协作系统,将代码生成分解为四个协作代理:分类、生成、调试和优化。每个代理维护Memory模块:一个按编程语言和问题类别索引的排名矩阵,通过离线分析构建并在运行时用于选择最适合的模型。在HumanEval-X和EffiBench-X两个基准上评估PerfOrch,总计2500个问题,覆盖五种语言(Python、Java、C++、Go和Rust)。PerfOrch在HumanEval-X上达到97.19%的pass@1率,在EffiBench-X上达到95.83%的pass@1率,比最强单模型流程在各语言上提升1.22-14.58个百分点。值得注意的是,仅通过HumanEval-X分析构建的Memory排名能泛化到完全未见过的EffiBench-X基准,证明PerfOrch利用的互补优势是模型属性而非特定问题分布的产物。此外,PerfOrch在61-90%的解决问题上提高执行时间,平均加速4.7-29.9%,在约一半的token成本下达到全面多模型评估的优化覆盖。

英文摘要:

Large Language Models (LLMs) are central to automated code generation, yet most approaches use one model at every stage, from writing code to repairing and optimizing it. LLMs have complementary strengths: their failures do not fully overlap across programming languages, algorithmic categories, and development stages. For example, in Python, the model with the highest code-generation accuracy ranks last at code repair. Using one model to generate code, another to repair it, and a third to refine it can therefore achieve higher correctness and better execution performance than a single model throughout. We propose PerfOrch, a multi-LLM multi-agent system with four agents for categorization, generation, debugging, and refinement. The generation, debugging, and refinement agents select models through a Memory module that ranks candidate LLMs by their measured performance for each stage, programming language, and algorithmic category. We evaluate PerfOrch with five candidate LLMs on 4,640 problems from four benchmarks covering five programming languages (HumanEval-X, EffiBench-X, BigCodeBench, and APPS) against single-model direct generation, single-model generate-debug-refine pipelines (PerfCodeGen), and the state-of-the-art multi-agent systems MapCoder and CodeSIM. PerfOrch achieves the highest pass@1 in all twelve benchmark-language settings, exceeding the strongest baseline by an average of 8.19 percentage points, and reduces execution time for an average of 75.03% of solved problems with an average speedup of 1.18x. The Memory rankings remain effective on three unseen benchmarks without re-profiling. Sequential refinement matches exhaustive execution-time refinement coverage with 66% fewer refinement-stage tokens (57% for average-memory optimization). The complementary strengths persist after all five LLMs are replaced with their current-generation successors.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑