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

使用 AlphaCodium 进行代码生成:从提示工程到流程工程

Code Generation with AlphaCodium: From Prompt Engineering to Flow Engineering

CodiumAI

Tal Ridnik, Dedy Kredo, Itamar Friedman

AI总结:

本文提出 AlphaCodium 测试驱动多阶段迭代流程,将 GPT-4 在 CodeContests 上的 pass@5 准确率从 19% 提升至 44%,实现从提示工程到流程工程的转变。

摘要:

代码生成问题与常见的自然语言问题不同——它们需要精确匹配目标语言的语法,识别正常路径和边界情况,关注问题规范中的大量小细节,并处理其他代码特有的问题和要求。因此,许多在自然语言生成中取得成功的优化和技巧可能对代码任务无效。在这项工作中,我们提出了一种利用大语言模型(LLM)进行代码生成的新方法,我们称之为 AlphaCodium——一种基于测试的、多阶段的、面向代码的迭代流程,可提升 LLM 在代码问题上的表现。我们在一个名为 CodeContests 的具有挑战性的代码生成数据集上测试了 AlphaCodium,该数据集包含来自 Codeforces 等平台的竞赛编程问题。所提出的流程一致且显著地改善了结果。例如,在验证集上,GPT-4 的准确率(pass@5)从使用单一精心设计的直接提示时的 19% 提高到使用 AlphaCodium 流程时的 44%。我们相信,这项工作中获得的许多原则和最佳实践可广泛应用于一般代码生成任务。完整实现可在以下地址获取:https://github.com/Codium-ai/AlphaCodium

英文摘要:

Code generation problems differ from common natural language problems - they require matching the exact syntax of the target language, identifying happy paths and edge cases, paying attention to numerous small details in the problem spec, and addressing other code-specific issues and requirements. Hence, many of the optimizations and tricks that have been successful in natural language generation may not be effective for code tasks. In this work, we propose a new approach to code generation by LLMs, which we call AlphaCodium - a test-based, multi-stage, code-oriented iterative flow, that improves the performances of LLMs on code problems. We tested AlphaCodium on a challenging code generation dataset called CodeContests, which includes competitive programming problems from platforms such as Codeforces. The proposed flow consistently and significantly improves results. On the validation set, for example, GPT-4 accuracy (pass@5) increased from 19% with a single well-designed direct prompt to 44% with the AlphaCodium flow. Many of the principles and best practices acquired in this work, we believe, are broadly applicable to general code generation tasks. Full implementation is available at: https://github.com/Codium-ai/AlphaCodium

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

↑