Automated Prompt Engineering for Cost-Effective Code Generation Using Evolutionary Algorithm
Hamed Taherkhani, Melika Sepindband, Hung Viet Pham, Song Wang, Hadi Hemmati

TL;DR
This paper introduces EPiC, an evolutionary algorithm-based method that refines prompts for code generation, significantly reducing costs while improving code correctness compared to existing techniques.
Contribution
The paper presents a novel lightweight evolutionary approach for prompt engineering that enhances code generation quality cost-effectively.
Findings
EPiC achieves up to 6% improvement in pass@k.
EPiC is 2-10 times more cost-effective than state-of-the-art methods.
The approach reduces LLM interactions while maintaining high code quality.
Abstract
Large Language Models have seen increasing use in various software development tasks, especially in code generation. The most advanced recent methods attempt to incorporate feedback from code execution into prompts to help guide LLMs in generating correct code in an iterative process. While effective, these methods could be costly due to numerous interactions with the LLM and extensive token usage. To address this issue, we propose an alternative approach named Evolutionary Prompt Engineering for Code (EPiC), which leverages a lightweight evolutionary algorithm to refine the original prompts into improved versions that generate high quality code, with minimal interactions with the LLM. Our evaluation against state-of-the-art (SOTA) LLM based code generation agents shows that EPiC not only achieves up to 6% improvement in pass@k but is also 2-10 times more cost-effective than the…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSoftware Testing and Debugging Techniques · Parallel Computing and Optimization Techniques · Formal Methods in Verification
