Popularized by projects like AlphaCodium, flow engineering assumes that LLMs are relatively weak at zero-shot, complex reasoning but exceptionally strong when forced to iterate. Instead of writing one massive prompt hoping for the perfect output, flow engineers design a state machine. The LLM is forced through a sequence: generating a plan, writing draft code, running that code against a compiler, reading the error trace, and attempting a fix. By rigidly structuring this 'flow', developers can dramatically increase the reliability and performance of an underlying model without needing to upgrade to a more expensive, larger parameter model.

How It Works

A classic flow engineering pipeline for code generation looks like:
  • Phase 1 (Reflection): The model reads the problem and outputs its understanding of the constraints.
  • Phase 2 (Planning): The model outlines the algorithmic approach without writing syntax.
  • Phase 3 (Generation): The model generates the actual code based strictly on the plan.
  • Phase 4 (Execution & Critique): The code is run in a sandbox. A separate prompt passes the execution trace (success or stack trace) back to the model for refinement.

Common Use Cases

  • Competitive programming and automated software engineering.
  • Complex data extraction where the schema must be validated iteratively.
  • High-stakes content generation requiring rigorous fact-checking loops.

Related Terms