APE treats natural-language instructions as programs that a model executes. This makes prompt engineering resemble program synthesis: generate candidate instructions from examples, execute them on the task model, score behavior, and keep the instructions that best control the model.

In practice an LLM proposes candidate instructions from a few input-output demonstrations, each candidate is scored on a training set (for example by execution accuracy or log probability), and the best candidates are refined iteratively through Monte Carlo variants. Related work optimizes prompt embeddings by gradient descent (AutoPrompt, Prompt-Tuning) or learns a distribution over chain-of-thought examples with policy gradients. The common move is to stop hand-tweaking prompts and measure them.