Lesson 4 of 4 Prompt Engineering for FMs

Refining Prompts Iteratively with Evaluation and Feedback

This lesson describes a disciplined refinement process that improves prompts through measured changes driven by evaluation results and user feedback.

Learning outcomes

After completing this lesson, you will be able to:

  • Measure before changing a prompt.
  • Analyze failures by cause and change one thing at a time.
  • Feed production signals back into evaluation.

Measure before changing

Prompt refinement without measurement is guesswork. A change that fixes the example a developer is looking at may silently break ten others. Refinement therefore starts with a baseline: the current prompt's scores on an evaluation set that covers typical inputs, difficult inputs and adversarial inputs such as prompt injection attempts.

Scores combine several kinds of check. Deterministic checks confirm format and required fields; comparisons with reference answers measure correctness; and an LLM judge rates qualities that are hard to check by rule, such as completeness and tone. Each proposed change is then scored on the same set, and it is accepted only if it improves the target behaviour without lowering other scores.

Put in order

A refinement cycle

Exam skills 1.6.5 · 5.1.4

Put the steps of disciplined prompt refinement in order.

Log in to try this activity Interactive activities are free with an account.

Analyse failures and change one thing

Failures are grouped by cause: ignored instructions, wrong format, missing information, wrong tone, hallucinated details or poor reasoning. Each cause suggests a change: clarify or reorder instructions, add an example, add an explicit rule for the edge case, add structure, add reasoning steps, or split the task. Changing one aspect at a time and re-running the full evaluation shows what actually helped. Amazon Bedrock's prompt optimisation feature can rewrite a prompt for a chosen model as a starting point, which is then evaluated like any other candidate.

The following diagram shows a disciplined prompt refinement loop that tests each change against a baseline.

Disciplined prompt refinement. The team adds the failing case to the evaluation set, changes one thing, re-runs the full evaluation and compares every category with the baseline, releasing the new version only if no category regresses. Production feedback keeps adding cases.
The baseline is the current prompt's scores on the same evaluation set.
Match the pairs

Failure cause to prompt change

Exam skills 1.6.5 · 5.2.3

Match each group of failures with the change it usually suggests.

Log in to try this activity Interactive activities are free with an account.

Feedback loops from production

No evaluation set anticipates every real input, so production provides evidence that testing lacks. User ratings, corrections, escalations to human agents and guardrail interventions identify interactions that failed. These are reviewed to diagnose the cause, such as a missing instruction, an ambiguous rule or a retrieval problem, and added to the evaluation set, so that the same failure cannot return unnoticed in a later version.

Prompt versions in Prompt Management, A/B tests that compare variants on real traffic, and monitoring of quality metrics complete the loop: observe, diagnose, change, evaluate, release and observe again. The following table maps common failure types to typical refinements.

FailureTypical refinement
Instruction ignoredMove it earlier, make it explicit, repeat near the end
Wrong or inconsistent formatExample output, schema, tool use, lower temperature
Hallucinated detailsRequire answers only from context; allow "not found"; grounding check
Faulty multi-step logicChain-of-thought or prompt chaining
Wrong tone or lengthExplicit tone rules and word limits; examples
Worked example

A fix that broke other cases

A developer adds "Always include a discount offer" to a support prompt after a complaint. Satisfaction drops, and offers appear in replies to billing errors where they are inappropriate.

The change was made without evaluation. The disciplined approach adds the complaint case to the evaluation set, tests a narrower rule ("Offer a discount only when the customer reports a delayed delivery"), compares scores across all cases against the baseline, and releases the new prompt version only if no category regresses.

Check yourself

What should be done with failures found in production?

Show answer

Add them to the evaluation set, so later prompt changes are tested against them.

Exam Tips

Remember for the exam

  • Establish a baseline score before changing a prompt.
  • Group failures by cause and change one thing at a time.
  • Add production failures to the evaluation set.
  • Release prompt changes as new versions after evaluation.