Prompt Engineering tutorial
Learn to write prompts that get clear, correct and repeatable answers from AI models.
Course contents
Foundations
- Prompt Engineering — What a prompt is, what prompt engineering means, the four things every good prompt says, how to check replies by their result, and the write, run, check, improve loop.
- Understanding Prompts — What the model really receives: system, user and assistant messages, the chat template, why the whole chat is re-sent, instructions versus data, vague words, and dos versus don'ts.
- Prompt Structure — The six parts of a prompt (role, instruction, context, examples, input, output format), labelling them with headings or tags, a good order, templates, and checking the output format.
- Context and Grounding — Give the model the facts it needs: grounded prompts, picking the right context, letting the model say I don't know, asking for sources and checking them, and fitting context in the window.
Core Prompting Techniques
- Zero-Shot Prompting — Get results with no examples: why zero-shot works, the task, choices and format recipe, cleaning replies in code, measuring on many inputs, defining labels, and its limits.
- Few-Shot Prompting — Teach the model a pattern with examples: one-shot and few-shot, laying out examples, examples as chat turns, choosing varied and balanced examples, dynamic few-shot, and the cost of examples.
- Role Prompting — Set who the model is and who it writes for: roles, system prompts, personas, audience prompting, checking reading level and rules in code, and the limits of roles.
- Delimited and Template Prompting — Separate instructions from data with delimiters, keep data from breaking out of its tags, label several documents, build and fill templates, and get structured output you can check.
Advanced Prompting
- Step-by-Step Prompting — Break big tasks into steps: numbered steps in one prompt, showing each result, prompt chaining with checks between steps, planning a chain, and the game play pattern.
- Chain of Thought Prompting — Ask the model to reason before it answers: why chain of thought works, zero-shot and few-shot CoT, a fixed answer line, checking steps in code, and when CoT is worth the cost.
- Tree of Thoughts — Explore several lines of reasoning: generate distinct options, score them with weighted criteria, keep the best with a beam search, and a single-prompt version for everyday use.
- Self-Consistency Prompting — Ask several times and trust the most common answer: sampling with temperature, extracting answers, majority votes, agreement as confidence, accuracy versus cost.
Advanced Reasoning
- ReAct Prompting — Let the model reason and use tools: the Thought, Action, Observation loop, parsing actions in code, building a safe calculator and search tool, step limits, and tool safety.
- Meta Prompting — Use prompts to work on prompts: generate a prompt from a goal, critique it against a checklist, extract the rewrite in code, compare versions, and let tests decide which wins.
- Generate Knowledge Prompting — Ask for facts before the answer: the single-prompt and two-step versions, splitting facts from the answer in code, flagging facts to check, and how it differs from grounding.
- Prompt Evaluation and Optimization — Test prompts properly: build a test set, check outcomes in code, score and compare versions, find regressions and flaky cases, weight criteria, and set a release bar. Includes a graded challenge.
Practical Applications
- Writing Prompts — Prompts for emails, summaries, blog posts and reports: the reader, purpose, facts, tone and length, checking facts and length in code, outline-first writing, and avoiding filler.
- Research Prompts — Research safely with a model: plan sub-questions, judge sources, get claims with citations and check them, compare sources, catch invented links, and use the model as a tutor.
- Coding Prompts — Prompts for writing, explaining, debugging, refactoring and reviewing code: precise tickets, extracting and testing generated code, safe refactors, structured reviews, and keeping secrets out.
Advanced AI Workflows
- Advanced AI Workflows — Put the course together: long context with chunking and map-reduce, validating every reply, multimodal prompts, today's AI tools, and when to use retrieval, tools, code or a person instead.