A Comparative Empirical Study of Prompting Strategies for Code Generation with Large Language Models
Journal of Advanced Computing Systems · 09.12.2025 · 5 (12) · 26-37
DOI: 10.69987/jacs.2025.51203 ↗Kurz gefasst
Fachartikel in der Zeitschrift Journal of Advanced Computing Systems, online erschienen am 09.12.2025. Verfasst von Fanyi Zhao und 2 weiteren Autor:innen. Die Arbeit wurde bisher 3-mal zitiert (Crossref). Der Volltext ist frei zugänglich (Open Access, CC BY 4.0).
Abstract (Originalsprache)
Large language models have demonstrated strong capabilities in automated code generation, yet the influence of prompting strategies on generation quality remains insufficiently characterized under controlled experimental conditions. This study presents a systematic comparative evaluation of five prompting strategies — direct instruction, few-shot, zero-shot chain-of-thought, few-shot chain-of-thought, and self-consistency — across seven code-oriented large language models spanning both open-source and proprietary families. Experiments are conducted on four established benchmarks: HumanEval, MBPP, HumanEval+, and MBPP+. Results measured by pass@1 indicate that self-consistency with ten sampling paths yields the highest average accuracy, achieving 82.3% on HumanEval with DeepSeek-Coder-33B-Instruct, while few-shot chain-of-thought offers the strongest single-pass performance. Smaller-parameter models exhibit larger relative gains from structured prompting, with Code Llama-13B-Instruct improving by 8.5 percentage points from direct prompting to self-consistency on HumanEval. Larger models such as GPT-4 show comparatively modest gains of 3.7 percentage points under the same comparison. Evaluation on the more rigorous EvalPlus benchmarks reveals consistent pass@1 reductions averaging 8.3 percentage points, confirming that standard benchmarks overestimate functional correctness. A cost-effectiveness analysis demonstrates that zero-shot chain-of-thought provides favorable accuracy-to-cost trade-offs for latency-sensitive deployments, while self-consistency is preferable when accuracy is prioritized over computational budget. These findings offer actionable guidance for selecting prompting strategies in practical code generation workflows.
Zitieren
APA
Zhao, F., Yu, M., & Luo, C. (2025). A Comparative Empirical Study of Prompting Strategies for Code Generation with Large Language Models. Journal of Advanced Computing Systems, 5(12), 26-37. https://doi.org/10.69987/jacs.2025.51203
Vancouver
Zhao F, Yu M, Luo C. A Comparative Empirical Study of Prompting Strategies for Code Generation with Large Language Models. Journal of Advanced Computing Systems. 2025;5(12):26-37. doi:10.69987/jacs.2025.51203
BibTeX
@article{Zhao2025,
author = {Zhao, Fanyi and Yu, Mingzhuo and Luo, Chuankai},
title = {A Comparative Empirical Study of Prompting Strategies for Code Generation with Large Language Models},
journal = {Journal of Advanced Computing Systems},
year = {2025},
volume = {5},
number = {12},
pages = {26--37},
doi = {10.69987/jacs.2025.51203}
}
EUVIMED