Module 4 Wrap-up: Engineering the Instruction
·AWS Bedrock

Module 4 Wrap-up: Engineering the Instruction

Hands-on: Robust prompt engineering to reduce hallucinations and maximize cost-efficiency.

Module 4 Wrap-up: The Instruction Engineer

You have graduated from "Asking" to "Engineering." You know that a professional AI prompt is multi-layered: a System Role that sets the rules, and a User Message that provides the task. You also understand that every token is a line item on your AWS bill.


Hands-on Exercise: The Hallucination Buster

1. The Goal

Write a prompt that extracts "Order ID" from a messy email. If the email does not contain an ID, the AI must return exactly: NONE.

2. The Implementation Plan

  1. Set a System Prompt that defines the role as a "Data Extraction Bot."
  2. Explicitly state the "NONE" rule in the system prompt.
  3. Set temperature: 0.
  4. Write a stopSequence for the newline character.

3. Verification

Test with an email that has an ID and one that doesn't. Ensure the AI doesn't apologize or explain itself ("I couldn't find an ID...").


Module 4 Summary

  • System Prompts: The foundation of AI behavior.
  • Separation of Roles: Prevents prompt injection and improves logic.
  • Token Optimization: Reducing word count to save money.
  • Temperature: Controlling randomness (0 for math/data, 0.7 for chat).
  • XML Tags: The secret weapon for Claude model accuracy.

Coming Up Next...

In Module 5, we look at Performance. We will learn how to implement Streaming Responses to provide that "ChatGPT-style" typing effect and how to optimize for Latency in professional web applications.


Module 4 Checklist

  • I have used the system parameter in a Converse API call.
  • I can explain why Temperature 0 is useful for data extraction.
  • I have practicing using XML tags to structure my data.
  • I can identify at least 3 ways to reduce the cost of a prompt.
  • I understand the difference between input and output token billing.

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn