arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2503.11085cs.SE
收藏

Prompt Alchemy:用于增强代码生成的自动提示词优化

Prompt Alchemy: Automatic Prompt Refinement for Enhancing Code Generation

Sixiang Ye, Zeyu Sun, Guoqing Wang, Liwei Guo, Qingyuan Liang, Zheng Li, Yong Liu

AI总结:

本文提出自动提示词优化方法 Prochemy,通过基于模型表现的迭代改进与即插即用集成,提升 LLM 在代码生成和翻译任务上的一致性与性能。

摘要:

代码生成已成为通过将高层描述转换为可执行代码来实现软件开发自动化的关键任务。大型语言模型(LLM)在此方面表现出色,但高度依赖输入提示词的质量。人工提示词工程可能耗时且不一致,从而限制了 LLM 的有效性。本文介绍了 Prochemy,这是一种用于自动优化提示词以提升代码生成的创新方法。Prochemy 通过自动化优化、确保推理过程中的一致性以及支持多智能体系统,克服了人工提示词的局限性。它根据模型性能迭代优化提示词,使用经过优化的最终提示词来提高跨任务一致性。我们使用三个 LLM 系列,在基于自然语言的代码生成和翻译任务上测试了 Prochemy。结果表明,Prochemy 增强了现有方法:在 HumanEval 上,相较零样本基线,GPT-3.5-Turbo 的性能提升 5.0%,GPT-4o 提升 1.9%。在最先进的 LDB 中,Prochemy + LDB 比独立方法高出 1.2–1.8%。在代码翻译方面,Prochemy 将 GPT-4o 在 Java 到 Python(AVATAR)上的性能从 74.5 提升至 84.1(+12.9%),并将 Python 到 Java 的性能从 66.8 提升至 78.2(+17.1%)。此外,Prochemy 在与 o1-mini 模型集成时仍保持强劲性能,验证了其在代码任务中的功效。Prochemy 被设计为即插即用,能够以最少的人工输入优化提示词,弥合了简单提示词与复杂框架之间的差距。

英文摘要:

Code generation has emerged as a key task to automate software development by converting high-level descriptions into executable code. Large language models (LLMs) excel at this but depend heavily on input prompt quality.Manual prompt engineering can be time-consuming and inconsistent, limiting LLM effectiveness. This paper introduces Prochemy, an innovative method for automatically refining prompts to boost code generation. Prochemy overcomes manual prompt limitations by automating optimization, ensuring consistency during inference, and supporting multi-agent systems.It iteratively refines prompts based on model performance, using an optimized final prompt for improved consistency across tasks. We tested Prochemy on natural language-based code generation and translation tasks using three LLM series. Results indicate Prochemy enhances existing methods, improving performance by 5.0% for GPT-3.5-Turbo and 1.9% for GPT-4o over zero-shot baselines on HumanEval. In state-of-the-art LDB, Prochemy + LDB surpasses standalone methods by 1.2-1.8%. For code translation, Prochemy boosts GPT-4o's Java-to-Python (AVATAR) performance from 74.5 to 84.1 (+12.9%) and Python-to-Java from 66.8 to 78.2 (+17.1%). Moreover, Prochemy maintains strong performance when integrated with the o1-mini model, validating its efficacy in code tasks. Designed as plug-and-play, Prochemy optimizes prompts with minimal human input, bridging the gap between simple prompts and complex frameworks.

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

↑