Prompt Alchemy: Automatic Prompt Refinement for Enhancing Code Generation

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Ye, Sixiang, Sun, Zeyu, Wang, Guoqing, Guo, Liwei, Liang, Qingyuan, Li, Zheng, Liu, Yong
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866929759752028160
author Ye, Sixiang
Sun, Zeyu
Wang, Guoqing
Guo, Liwei
Liang, Qingyuan
Li, Zheng
Liu, Yong
author_facet Ye, Sixiang
Sun, Zeyu
Wang, Guoqing
Guo, Liwei
Liang, Qingyuan
Li, Zheng
Liu, Yong
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2503_11085
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Prompt Alchemy: Automatic Prompt Refinement for Enhancing Code Generation
Ye, Sixiang
Sun, Zeyu
Wang, Guoqing
Guo, Liwei
Liang, Qingyuan
Li, Zheng
Liu, Yong
Software Engineering
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.
title Prompt Alchemy: Automatic Prompt Refinement for Enhancing Code Generation
topic Software Engineering
url https://arxiv.org/abs/2503.11085