AI Tutorial
Home All Courses Blog Interview Prep ↗ 0%
1
Curious builder 0 XP earned · 300 to level 2
0 days Finish a lesson to begin
Badge collection
0 of 5 unlocked
small wins to finish your path
Next lesson →

Prompt Engineering

Prompt engineering is the practice of designing the instructions, context, and examples you give a language model so that it produces the output you need — reliably, not just once. This course treats prompts as engineering artefacts: you will structure them deliberately, constrain their output with schemas, diagnose their failures, and measure them with evaluations instead of gut feeling.

Last updated: 01 Nov, 2026

What is prompt engineering?

Definition · Prompt engineering

The discipline of designing, testing, and iterating on the input to a language model — instructions, context, examples, and output constraints — to make its behaviour accurate, consistent, and safe for a specific task.

A prompt that works once in a chat window is not the same as a prompt that works ten thousand times inside a product. Real inputs are messy, users are creative, and models change. The prompts that survive production share three properties: they are specific about the task, constrained in their output, and measured against a test set. That is what this course teaches.

Why it still matters as models improve

  • Models cannot read your mind. Better models follow instructions more faithfully — which makes clear instructions more valuable, not less.
  • Your context is unique. Your product's tone, rules, edge cases, and data formats exist only in your prompt.
  • It is the cheapest lever. Changing a prompt costs minutes; fine-tuning costs days and money.
  • Every AI system contains prompts. RAG pipelines, agents, classifiers, and evaluators are all driven by prompts.

Prompting vs RAG vs fine-tuning

ApproachWhat it changesBest forCost to try
Prompt engineeringThe instructions and examples sent with each requestFormat, tone, task definition, reasoning stepsMinutes
RAG (retrieval)The facts available to the model at request timePrivate, fresh, or large knowledge basesHours to days
Fine-tuningThe model's weightsConsistent style or format at scale, specialised behaviour, shorter promptsDays, plus data and training cost

Always start with prompting. Add retrieval when the model lacks knowledge. Consider fine-tuning only when well-engineered prompts and retrieval still fall short, or when you need to cut cost and latency at high volume.

The prompt engineering workflow

Workflow
1. Define the task      what input, what output, what counts as "correct"?
2. Collect examples     20-100 realistic inputs, including hard and weird ones
3. Draft the prompt     role, task, context, format, constraints, examples
4. Run and inspect      read the outputs - every one, at first
5. Evaluate             score outputs automatically against expectations
6. Diagnose failures    group errors by cause
7. Iterate              change ONE thing, re-run the eval, keep what improves the score
8. Version and monitor  store prompts like code; re-evaluate when models change

What you will learn

LessonWhat you learn
Anatomy of a promptThe seven building blocks of a prompt, delimiters, ordering, and turning vague prompts into precise ones.
System and developer promptsThe instruction hierarchy, what belongs in the system prompt, guardrails, and versioning prompts as code.
Few-shot examplesZero-, one-, and few-shot prompting; choosing, formatting, and dynamically selecting examples.
Structured outputsJSON mode, JSON Schema, Pydantic validation, and repair-and-retry loops.
Failure modes and fixesHallucination, format drift, injection, sycophancy, truncation — symptoms, causes, and fixes.
Evaluate a promptTest sets, metrics, LLM-as-judge, comparing prompt versions, and regression testing.

Prerequisites

  • Comfortable Python: functions, dicts, lists, JSON (Python for AI Developers).
  • Understanding of tokens, messages, roles, and temperature (LLM Fundamentals).
  • An API key for live experiments. Most code in this course runs offline with simulated models so you can learn the mechanics for free.
Terminal
python -m pip install openai pydantic python-dotenv

Key terms

TermMeaning
PromptEverything the model receives for a request: system message, user message, examples, and context.
InstructionThe part of the prompt that tells the model what to do.
ContextBackground information or data the model needs to complete the task.
DelimiterMarkers such as XML tags or triple quotes that separate parts of a prompt.
Zero-shot / few-shotPrompting without examples / with a small number of examples.
Structured outputOutput constrained to a machine-readable format, usually JSON matching a schema.
EvalAn automated test that scores model outputs against expectations.
Prompt injectionMalicious instructions hidden in user input or data that try to override your prompt.
Note

Prompting advice that worked for older models sometimes hurts newer ones — for example, shouting rules in capital letters or adding “think step by step” to a reasoning model. This course focuses on principles that hold across models, and on evaluation so you can verify what works for your model.

Course syllabus

Work through the lessons in order. Your progress is saved in this browser as you mark lessons done.

Syllabus