Code Generation with AlphaCodium: From Prompt Engineering to Flow Engineering
Open accessAbstract
Code generation problems differ from common natural language problems - they require matching the exact syntax of the target language, identifying happy paths and edge cases, paying attention to numerous small details in the problem spec, and addressing other code-specific issues and requirements. Hence, many of the optimizations and tricks that have been successful in natural language generation may not be effective for code tasks. In this work, we propose a new approach to code generation by LLMs, which we call AlphaCodium - a test-based, multi-stage, code-oriented iterative flow, that improves the performances of LLMs on code problems. We tested AlphaCodium on a challenging code generation dataset called CodeContests, which includes competitive programming problems from platforms such as Codeforces. The proposed flow consistently and significantly improves results. On the validation set, for example, GPT-4 accuracy (pass@5) increased from 19% with a single well-designed direct prompt to 44% with the AlphaCodium flow. Many of the principles and best practices acquired in this work, we believe, are broadly applicable to general code generation tasks. Full implementation is available at: https://github.com/Codium-ai/AlphaCodium
The claims and statistics of this paper haven’t been checked yet.
Run the check — free, no account needed. It reads the open-access text and checks the sources it cites.
Integrity signals
Registry
Cites
Statistics
Claims the paper makes
The claims and statistics of this paper haven’t been checked yet.
Run the check — free, no account needed. It reads the open-access text and checks the sources it cites.
Claims other papers make about this one
Each is checked against this paper’s own text: does it say what the citing paper says it does?
On MBPP, AFLOW found structures resembling manually designed workflows, including LLM test generation and execution.
“On the MBPP dataset, AFLOW discovered structures similar to current manually designed workflows, such as test generation and execution by LLMs as seen in Ridnik et al. (2024).”
From AFlow: Automating Agentic Workflow Generation (2024) · cites this paper as Ridnik et al. (2024)
AFLOW can reduce human effort by evolving from an empty workflow to a solution closely resembling manually designed workflows such as Ridnik et al. (2024) in code generation.
“AFLOW demonstrates its ability to reduce human effort by evolving from an empty workflow to a solution highly similar to manually designed workflows like Ridnik et al. (2024) in the code generation scenario.”
From AFlow: Automating Agentic Workflow Generation (2024) · cites this paper as Ridnik et al. (2024)
Self-check
Percentages, sums and reported differences re-computed from the paper’s own numbers.
The self-check needs the paper’s full text.
Cites
The publisher hasn’t deposited this paper’s reference list.
Research works printed but not linked: 11
- Jacob Austin, Augustus Odena, Maxwell Nye, Maarten Bosma, Henryk Michalewski, David Dohan, Ellen Jiang, Carrie Cai, Michael Terry, Quoc Le, et al. Program synthesis with large language models. arXiv preprint arXiv:2108.07732, 2021. 1 · arXiv
- Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Hen- rique Ponde de Oliveira Pinto, Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, et al. Evalu- ating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021. 1, 3 · arXiv
- Shehzaad Dhuliawala, Mojtaba Komeili, Jing Xu, Roberta Raileanu, Xian Li, Asli Celikyilmaz, and Jason Weston. Chain-of-verification reduces hallucination in large language models. arXiv preprint arXiv:2309.11495, 2023. 1 · arXiv
- Dan Hendrycks, Steven Basart, Saurav Kadavath, Mantas Mazeika, Akul Arora, Ethan Guo, Collin Burns, Samir Puranik, Horace He, Dawn Song, et al. Measuring coding challenge competence with apps. arXiv preprint arXiv:2105.09938, 2021. · arXiv
- Hung Le, Hailin Chen, Amrita Saha, Akash Gokul, Doyen Sahoo, and Shafiq Joty. Codechain: Towards modular code generation through chain of self-revisions with representa- tive sub-modules. arXiv preprint arXiv:2310.08992, 2023. 1, 7 · arXiv
- Yujia Li, David Choi, Junyoung Chung, Nate Kush- man, Julian Schrittwieser, Rémi Leblond, Tom Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, et al. Competition-level code generation with alphacode. Science, 378(6624):1092-1097, 2022. 1, 3, 7
- Mike Mirzayanov, Oksana Pavlova, Pavel MAVRIN, Roman Melnikov, Andrew Plotnikov, Vladimir Parfenov, and An- drew Stankevich. Codeforces as an educational platform for learning programming in digitalization. Olympiads in Infor- matics, 14(133-142):14, 2020. 1, 3
- Harsha Nori, Yin Tat Lee, Sheng Zhang, Dean Carignan, Richard Edgar, Nicolo Fusi, Nicholas King, Jonathan Lar- son, Yuanzhi Li, Weishung Liu, et al. Can generalist founda- tion models outcompete special-purpose tuning? case study in medicine. arXiv preprint arXiv:2311.16452, 2023. 1 · arXiv
- Gemini Team, Rohan Anil, Sebastian Borgeaud, Yonghui Wu, Jean-Baptiste Alayrac, Jiahui Yu, Radu Soricut, Johan Schalkwyk, Andrew M Dai, Anja Hauth, et al. Gemini: a family of highly capable multimodal models. arXiv preprint arXiv:2312.11805, 2023. 7 · arXiv
- Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszko- reit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017. 1
- Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, Sharan Narang, Aakanksha Chowdhery, and Denny Zhou. Self-consistency improves chain of thought reason- ing in language models. arXiv preprint arXiv:2203.11171, 2022. · arXiv
Cited by
Sorted by citations
Biomni: A general-purpose biomedical ai agent
Huang, K., Zhang, S., Wang, H., Qu, Y., Lu, Y., Roohani, Y., Li, R., Qiu, L., Li, G., Zhang, J., et al. (2025) · doi:10.1101/2025.05.30.656746 · Cited by 125 · see citing works
From text to insight: large language models for chemical data extraction
Schilling-Wilhelmi, M., Ríos-García, M., Shabih, S., Gil, M. V., Miret, S., Koch, C. T., Marquez, J. A., & Jablonka, K. M. (2024) · Chemical Society Reviews · doi:10.1039/d4cs00913d · Cited by 155 · see citing works
Prompt engineering as a new 21st century skill
Federiakin, D. A., Molerov, D., Zlatkin‐Troitschanskaia, O., & Maur, A. (2024) · Frontiers in Education · doi:10.3389/feduc.2024.1366434 · Cited by 185 · see citing works
Materials science in the era of large language models: a perspective
Lei, G., Docherty, R., & Cooper, S. J. (2024) · Digital Discovery · doi:10.1039/d4dd00074a · Cited by 109 · see citing works
Large Language Model-Based Agents for Software Engineering: A Survey
Jun-wei, L., Wang, K., Chen, Y., Peng, X., Chen, Z., Zhang, L., & Lou, Y. (2026) · ACM Transactions on Software Engineering and Methodology · doi:10.1145/3796507 · Cited by 106 · see citing works
A Comprehensive Overview and Analysis of Large Language Models: Trends and Challenges
Mohammed, A., & Kora, R. (2025) · IEEE Access · doi:10.1109/access.2025.3573955 · Cited by 38 · see citing works
Programming with AI: Evaluating ChatGPT, Gemini, AlphaCode, and GitHub Copilot for Programmers
Siam, K., Gu, H., & Cheng, J. Q. (2024) · International Conference on Computing Advancements (ICCA) · doi:10.1145/3723178.3723224 · Cited by 30 · see citing works
RLEF: Grounding Code LLMs in Execution Feedback with Reinforcement Learning
Gehring, J., Zheng, K., Copet, J., Mella, V., Carbonneaux, Q., Cohen, T., & Synnaeve, G. (2024) · arXiv · doi:10.48550/arxiv.2410.02089 · Cited by 23 · see citing works
APOLLO: A GPT-based tool to detect phishing emails and generate explanations that warn users
Desolda, G., Greco, F., & Vigano, L. (2025) · Proceedings of the ACM on Human-Computer Interaction · doi:10.1145/3733049 · Cited by 16 · see citing works
COFFE: A Code Efficiency Benchmark for Code Generation
Peng, Y., Wan, J., Li, Y., & Ren, X. (2025) · Proceedings of the ACM on software engineering. · doi:10.1145/3715727 · Cited by 15 · see citing works
Developing large language models for quantum chemistry simulation input generation
Jacobs, P. F., & Pollice, R. (2025) · Digital Discovery · doi:10.1039/d4dd00366g · Cited by 14 · see citing works
Exploring formal defeasible reasoning of large language models: A Chain-of-Thought approach
Li, Z., Chen, C., Li, M., & Liao, B. (2025) · Knowledge-Based Systems · doi:10.1016/j.knosys.2025.113564 · Cited by 9 · see citing works
Training LLMs for Generating IEC 61131-3 Structured Text with Online Feedback
HAAG, A. L., Fuchs, B., Kacan, A., & Lohse, O. (2025) · International Workshop on Large Language Models for Code (LLM4Code) · doi:10.1109/llm4code66737.2025.00013 · Cited by 8 · see citing works
AFlow: Automating Agentic Workflow Generation
Zhang, J., Xiang, J., Yu, Z., Teng, F., Chen, X., Chen, J., Zhuge, M., Cheng, X., Hong, S., Wang, J., et al. (2024) · arXiv · doi:10.48550/arxiv.2410.10762 · Cited by 7 · see citing works
“Domain-specific workflows focus on building effective processes to solve domain-specific problems, such as code generation (Hong et al., 2024b; Ridnik et al., 2024; Zhong et al., 2024a), data analysis (Xie et al., 2024b; Ye et al., 2024; Li et al., 2024a; Zhou et al., 2023), mathematics (Zhong et…”
Test Code Generation for Telecom Software Systems Using Two-Stage Generative Model
Nabeel, M., Nimara, D. D., & Zanouda, T. (2024) · IEEE International Conference on Communications workshops · doi:10.1109/iccworkshops59551.2024.10615269 · Cited by 6 · see citing works
STEP: A structured prompt optimization method for SCADA system tag generation using LLMs
Ma, F.-Y., Li, D., Liu, Y., Lan, D., & Pang, Z.-B. (2025) · Journal of Industrial Information Integration · doi:10.1016/j.jii.2025.100832 · Cited by 9 · see citing works
Visual analysis of LLM-based entity resolution from scientific papers
Wu, S., Yang, Y., Wu, W., Li, R., Zhang, Y., Wang, G., Tan, H., Liu, Z., & Shi, L. (2025) · Visual Informatics · doi:10.1016/j.visinf.2025.100236 · Cited by 4 · see citing works
Liao, L., Wang, J., Xu, Z., Mu, F., & Yang, Y. (2024) · IEEE/ACM International Conference on Automated Software Engineering (ASE) · doi:10.1145/3691620.3695282 · Cited by 3 · see citing works
FeedbackEval: A Benchmark for Evaluating Large Language Models in Feedback-Driven Code Repair Tasks
Dai, D., Liu, M., Li, A., Cao, J., Wang, Y., Wang, C., Peng, X., & Zheng, Z. (2025) · arXiv · doi:10.48550/arxiv.2504.06939 · Cited by 1 · see citing works
“With the rise of large language models (LLMs), there is increasing interest in leveraging their capabilities for automated code repair by incorporating test feedback and compiler diagnostics [30, 34].”
Mao, K., Hu, B., Lin, R., Li, Z., Lu, G., & Zhang, Z. (2025) · Frontiers in Artificial Intelligence · doi:10.3389/frai.2025.1660912 · Cited by 4 · see citing works
PhysAgent: A Multi-Agent Large Language Model Framework for Physics Data Analysis and Simulation
Han, X., Gao, Z.-F., Guo, P., & Lu, Z.-Y. (2026) · Chinese Physics B · doi:10.32388/j2mxuw · Cited by 1 · see citing works
R2E-Gym: Procedural Environments and Hybrid Verifiers for Scaling Open-Weights SWE Agents
Jain, N., Singh, J., Shetty, M., Zheng, L., Sen, K., & Stoica, I. (2025) · arXiv · doi:10.48550/arxiv.2504.07164 · Cited by 1 · see citing works
Multi-LCB: Extending LiveCodeBench to Multiple Programming Languages
Ivanova, M., Zadorozhny, P., Levichev, R., Petrov, I., Pavel, A., Lopatin, I., Kutalev, A., & Babaev, D. (2026) · arXiv · doi:10.48550/arxiv.2606.20517
“Large language models (LLMs) have recently demonstrated impressive capabilities in code-related tasks (Ridnik et al., 2024; Lozhkov et al., 2024; Roziere et al., 2023; Li et al., 2022; Nijkamp et al., 2022), powering applications such as AI-assisted programming, automated debugging, and code…”
ScoreFlow: Mastering LLM Agent Workflows via Score-based Preference Optimization
Wang, Y., Yang, L., Li, G., Wang, M., & Aragam, B. (2025) · arXiv · doi:10.48550/arxiv.2502.04306
Leveraging Large Language Model Outputs for Enhanced Domain Specific Decision-Making
Chandra, R., Mehndiratta, V., Srivastava, S., Poonia, R. C., & Shoran, P. (2024) · International Conference on Advancement in Electronics & Communication Engineering (AECE) · doi:10.1109/aece62803.2024.10911745
Leveraging Generative AI for Accelerating Enterprise Application Development: Insights from ChatGPT
Rajbhoj, A., Sant, T., Somase, A., & Kulkarni, V. (2024) · Asia-Pacific Software Engineering Conference · doi:10.1109/apsec65559.2024.00052 · Cited by 1 · see citing works
Nehzati, M. (2025) · Frontiers in Artificial Intelligence · doi:10.3389/frai.2025.1662220
Kim, M., Choi, M., Wang, E., & Chung, S. (2026) · The Journal of Korean Institute of Information Technology · doi:10.14801/jkiit.2026.24.5.75
Spiridonov, A. (2026) · International Workshop on Agentic AI for Next-Generation Software Development · doi:10.1145/3843282.3844443
From Vibe to Spec: An Empirical Study to Demystify Specifications in Code Generation
He, R., Lu, H., Ma, L., Ye, K., Wu, Q., Liu, S., Bu, L., & Li, X. (2026) · IEEE/ACM International Conference on Automated Software Engineering (ASE) · doi:10.1145/3832783.3837515
- Authors
- Ridnik, T., Kredo, D., & Friedman, I.
- Venue
- arXiv
- Publisher
- arXiv
- Published
- 2024
- ISSN
- 2331-8422 (ISSN-L)
- arXiv
- 2401.08500
- OpenAlex
- W4390963096
- Semantic Scholar
- 1566d96346927ad4dced85de4d55356f6aee6fb6
- Cited by
- 23
- References
- 0
- Citations by year
- 2026: 4 · 2025: 11 · 2024: 8
- Type
- posted content
- Language
- en
- Open access
- green
- arxiv.org
- Licence
- Locations
- arXiv (Cornell University) (submittedVersion, cc-by)
- arXiv (Cornell University) (cc-by)
- Topics
- Physical Sciences › Computer Science › Information Systems › Software Engineering Research
- Physical Sciences › Computer Science › Artificial Intelligence › Topic Modeling
- Physical Sciences › Computer Science › Computer Science Applications › Teaching and Learning Programming
- Keywords
- code generation, large language models, prompt engineering, competitive programming, GPT-4
About these checks
Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.
Statistics and arithmetic are recomputed, not judged.
Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.
What counts as a claim ›How we measure confidence ›How we check this ›
Are you an author, or do you see a problem with this page? Request a review