CoachnestCoachnest
Sign InGet Started
Back to course

Prompt Engineering Mastery: From Fundamentals to Production

…
—
Contents
1

What Is Prompt Engineering?

ReadingFree

How Large Language Models Actually Work

ReadingFree
3

Tokens, Context Windows, Temperature & Sampling

Reading11m
4

The Anatomy of a Great Prompt

Reading13m
5

Module 1 Knowledge Check

Quiz8m
6

Zero-Shot, One-Shot & Few-Shot Prompting

Reading12m
7

Role & Persona Prompting

Reading9m
8

Instruction Clarity, Delimiters & Decomposition

Reading11m
9

Controlling the Output Format

Reading10m
10

Module 2 Knowledge Check

Quiz8m
11

Chain-of-Thought Prompting

Reading12m
12

Self-Consistency & Tree-of-Thought

Reading11m
13

ReAct — Reasoning + Acting with Tools

Reading12m
14

Structured Output with JSON Schemas

Reading11m
15

Module 3 Knowledge Check

Quiz8m
16

Retrieval-Augmented Generation (RAG)

Reading13m
17

Prompt Templates, Variables & Chaining

Reading11m
18

Tool / Function Calling Patterns

Reading12m
19

Project — Build a Customer Support Assistant

Reading14m
20

Module 4 Knowledge Check

Quiz8m
21

Evaluating Prompt Quality

Reading12m
22

Prompt Injection & Security

Reading12m
23

Reducing Hallucinations

Reading10m
24

Cost, Latency & Optimization

Reading10m
25

Final Assessment — Prompt Engineering Mastery

Quiz15m
←→navigate lessons
Chapter 1 of 5·Module 1 · Foundations of Prompt Engineering
Lesson 2 of 25Reading

How Large Language Models Actually Work

#How Large Language Models Actually Work¶

You cannot reliably steer something you do not understand. This lesson demystifies LLMs just enough to make your prompting deliberate instead of superstitious.

Core Idea: Next-Token Prediction¶

An LLM does exactly one thing: given a sequence of tokens, it predicts a probability distribution over the next token.

"The capital of France is" → Paris (0.92) the (0.01) a (0.004) ...

It samples a token, appends it, and repeats. Everything else — reasoning, summarisation, coding — is an emergent behaviour of doing this extremely well over trillions of tokens of training text.

Implications for You¶

  1. 1The model continues patterns. If your prompt looks like a Q&A transcript, it continues the transcript. This is why few-shot examples work.
  2. 2Recency matters. Tokens near the end of the prompt strongly influence the next token. Put critical instructions last.
  3. 3It has no memory. Each API call is stateless. "Conversation" is an illusion created by re-sending history every turn.

Training Stages (Why Models Behave the Way They Do)¶

StageWhat happensEffect on prompting
Pre-trainingPredict next token on the internetBroad knowledge, mimics patterns
Instruction tuningTrained on (instruction → response) pairsFollows commands, not just continues text
RLHF / alignmentOptimised toward human preferencesHelpful, cautious, "assistant" persona

This is why a modern chat model responds to "Summarise this" instead of just continuing your sentence — instruction tuning taught it that instructions expect compliance, not completion.

What LLMs Are Bad At (By Design)¶

  • Exact arithmetic — it predicts plausible digits, not computed ones
  • Up-to-date facts — frozen at training cutoff
  • Knowing what it doesn't know — it will confidently hallucinate

Good prompting works with these properties (e.g. "show your steps" for math, "say 'I don't know' if unsure" for facts) rather than fighting them.

Mental model: An LLM is an extremely well-read improviser, not a database and not a calculator.

Previous

What Is Prompt Engineering?

Next

Tokens, Context Windows, Temperature & Sampling

Use ← → arrow keys to navigate between lessons