What is automatic prompt optimisation?

Automatic prompt optimisation is a family of methods searching for the best prompt for a task by having a language model propose candidate prompts, scoring them on labelled examples and iteratively refining the best, instead of manual trial and error.

Unlike prompt tuning, which learns continuous vectors added to the model's input via gradients and yields no readable text, automatic prompt optimisation produces readable natural language prompts and needs no access to model weights or gradients.

Topic
Prompts, context, reasoning and generation
Also known as
Automatic prompt engineering, APO

How automatic prompt optimisation works

  1. A small labelled example set and a success metric are prepared for the task.
  2. A language model proposes new candidate prompts from the current prompt and examples.
  3. Candidates run and are scored on the examples; some methods turn errors into natural language critiques used to revise the prompt.
  4. The best candidates move to the next round until the budget runs out; the result is validated on a separate set.

In more detail

Compound AI pipelines and DSPy and TextGrad

APO evolved from tuning single instructions (APE, OPRO) to compiling entire multi-stage AI pipelines, including RAG queries, tool descriptions and few-shot demonstrations, using frameworks such as DSPy (e.g., MIPROv2) and TextGrad.

Search methods: evolutionary search, textual gradients and Bayesian optimisation

Optimisation strategies include evolutionary/genetic mutation (such as EvoPrompt), textual gradient descent where an LLM critiques errors in natural language (such as ProTeGi and TextGrad) and Bayesian surrogate search over joint instruction and demonstration candidates.

Fragility across model versions and training data leakage

Automated optimisers can inadvertently copy sensitive details from training examples into the resulting prompt's rules or few-shot examples, creating privacy leakage risks. Optimised prompts are often brittle across model upgrades or quantisation changes, requiring re-validation whenever the underlying model changes.

Commonly confused terms

TermHow it differs
Manual prompt engineeringManual prompt engineering relies on human intuition and iterative trial and error, whereas APO automates candidate generation, evaluation and refinement against a quantitative metric and validation set.
Fine-tuningFine-tuning (full or LoRA) updates model weights to internalise new behaviours or domain knowledge, whereas APO leaves model weights untouched and only searches for better input instructions and few-shot examples.

Why automatic prompt optimisation matters for on-premises AI

Manual prompt tuning is slow. A study proposing automatic prompt generation showed generated instructions beat the prior baseline by a large margin on 24 tasks and matched or beat human-written ones. Another, using a language model as optimiser, reported its best prompts beat human-designed ones by up to 8% on a maths benchmark and up to 50% on a hard task set. The risk is overfitting a small example set.

ON-PREMISES EXAMPLE

An insurer automatically refines its prompt classifying claim emails using labelled examples; it tests the best candidate on a held-out validation set and saves the new version to its prompt store.

Common questions

Does automatic prompt optimisation change model weights?

No. It changes only the prompt text and needs no access to weights or gradients.

What does automatic prompt optimisation need?

Representative labelled examples, a clear success metric, a model to propose candidates and a separate set to validate the result.

Sources

In the glossary: Glossary, A to C

What does this term mean for your infrastructure?

We can work out together in a technical assessment how it maps onto your data, hardware and security requirements.

Request a technical assessment →

This site sets no cookies. Visitor numbers are counted in aggregate using a cookieless method that does not identify anyone. See the Privacy Policy for details.