Module 03: Prompt Engineering
Prompt engineering is the discipline of designing inputs that reliably elicit desired outputs from large language models. It sounds simple. It isn't.
A poorly designed prompt produces inconsistent, hallucinated, or completely wrong outputs - even from a state-of-the-art model. A well-designed prompt transforms the same model into a reliable, precise tool for production workloads. The difference between the two is what this module teaches.
This module covers the full spectrum: from understanding why zero-shot instructions work at all, through the mechanics of chain-of-thought reasoning, to building production-grade systems with structured outputs and automated optimization. By the end, you'll have a principled toolkit - not just a bag of tricks.
What You'll Learn
- Why instruction-following works and how to exploit it systematically
- How to engineer prompts that produce consistent, parseable output
- The reasoning techniques (CoT, ToT, ReAct) that make models solve hard problems
- Security: how prompt injection attacks work and how to defend against them
- How to automate the prompt engineering process itself with DSPy
Module Progression
Lessons
| # | Lesson | What You'll Learn |
|---|---|---|
| 01 | Zero-Shot Prompting | Instruction anatomy, role personas, format control, when zero-shot fails |
| 02 | Few-Shot Prompting | In-context learning, example selection, label calibration, ordering effects |
| 03 | Chain-of-Thought | Step-by-step reasoning, self-consistency, least-to-most prompting |
| 04 | Tree-of-Thought | Multi-path exploration, BFS/DFS search, thought evaluation |
| 05 | ReAct Pattern | Reasoning + Acting, tool calling, the foundation of LLM agents |
| 06 | System Prompts & Context Design | Conversation roles, token budget, history compression, dynamic context |
| 07 | Prompt Injection & Security | Attack taxonomy, jailbreaks, defense strategies, threat modeling |
| 08 | Structured Output & JSON Mode | JSON mode, Pydantic, constrained decoding, schema design |
| 09 | Prompt Optimization & DSPy | APE, OPRO, DSPy signatures, compiling, evaluation-driven engineering |
Prerequisites
- Familiarity with how LLMs work (Module 01: Foundations)
- Basic Python and API usage
- Understanding of tokenization (Module 02: Tokenization & Embeddings)
Key Concepts
- In-context learning: Models learn from examples in the prompt without weight updates
- Emergent capabilities: Some techniques (CoT) only work above certain model scales
- Instruction following: The result of RLHF/instruction tuning - models trained to follow explicit directions
- Context window: The finite memory of a model - everything must fit in tokens
- Prompt injection: The security vulnerability unique to LLM systems
- Constrained decoding: Guaranteeing output format at the generation level
- DSPy: Treating prompts as learnable parameters in an optimizable pipeline
:::tip Start Here If you're new to prompt engineering, start with Lesson 01 (Zero-Shot) and work through in order. If you already know the basics and want production techniques, jump to Lesson 06 (System Prompts) or Lesson 08 (Structured Output). :::
