Module 03
Prompt Engineering: Foundations to Advanced
Learn to brief a model the way you would brief a brilliant new hire: clear roles, rules, examples and output formats it cannot misread. You will move from single prompts to reusable templates, structured outputs, few-shot examples and step-by-step reasoning, then learn the chat formats open models expect and how to manage everything that goes into the context window.
By the end of this module you can
- write prompts that cover role, task, context, rules, output format and delimited input, and test them against awkward inputs
- get machine-readable answers with schemas and structured outputs, and validate what comes back
- build reusable, conditional prompt templates and choose between zero-shot, one-shot and few-shot prompting with measured results
- use chain-of-thought, self-consistency and personas where they help, and set effort on reasoning models instead
- explain chat templates such as Alpaca, ChatML and INST, and apply the right one to an open model
- design a context window deliberately: what goes in, in what order, and how to trim, summarise and keep it cache-friendly
Lessons
7 in this module- 01The anatomy of a good promptWrite a prompt as a complete briefing (role, task, context, rules, output format and delimited input) and test it against awkward inputs before trusting it.
- 02Structured outputs and custom formatsGet answers your code can trust by defining a schema with Pydantic, letting the API enforce it, validating the content, and using literal skeletons for human-readable formats.
- 03Reusable templates and conditional promptsTurn copy-pasted prompts into one versioned template with named placeholders and code-chosen sections, and test every combination it can render.
- 04Zero-shot, one-shot and few-shot promptingTeach a model your house rules with well-chosen examples, and prove the improvement by measuring zero-shot and few-shot prompts against a hand-labelled answer key.
- 05Chain-of-thought, self-consistency, Auto-CoT and personasUse step-by-step reasoning, majority voting, automatically built worked examples and personas where they help, and know when a reasoning model or plain code is the better tool.
- 06Prompt formats: Alpaca, ChatML and INSTExplain how chat messages are flattened into one string with a chat template, recognise Alpaca, ChatML and INST, and apply the right template to an open model with apply_chat_template.
- 07Context engineering and context window managementDesign what goes into every call: layer instructions, pinned facts, relevant documents, a rolling summary and recent turns, ordered stable-to-volatile so caching works and vital facts never get lost.