Code Generation with AlphaCodium: From Prompt Engineering to Flow Engineering

By Tal Ridnik, Dedy Kredo, Itamar Friedman. 2024

136 citations recorded by the source corpus.

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

Subfields: Artificial Intelligence, Information Systems, Software, Large Language Models, Prompting & Reasoning, Code Generation & Program Synthesis

How researchers see this paper

The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.

In Artificial Intelligence

  1. Armando Solar-Lezama
  2. Koushik Sen
  3. Naman Jain
  4. Tianjun Zhang
  5. Wen-Ding Li
  6. Ion Stoica
  7. Swarat Chaudhuri
  8. Rishabh Singh

In Information Systems

  1. Armando Solar-Lezama
  2. Koushik Sen
  3. Naman Jain
  4. Tianjun Zhang
  5. Ion Stoica
  6. Rishabh Singh
  7. Mosharaf Chowdhury
  8. Charles Sutton

In Software

  1. Armando Solar-Lezama
  2. Koushik Sen
  3. Naman Jain
  4. Tianjun Zhang
  5. Ion Stoica
  6. Patrice Godefroid
  7. Rishabh Singh
  8. Gordon Fraser

In Large Language Models

  1. Armando Solar-Lezama
  2. Naman Jain
  3. Tianjun Zhang
  4. Ion Stoica

In Code Generation & Program Synthesis

  1. Armando Solar-Lezama
  2. Koushik Sen
  3. Rishabh Singh

Citations in the corpus