CoachnestCoachnest
Sign InGet Started
Back to course

Prompt Engineering Mastery: From Fundamentals to Production

…
—
Contents
1

What Is Prompt Engineering?

ReadingFree
2

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

Reducing Hallucinations

Reading10m
24

Cost, Latency & Optimization

Reading10m
25

Final Assessment — Prompt Engineering Mastery

Quiz15m
←→navigate lessons
Chapter 5 of 5·Module 5 · Evaluation, Safety & Production
Lesson 23 of 25Reading10 min

Reducing Hallucinations

#Reducing Hallucinations¶

A hallucination is confident, fluent, wrong output. You can't eliminate it, but you can engineer it down dramatically.

Why Models Hallucinate¶

Recall Module 1: an LLM predicts plausible next tokens, not true ones. With no grounding and a question beyond its knowledge, the most "plausible-sounding" continuation is often a confident fabrication.

The Hierarchy of Fixes (most → least effective)¶

  1. 1Ground with retrieval (RAG) — give it the facts to read instead of recall (Module 4). Biggest single lever.
  2. 2Use tools for exact tasks — calculator, code execution, DB lookups via tool calling. Don't ask the model to be a database.
  3. 3Give an explicit "I don't know" path:
    text
    3 lines
    1If the answer is not supported by the context, respond exactly:
    2"I don't have enough information to answer that."
    3Do not speculate.
  4. 4Demand citations — "cite the source id for each claim." Unsupported claims become visible and verifiable.
  5. 5Chain-of-thought / verification — ask it to reason, then check its own answer against the context before finalising.
  6. 6Lower temperature — for factual tasks, temperature 0 reduces creative drift.

Self-Verification Pattern¶

text
5 lines
1Step 1: Draft an answer.
2Step 2: For each factual claim, quote the exact supporting
3        sentence from the context. If you cannot quote
4        support, delete the claim.
5Step 3: Output only the verified answer.

What Does Not Reliably Work¶

MythReality
"Just tell it: do not hallucinate"Weak on its own — it doesn't know when it's wrong
"Bigger model = no hallucination"Reduces, never eliminates
"High confidence wording = correct"Confidence ≠ accuracy in LLMs

Practical Recipe¶

RAG for knowledge + tools for computation + explicit "I don't know" + required citations + temperature 0 + an eval set that measures hallucination rate.

Combine them. No single trick is sufficient; the stack is.

Mindset: Don't ask "how do I make it never lie?" Ask "how do I make wrong answers rare, visible, and verifiable?"

Previous

Prompt Injection & Security

Next

Cost, Latency & Optimization

Use ← → arrow keys to navigate between lessons