Skip to content
Learn · AI Lessons · Free lesson

Prompt Engineering: Principles and Patterns

Most people who work with large language models reach the same realisation after a run of frustrating results: what you put into a model shapes what comes out in ways that are neither arbitrary nor magical. Prompt engineering is the discipline of understanding those relationships well enough to exploit them deliberately. The phrase attracts some scepticism, often dismissed as a temporary workaround until models become smart enough to understand plain instructions. That view misunderstands what is happening. Prompting is structured communication with a probabilistic system that predicts the most likely continuation of your input, not the coaxing of a reluctant machine into compliance. Every word you write shifts that probability distribution. This lesson treats prompt engineering as the applied discipline it is. You will learn why prompts work the way they do, master the core patterns experienced practitioners reach for, understand how to structure prompts for production systems rather than one-off experiments, and recognise the security and failure risks that can derail real deployments. You will also get a framework for iterating on prompts systematically, because good prompting is a craft practised over many iterations, not a secret unlocked by a single trick. By the end, you will have a principled toolkit rather than a bag of incantations.

Start this lesson freeFree forever. No card required.
Advanced 45 minutes AI for Practitioners Certificate upon completion

Create your free account

Unlock the full lesson, the quiz, and your verifiable completion.

Continue with Google
or
Continue with email

By continuing you agree to the Institute of AI terms of use and privacy policy.

Learners across the UK study with the Institute of AI
Open to everyone From the UK's professional body for AI 100% free, no card required
What you'll learn

By the end of this lesson, you will be able to:

  • Explain why every element of a prompt shifts the probability distribution over the next token.
  • Choose between zero-shot, few-shot, chain-of-thought, role prompting, and output control for a given task.
  • Structure prompts for production across the system, user, and context layers.
  • Build in mitigations for prompt injection, hallucination, and prompt leakage.
  • Develop prompts with evaluation sets, version control, and structured diagnosis rather than intuition.

Recommended before you start

None of these are hard requirements. The lesson is easier if they are already familiar, but everything it uses is explained along the way, so you can start without them.

  • Regular hands-on use of a large language model for real work.
  • A basic understanding of tokens, context windows, and what a system prompt does.
Join Others Learning AI

Free to start. Free to finish. Free to prove.

Start this lesson free
Inside this lesson

5 sections, about 45 minutes.

Section one is open to everyone. Create a free account to work through the rest and take the quiz.

01

How LLMs Actually Respond to Prompts

Free preview

To use prompts well, you need a working mental model of what happens when a model receives one. You do not need the mathematics of attention mechanisms; you need the mechanism at the level that changes how you behave. A large language model is fundamentally a next-token prediction system. It takes a sequence of text, represented internally as tokens (roughly, word fragments), and produces a probability distribution over what token should come next. It samples from that distribution, appends the result, and repeats until it hits a stopping condition. The model has no memory between sessions and no intentions, only a vast set of statistical associations encoded in billions of learned parameters. The direct implication is that every element of your prompt influences that distribution. A prompt is not a command issued to a compliant assistant; it is the context that shapes the space of likely responses. Change the context and you change the likely outputs. The context window is the total amount of text, including your prompt, any conversation history, retrieved documents, and the model's own output, that the model can see at once. It is a hard limit, not a soft one. Text that falls outside the window is simply not available to the model. Exceeding it causes earlier content to be dropped or produces an error, depending on the implementation. Context windows vary widely and continue to expand, but they remain a hard constraint in any real deployment. Practitioners who treat the context window as infinite build systems that fail under realistic load. There are two broad mechanisms by which a prompt influences behaviour. The first is instruction following: the model has been trained to treat certain patterns, typically imperative sentences or system-level directives, as instructions to execute. 'Summarise this in three bullet points' works partly because the model has been reinforced on many examples of that kind of instruction-response pair. The second is in-context learning: the model adjusts its behaviour based on patterns demonstrated within the prompt itself, with no change to its weights. Show it three examples of a task and it continues the pattern. This is why few-shot prompting works, and why the format, tone, and content of your examples matter so much. The distinction matters because it changes how you diagnose failures. If a model ignores an instruction, you have an instruction-following problem: rephrase, reposition, or strengthen the directive. If outputs are stylistically or structurally wrong despite following instructions, you likely need better in-context examples. A common mistake is to read model outputs as evidence of comprehension. The model does not comprehend your prompt the way a human colleague would; it produces a statistically appropriate continuation. This is why precision matters. 'Write a summary' invites a range of lengths, styles, and levels of detail. 'Write a two-sentence executive summary of the key risk in this document, in plain language, for a non-specialist audience' leaves far less to chance.

02

Core Prompting Patterns

Unlock free
03

Structuring Prompts for Production

Unlock free
04

Prompt Security and Failure Modes

Unlock free
05

Iterative Development and Evaluation

Unlock free
How it works

Walk away with proof, not just knowledge.

Step 1

Study the lesson

Work through every section at your own pace, from start to finish.

Step 2

Pass the quiz

A short set of questions on what you have just covered.

Step 3

Get your certification

Every completion has a certificate that you can share publicly for anyone to verify.

Your record of completion

Finish the lesson. Keep the proof.

The Institute of AI
Record of completion
Prompt Engineering: Principles and Patterns
Completed by
Your name
Quiz score
90%
theinstituteofai.co.uk/verify/lesson/…

Pass the quiz and the Institute of AI issues you a record of completion with your score. Every completion has its own public verification page, so the link you put on your CV or LinkedIn profile can be checked by anyone, at any time.

  • Verifiable by anyone, with no account needed
  • One link for your CV, email signature, or LinkedIn profile
  • Issued by the UK's professional body for AI
— Common questions —

Frequently asked questions.

Is this lesson really free?+
Yes. Every AI lesson from the Institute of AI is free to take and free to complete, including the quiz and your record of completion. There is no trial, no card, and no catch.
Do I need a technical background?+
This lesson is pitched at advanced level, so it helps to be comfortable with what is recommended above, though none of it is a hard requirement. Everything is explained in plain English, and if a term matters, the lesson covers it before using it.
How long does this lesson take?+
Around 45 minutes to work through, plus the quiz at the end. You can leave and come back at any point.
What do I get when I finish?+
A record of completion with your score, held on your profile. Each completion has a public verification page, so you can share a link on your CV or LinkedIn profile that anyone can check.
What is the Institute of AI?+
The Institute of AI is the UK’s professional body for artificial intelligence. It sets the standard of AI practice, works to that standard itself, and puts it within reach of everyone else. Its work runs across four areas: Accreditation, Practice, Platforms, and AI for All.

Join learners across the UK and start "Prompt Engineering: Principles and Patterns" today.

Free lessons, a quiz to test what you have learned, and a completion you can verify publicly. All from the UK's professional body for artificial intelligence.

The Institute of AI

Free to learn.
Yours to prove.

Every AI lesson is free to start, free to finish, and ends in a completion you can verify publicly.