Prompt Optimization: Improve Performance with Evaluation Criteria
Prompt optimization is the systematic process of improving instructions and examples so a model produces the intended result more often and consistently. It is more than polishing sentences: inspect failures on representative inputs, then compare whether a revised prompt actually meets defined quality criteria better. The goal is not an abstract “best prompt,” but one that reliably performs an acceptable task under specific model, workload, cost, and latency constraints.
Prompt optimization is the systematic process of improving instructions and examples so a model produces the intended result more often and consistently. It is more than polishing sentences: inspect failures on representative inputs, then compare whether a revised prompt actually meets defined quality criteria better. The goal is not an abstract “best prompt,” but one that reliably performs an acceptable task under specific model, workload, cost, and latency constraints.
When is optimization useful?
Optimization is warranted when a prompt that works on a few hand-picked examples fails on varied real inputs, when changing models alters accuracy or format compliance, or when the same failure keeps recurring. If the user’s requirement is unclear or the necessary data is missing, fix the requirement or input before rewriting the prompt. An optimizer cannot infer what an ambiguous goal means.
Prompt optimization is also different from model training. In a typical optimization cycle, model weights stay fixed while the instruction, examples, context, or output constraints change. Fine-tuning uses training data to adjust model weights. Choose between a prompt that can be changed immediately and model training based on data volume, change frequency, cost, and quality requirements.
Define what “better” means
“Give a better answer” is not measurable enough. Translate the task into observable criteria. For customer-message classification, this might include label accuracy and the rate of disallowed labels. For summaries, it might include preservation of key facts and compliance with a length limit. For extraction, it might include missing required fields and schema validity. Set a rubric for qualities that need human judgment, and review automated scores on representative cases.
Metrics should reflect the real use case. A prompt that raises accuracy might also over-refuse, omit important detail, or increase cost. Track safety, format compliance, latency, and token cost alongside quality, and decide in advance which conditions are mandatory and what regressions are acceptable.
An iterative optimization process
**Freeze the baseline prompt and model.** Record not just the system instruction but also variable values, examples, model version, and relevant settings. If other factors change during comparison, it becomes hard to isolate the effect of the prompt edit.
**Build a representative evaluation set.** Include common inputs, edge cases, and known failures. Record expected outputs or scoring rules. Separating cases used to develop a prompt from held-out cases used for final comparison helps reduce overfitting.
**Inspect current performance and failure types.** Do not look only at an average score. Review examples and classify causes: unclear instructions, missing information, biased examples, or an undefined output format.
**Test a small number of changes with a hypothesis.** For example: “If the prompt says not to guess when evidence is missing, unsupported extracted values will decrease.” Recording the reason for a change and the expected result makes later score changes easier to interpret.
**Compare candidates on the same evaluation set.** Keep the model, settings, and inputs the same; for variable generation tasks, consider repeated runs when appropriate. Even if a candidate improves the target metric, inspect failure cases and confirm that it does not violate other required conditions.
**Recheck on held-out cases and operational conditions.** Confirm the improvement also holds on cases not used to make the edit. Save only candidates that pass, deploy them to a limited scope, and retain the previous version so you can roll back if new failures appear in real inputs.
A small example
Example: Suppose a system extracts material and color from product descriptions as JSON. The existing prompt works for known products, but it guesses a common material when the description does not specify one. Create a candidate that clarifies both the missing-value rule, such as returning an empty string, and the output schema. The evaluation set should include descriptions that state a material, omit one, or contain conflicting material claims. Score field accuracy, missing-value handling, and JSON validity separately.
If the candidate raises the overall average but creates new color-extraction errors, do not adopt it automatically. Refine the missing-value rule or examples and run the same evaluation again. The exercise might reveal that the evaluation cases are too weak, rather than that the prompt wording is the main problem. This is a hypothetical example to explain the process, not a claim about a product or an actual experiment.
Where automated optimizers fit
An automated prompt optimizer can help generate candidate instructions and explore them against evaluation examples and metrics. Google Cloud’s current documentation describes a zero-shot approach for quickly improving a single instruction, a few-shot approach that uses failure examples and feedback, and a data-driven approach that iteratively evaluates labeled examples with specified metrics. Available methods and supported models vary by platform, so check the service’s current documentation before using it.
A tool’s suggested candidate is not a final answer. Its automated scorer may not match user value, or it may produce wording that fits only the examples used for optimization. For sensitive work, check whether evaluation data contains confidential or personal information, and whether candidate prompts weaken safety boundaries. Validate important changes against held-out examples and human judgment before applying them.
Common failures and how to recover
**The objective is vague:** Criteria such as “be friendly” can be interpreted differently and make comparisons unstable. Specify observable behavior or give examples.
**The evaluation set is too small or easy:** A score increase may not represent a real improvement. Add varied input types, missing information, and exceptions, plus held-out cases.
**Only the average is considered:** An average can hide serious degradation for a subgroup. Inspect results by failure type and check mandatory conditions such as safety and output format.
**Many parts change at once:** It becomes difficult to identify which change caused the result. Reduce the number of edits and record each version’s differences and evaluation results.
**The prompt is overfit to the evaluation data:** Repeatedly optimizing against the same examples can hurt performance on new inputs. Separate development and held-out data, and periodically review operational samples.
**The prompt is reused after a model change:** Prompt behavior can differ across models. Treat a model change as a new comparison and evaluate again.
Practical checklist
Have you specified the task and target model?
Have you translated “good results” into measurable criteria and mandatory constraints?
Do you have common inputs, edge cases, known failures, and held-out cases?
Did you compare the baseline and candidate under the same conditions?
Did you inspect failure types, cost, latency, and safety in addition to the average?
Did you record the rationale, evaluation results, approved version, and rollback path?
Prompt optimization is not endless wordsmithing. It is a way to make decisions using a clear objective and repeatable evaluation. A change that cannot be explained or reproduced on representative cases should not be promoted to an operational prompt.
Sources
[Google Cloud: Optimize prompts](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/prompts/prompt-optimizer?hl=en) — documented zero-shot, few-shot, and data-driven approaches and their current scope.
[Google Cloud: Announcing Vertex AI Prompt Optimizer](https://cloud.google.com/blog/products/ai-machine-learning/announcing-vertex-ai-prompt-optimizer) — background on iterative candidate generation and evaluation against metrics. Current documentation takes precedence for present product behavior.
[OpenAI API: Prompt engineering](https://developers.openai.com/api/docs/guides/prompt-engineering) — reference for prompt-design strategies.