Code

AlphaCodium

First page
AlphaCodium
Paper summary

AlphaCodium is a test-based, iterative "flow" that turns off-the-shelf LLMs into strong competitive-programming solvers without model training.

Ask this paper

Key points
01

Test-based iteration: Instead of a single-shot prompt, AlphaCodium runs a staged pipeline - problem self-reflection, public-test enrichment, iterative code generation, and test-driven refinement.

02

Public test enrichment: AI-generated additional tests expand the usually thin public-test set, giving the iterative loop more signal for verification.

03

CodeContests gains: On CodeContests validation, GPT-4 pass@5 jumps from 19% with a well-crafted single prompt to 44% using the AlphaCodium flow.

04

4 orders of magnitude fewer calls: Outperforms DeepMind's AlphaCode while using roughly 10,000x fewer LLM calls, highlighting how structured test-driven flows dominate brute-force sampling.

Abstract

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

Every Monday
Get next week’s papers.
Subscribe on Substack