Algorithmic Prompt Engineering: Improving Accuracy and Diversity in LLM-Based Code Synthesis
Recent advancements in Large Language Models (LLMs), notably GPT-3.5 and GPT-4, have transformed AI-assisted code generation; however, their performance appears to hinge on the formulation of input prompts. This study investigates a range of prompt engineering strategies aimed at optimizing code generation outcomes. Specifically, we compare generic, context-sensitive, and dynamically constructed prompts using a benchmark of more than fifty programming tasks spanning Python, Java, and C++. A central contribution of this work lies in the development of algorithmic techniques for dynamic prompt construction, which incorporate iterative refinement informed by automated feedback. Empirical findings indicate that dynamic prompting achieves superior results, with code accuracy reaching approximately 93% and average debugging time reduced by nearly two-thirds relative to generic strategies. Beyond accuracy, the analysis suggests notable gains in code relevance, structural efficiency, and solution diversity. These insights offer a set of evidence-based practices for practitioners and provide a conceptual basis for future research on adaptive and automated prompt design in software development environments.
Publication Details
- Journal
- Zenodo (CERN European Organization for Nuclear Research)
- Published
- 2025-10-28
- DOI
- https://doi.org/10.5281/zenodo.17461531
- Primary Topic
- Phytochemistry and Bioactive Compounds
- Type
- article
- Field-Weighted Citation Impact
- 0.00