CertBrain
CoursesBlog
Sign in
← Back to decks
Sign in to save your progress, vote, and build your own decks.Sign in

Prompt Engineering Best Practices

Good prompts are rarely written in one go. They come from clear, specific wording, careful testing and steady refinement, with guardrails around the model for the cases a prompt alone can't handle. This lesson covers the habits behind reliable prompts and the benefits they bring: better answers…

9 cards
Study this deck

Prompt Engineering Best Practices

Good prompts are rarely written in one go. They come from clear, specific wording, careful testing and steady refinement, with guardrails around the model for the cases a prompt alone can't handle. This lesson covers the habits behind reliable prompts and the benefits they bring: better answers, fewer surprises and a cheaper path than retraining a model.

Be specific and concise

Vague prompts get vague answers. State exactly what you want: the task, the audience, the scope and the form of the answer. "Write about our product" leaves the model guessing; "Write a 50-word product description of our hiking boot for first-time hikers, focusing on comfort" doesn't. For classification, name the allowed labels.

Concise matters as much as specific. Extra words cost tokens on every request, and AWS's own guidance notes that over-engineered prompts can lower accuracy. Give the model everything it needs and nothing it doesn't. A prompt that's too simple lacks context; one that's too complex buries the point.

Experiment and iterate

Prompt engineering is experimental. Change one thing at a time, compare the results and keep what works. AWS suggests a simple discipline: collect sample inputs, split them into a development set for trying prompt changes and a hold-out test set you only use to check the final prompt. That way you know your prompt works on inputs it wasn't tuned on, not just the handful you kept testing.

Amazon Bedrock supports this loop. The console playgrounds let you try prompts against different models and settings quickly. Prompt optimization can suggest a rewritten version of your prompt for a chosen model. Prompt Management lets you save variants side by side and compare their outputs. Experimenting this way is also a form of discovery: you learn what a model can and can't do before building an application around it.

Build in guardrails

Some protections belong inside the prompt. Tell the model what to do when it isn't sure: AWS recommends giving a default answer such as "If the answer isn't in the text, say 'I don't know'", which discourages confident-sounding guesses. You can also tell it to stay on topic and refuse requests outside its job.

Prompt instructions can be ignored or worked around, though, so production applications add a separate safety layer. Amazon Bedrock Guardrails screens both user inputs and model outputs against policies you set, such as denied topics, harmful content filters and filters for sensitive information. Guardrails apply consistently whatever the prompt says.

The payoff

These practices improve response quality without touching the model: no training data, no retraining cost and changes that take effect immediately. That's why prompt engineering is usually the first tool to try. Only when good prompting still can't reach the quality you need, for example because the model lacks your company's knowledge, do you move on to Retrieval Augmented Generation or fine-tuning.

On the exam

Questions often ask for the FIRST or LEAST effort way to improve output. That's usually a clearer, more specific prompt, not a bigger model or fine-tuning. If a model makes up answers when information is missing, give it a default answer to use instead. If the requirement is that rules apply reliably to every request, the answer is Bedrock Guardrails, not prompt wording alone. And if a team is unsure whether a prompt change helped, the answer involves testing on held-out examples.

Quiz me on this
A travel company's assistant answers questions from a set of hotel policy documents. When a guest asks about something the documents don't cover, the assistant invents a confident-sounding policy. What is the simplest prompt change to reduce this?
  1. Ask the model to answer every question in as much detail as possible
  2. Remove the policy documents so the model relies on its own knowledge
  3. Raise the temperature so the model considers more possible answers
  4. ✓ Tell the model to say "I don't know" when the answer isn't there
A bank's prompt tells its chatbot never to discuss investment advice. Testers find that cleverly worded requests still get investment tips, and the compliance team needs the rule enforced on every conversation. What should the bank add?
  1. A longer system prompt that repeats the rule in several places
  2. ✓ Amazon Bedrock Guardrails with a denied topic for investment advice
  3. Few-shot examples of the chatbot politely refusing investment questions
  4. A lower temperature so the chatbot gives more predictable replies
A team rewrote its prompt and the new version looks better on the five examples they kept testing with. They want confidence it will also work on real traffic. What does AWS recommend?
  1. Ship the new prompt now, since all five examples improved
  2. Test only on the five examples again, using a different model
  3. ✓ Check the final prompt on a hold-out set of unseen examples
  4. Raise the maximum output length and test the same five examples
A retailer's product-description prompt has grown over a year into two pages of rules added by different people. Some rules repeat, and some conflict, such as "keep it under 50 words" and later "explain every feature in detail". The output is now erratic. Which prompt engineering practice BEST addresses this?
  1. ✓ Rewrite it as one short, consistent set of instructions
  2. Append several more examples after the existing rules
  3. Raise the temperature so the model explores more options
  4. Switch to a model with a larger context window to fit it all
Specificity and concision in prompts
Give clear, complete instructions and specify the output you want, such as length and format, in as few words as needed.
Hold-out test set (prompt engineering)
Sample inputs kept aside while tuning a prompt and used only to check the final version on unseen data.
Default output instruction
Telling the model what to say when unsure, such as "I don't know", to discourage confident made-up answers.
Prompt instructions vs Amazon Bedrock Guardrails
Prompt rules can be worked around; Guardrails screens inputs and outputs against set policies on every request.
Prompt optimization (Amazon Bedrock)
A Bedrock feature that analyzes a prompt and rewrites it for a chosen model, so you can compare it with the original.