PMPO
PMPO, short for Probabilistic Metric Prompt Optimization, tunes prompts using the model's own loss instead of generated outputs. It measures how surprised the model is, token by token, to find the weak parts of a prompt by masking, then rewrites and picks the best variant by which one lowers the loss in a single forward pass. Because it never has to sample outputs or call a judge, it is lightweight and works even on small models.
*These are learning tools, not prompts. They teach you to write your own, think of them as training wheels that guide you while you learn, then fall away once you can ride on your own.
Let the Loss Be the Signal
Most prompt optimizers judge a candidate by generating an output and scoring it, often with another LLM acting as a judge. That is powerful but heavy: it needs sampling, sometimes several samples, and a capable evaluator. On small models, which make weaker judges, this whole approach is shaky.
PMPO uses a cheaper, more direct signal: the model's token-level cross-entropy loss. The loss measures how well the prompt leads the model toward the correct continuation. A lower loss means the prompt is doing its job better. Because the loss can be read from a single forward pass without generating anything, evaluating a candidate is fast and does not depend on the model being a good judge.
PMPO uses this metric twice. First, it masks segments of the prompt and watches how the loss changes, which reveals which parts of the prompt are weak or unhelpful. Then it rewrites those parts, evaluates each variant by its loss, and keeps the one that lowers it most. Working purely from probabilities, PMPO optimizes prompts for both small and large models.
Generating and judging an output can take many model calls. Reading the cross-entropy loss takes just one forward pass, because the loss already reflects how confidently the prompt steers the model toward the right answer. That makes each candidate cheap to evaluate and removes the need for a strong judge model.
The PMPO Process
Measure loss, locate weak spans, rewrite, and select by loss
Measure the Prompt's Loss
Run the prompt through the model and read its token-level cross-entropy loss against the desired continuations. This single number captures how well the current prompt guides the model, no output generation needed.
A classification prompt is measured, giving a baseline loss to improve on.
Locate Weak Segments by Masking
Mask different parts of the prompt and observe how the loss shifts. Segments whose removal barely changes the loss, or whose presence raises it, are flagged as weak, pinpointing where a rewrite will help most.
Masking a rambling preamble leaves the loss almost unchanged, marking it as dead weight to revise.
Rewrite the Weak Parts
Generate several rewrites of the flagged segments, producing a set of candidate prompts that differ only where the weakness was found. The search stays focused on the parts that actually matter.
The weak preamble is replaced with a few candidate openings, each stating the task directly.
Select the Lowest-Loss Variant
Measure each candidate's loss in a single forward pass and keep the one that lowers it most. Repeat the cycle if desired. The result is a prompt refined entirely through probabilities, with no output sampling or judge involved.
The direct opening yields the lowest loss and becomes the new prompt.
See the Difference
Generate-and-judge versus read-the-loss
Generate-and-Judge
Each candidate prompt must generate an output, which is then judged, often by another LLM, to decide if the prompt is better.
Sampling and judging are expensive, and small models make unreliable judges, so the approach struggles at the low end.
PMPO
Each candidate is scored by its token-level loss in a single forward pass, and weak spans are found by masking, no generation or judge required.
Fast to evaluate and independent of judging ability, so it optimizes prompts for small models as well as large ones.
Practice Responsible AI
Always verify AI-generated content before use. AI systems can produce confident but incorrect responses. When using AI professionally, transparent disclosure is both best practice and increasingly a legal requirement.
Most US states are actively legislating AI transparency and accountability. Critical thinking remains your strongest tool against misinformation.
PMPO in Action
See how the loss signal drives targeted rewrites
A sentiment prompt opens with a long, generic description of the task before the actual instruction.
Mask the preamble: the loss barely moves, showing the opening adds little.
Mask the instruction: the loss jumps, confirming that part carries the weight.
Action: PMPO targets the preamble for rewriting, leaving the effective instruction alone.
Three rewrites of the weak opening are produced, each phrasing the task differently.
Each candidate is measured by its token-level loss in one forward pass.
The lowest-loss rewrite wins: the phrasing that most confidently steers the model toward correct labels is chosen, with no outputs generated or judged.
A small, non-instruction-tuned model needs a better prompt, but it is a poor judge of output quality.
Because PMPO relies on loss, not judgment, it can still optimize the prompt, the loss signal is reliable even when the model cannot evaluate its own outputs well.
Result: the small model gets an improved prompt that a generate-and-judge optimizer could not have produced.
When to Use PMPO
Best when you can read the model's loss and want a light, judge-free optimizer
Perfect For
When the model is a weak judge, a loss-based signal still works, so PMPO can optimize prompts for small or non-instruction-tuned models.
Reading the loss in a single forward pass makes each candidate cheap, which suits fast iteration and limited compute.
When you can read token-level loss from the model, PMPO turns that directly into a precise optimization signal.
Masking analysis shows exactly which segments of a prompt are not pulling their weight, so rewrites stay targeted.
Skip It When
If you can only call a model through an interface that hides token probabilities, PMPO's core signal is unavailable.
On tasks where a lower loss does not track the outcome you care about, a metric or preference-based optimizer may fit better.
For long, creative outputs where there is no clear target continuation to measure loss against, the signal is less meaningful.
Use Cases
Where PMPO delivers the most value
On-Device Model Prompts
Tune prompts for small local models that cannot judge their own work, using the loss signal that remains reliable at that scale.
Classification Prompts
Improve prompts for labeling tasks where the correct continuation is known, so token-level loss is a clean measure of prompt quality.
Fast Iteration Loops
Evaluate many prompt variants quickly, since each costs only a forward pass rather than a full generate-and-judge cycle.
Prompt Debugging
Use masking analysis to reveal which parts of an underperforming prompt are dead weight, guiding a focused rewrite.
Low-Compute Environments
Optimize prompts where a heavy generate-and-judge loop is too costly, relying on the cheaper probability-based signal.
Probability-Based Tooling
Fit naturally into pipelines that already have access to model loss, turning that existing signal into prompt improvements.
Where PMPO Fits
The probability-driven, judge-free optimizer
Where OPRO and APE score generated outputs, PMPO scores the prompt itself through its loss. Reach for it when you can read the model's probabilities and want a fast optimizer that does not depend on a strong judge, especially for smaller models.
Related Techniques
Explore complementary prompt-optimization techniques
Optimize by the Numbers
Explore how a prompt steers a model toward the right answer in the Prompt Builder, or see how PMPO relates to the wider family of prompt optimizers.