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

分治与共识相结合:释放函数在代码生成中的潜力

Divide-and-Conquer Meets Consensus: Unleashing the Power of Functions in Code Generation

Harbin Institute of Technology(哈尔滨工业大学);Zhejiang University(浙江大学)

Jingchang Chen, Hongxuan Tang, Zheng Chu, Qianglong Chen, Zekun Wang, Ming Liu, Bing Qin

AI总结:

针对大语言模型生成复杂代码的难题,提出融合分治策略与函数共识的FunCoder框架,通过递归拆分子函数、行为共识纠错,在多个基准上实现性能提升,小模型效果尤为显著。

摘要:

尽管大语言模型近期在代码生成领域取得了进展,但它们在生成满足复杂需求的程序时仍存在困难。现有研究采用“规划-求解”分解法降低复杂度,并利用自测试优化生成的程序,但提前规划深层需求颇具挑战,且自测试需要足够准确才能实现自我改进。为此,我们提出FunCoder——一种融合分治策略与函数共识的代码生成框架。具体而言,FunCoder在代码生成过程中以树形层级结构递归拆分子函数作为更小的目标,再将这些子函数组合以实现更复杂的目标。此外,我们通过识别程序行为的相似性形成共识来确定函数,从而缓解错误传播问题。在GPT-3.5和GPT-4上,FunCoder在HumanEval、MBPP、xCodeEval和MATH基准上的表现平均优于现有最优方法9.8%。此外,我们的方法在小模型上也展现出优势:借助FunCoder,StableCode-3b在HumanEval上的表现超过GPT-3.5 18.6%,达到GPT-4性能的97.7%。进一步分析表明,我们提出的动态函数分解能够处理复杂需求,且函数共识在正确性评估上优于自测试。

英文摘要:

Despite recent progress made by large language models in code generation, they still struggle with programs that meet complex requirements. Recent work utilizes plan-and-solve decomposition to decrease the complexity and leverage self-tests to refine the generated program. Yet, planning deep-inside requirements in advance can be challenging, and the tests need to be accurate to accomplish self-improvement. To this end, we propose FunCoder, a code generation framework incorporating the divide-and-conquer strategy with functional consensus. Specifically, FunCoder recursively branches off sub-functions as smaller goals during code generation, represented by a tree hierarchy. These sub-functions are then composited to attain more complex objectives. Additionally, we designate functions via a consensus formed by identifying similarities in program behavior, mitigating error propagation. FunCoder outperforms state-of-the-art methods by +9.8% on average in HumanEval, MBPP, xCodeEval and MATH with GPT-3.5 and GPT-4. Moreover, our method demonstrates superiority on smaller models: With FunCoder, StableCode-3b surpasses GPT-3.5 by +18.6% and achieves 97.7% of GPT-4's performance on HumanEval. Further analysis reveals that our proposed dynamic function decomposition is capable of handling complex requirements, and the functional consensus prevails over self-testing in correctness evaluation.

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

↑