Prompt Engineering
Design reliable prompts using templates, variables, and structured techniques to keep instructions consistent while scaling experimentation across any LLM provider.
Why take this course?
Build prompts that stay consistent as your app grows. Learn how to separate fixed instructions from dynamic context, structure inputs with XML tags, and ship repeatable prompt patterns that work across providers.
Prerequisites
This course builds on concepts from the following courses. It is recommended to complete them first:
Course Modules
Master the fundamentals of prompt engineering for generative models: controlling randomness with temperature and top_p, structuring prompts with instruction/data/output indicators, few-shot learning, chain prompting, reasoning techniques (CoT, ToT), and output verification.
Learning Goals
- Control model output using temperature and top_p parameters.
- Structure effective prompts with instruction, data, and output indicators.
- Apply advanced components: persona, context, format, audience, tone.
- Use few-shot, one-shot, and zero-shot prompting effectively.
- Break complex tasks into chain prompts.
- Apply reasoning techniques: chain-of-thought and tree-of-thought.
- Verify outputs using examples, grammar constraints, and self-validation.
Concept Card Preview
Visuals, diagrams, and micro-interactions you'll see in this module.
Nina's Inconsistency Problem
Nina shipped her first LLM feature last week: a product description generator for her company's B2B platform. Monday's o…
Temperature and top_p: The Creativity Dials
Nina's first fix targets the randomness itself. Two parameters control how the model samples tokens:
Temperature fl…
Anatomy of a Prompt
With randomness tamed, Nina tackles the prompt itself. A well-structured prompt has three core ingredients and several o…
Write prompts that are clear, specific, and repeatable. Learn to separate fixed instructions from dynamic context with templates, write explicit prompts with concrete constraints, and guide models with few-shot examples.
Learning Goals
- Differentiate fixed instructions from variable context in prompts.
- Use double-brace placeholders to represent dynamic inputs in templates.
- Explain why LLMs need explicit context and stepwise instructions to follow tasks reliably.
- Write prompts that specify exact outputs, constraints, and formatting expectations.
- Describe how few-shot/multishot examples guide models toward the desired format and style.
- Select relevant and diverse examples, including edge cases, to reduce unintended patterns.
- Structure examples with <example> tags to make patterns explicit.
Concept Card Preview
Visuals, diagrams, and micro-interactions you'll see in this module.
Nina's Drift Problem
Nina's team ships a support chatbot. She writes the initial prompt. It works great. Then her colleague Marcus tweaks the…
What a Prompt Template Actually Is
A prompt template is a reusable prompt with fixed instructions and placeholder variables for the parts that change p…
Variable Substitution in Practice
The {{double_brace}} convention isn't magic — it's a find-and-replace contract between your code and your prompt.
Her…
Improve complex reasoning by giving the model structured space to think. Covers basic CoT, guided reasoning with XML tags, extended thinking mode, budgets, and when to use each approach.
Learning Goals
- Explain when chain-of-thought (CoT) helps and when to avoid it due to latency or verbosity.
- Prompt the model to think step-by-step for math, logic, research, or multi-factor decisions.
- Structure CoT with guided steps or XML tags (e.g., <thinking>, <answer>) to separate reasoning from final output.
- Configure thinking budgets safely and know when to batch long runs.
- Combine multishot patterns and structured frameworks with extended thinking.
- Apply reflection and self-checks to improve consistency on long reasoning tasks.
Concept Card Preview
Visuals, diagrams, and micro-interactions you'll see in this module.
Nina's Math Problem
Nina had a simple test for her model. A word problem: "A store sells 3 packs of 8 pencils. Each pencil costs $0.25. A cu…
Why Chain-of-Thought Works
The fix is deceptively simple: ask the model to show its work.
Chain-of-thought (CoT) prompting gives the model a s…
Zero-Shot CoT: The Magic Phrase
The simplest form of CoT requires no examples at all. Just append one line:
"Think through this step by step."
That's…
Shows how to segment instructions, context, and examples with XML tags to boost clarity, accuracy, and post-processing, with before/after examples.
Learning Goals
- Explain why XML-tagged prompts reduce ambiguity and misinterpretation.
- Apply consistent, nested tags to separate instructions, examples, formatting, and context.
- Combine XML tags with multishot prompting and chain of thought for structured reasoning.
- Transform unstructured prompts into tagged versions that preserve tone and format requirements.
Concept Card Preview
Visuals, diagrams, and micro-interactions you'll see in this module.
Nina's Prompt Injection
Nina ships her first customer support bot. It pulls the company's refund policy into the prompt and answers user questio…
Why XML Tags Improve Reliability
Without structure, the model infers boundaries from whitespace, formatting, and vibes. That works for simple prompts. It…
Common Tag Patterns
There's no official XML tag standard for prompts. Pick clear names and stay consistent within a project. Here are the pa…
Covers role prompting via the system parameter to shape expertise, tone, and focus, with side-by-side examples showing impact on legal and financial analysis.
Learning Goals
- Explain how system-role prompting shifts the model into a domain persona for accuracy and tone.
- Place role definition in the system prompt while keeping task instructions in the user turn.
- Experiment with different roles to surface varied insights on the same data.
- Compare outputs with and without role prompting to validate improvements.
Concept Card Preview
Visuals, diagrams, and micro-interactions you'll see in this module.
Nina's Generic Reviews
Nina pastes her API architecture doc into the model and asks: "Review this and give me feedback."
The response is polis…
How Role Prompting Focuses Responses
Ask a doctor about a persistent headache and you get a differential diagnosis, red-flag symptoms, and a referral recomme…
Five Elements of an Effective Role
A vague role like "You are a helpful assistant" is window dressing — it sounds intentional but changes nothing. Strong r…
Covers using assistant-prefill to steer model output, skip preambles, enforce formats, and maintain character. Supported by Anthropic and some other providers via the messages API.
Learning Goals
- Explain how assistant-prefill guides model continuation and which providers support it.
- Use prefilling to skip boilerplate and force structured outputs like JSON.
- Combine prefilling with role prompting to maintain character consistency.
- Avoid pitfalls like trailing whitespace and extended-thinking mode limitations.
Concept Card Preview
Visuals, diagrams, and micro-interactions you'll see in this module.
Nina's JSON Parser Breaks — Again
Nina's extraction pipeline was simple: send customer support tickets to the model, get back structured JSON, feed it int…
What Prefilling Is
The fix was elegant. Instead of asking the model not to add preamble, Nina supplied the first tokens of the response her…
What Prefilling Achieves
Prefilling is more than a JSON trick. It is a general mechanism for controlling how a response begins — and what begins…
Breaks complex tasks into chained prompts for accuracy and debuggability. Also covers using large context windows effectively: ordering long inputs, structuring multi-document prompts, and grounding answers in quotes.
Learning Goals
- Explain why chaining prompts improves accuracy and traceability on multi-step tasks.
- Design sequential subtasks with single-task goals and clear handoffs (e.g., XML tags).
- Use self-correction chains to review and refine outputs for high-stakes work.
- Position longform inputs near the top of prompts to improve relevance on large contexts.
- Structure multi-document prompts with XML tags for content and metadata.
- Ground responses by extracting and quoting relevant spans before analysis.
Concept Card Preview
Visuals, diagrams, and micro-interactions you'll see in this module.
Nina's All-in-One Prompt Falls Apart
Nina needs to analyze fifty user interviews. She writes one massive prompt: extract key quotes, identify recurring theme…
Why Single Prompts Break Under Complexity
Four failure modes explain why multi-step tasks collapse inside a single prompt.
Attention dilution. The model dist…
Sequential Chains: One Job Per Step
The most common chaining pattern is sequential: the output of step N becomes the input of step N+1. Each step has ex…