Prompt Engineering Tutorial 0/120 lessons ~6 min read Lesson 48

    Reducing Hallucinations

    A hallucination is when the LLM confidently states something false.

    Course progress0%
    Focus
    6 guided sections
    Practice signal
    Examples included
    Career prep
    Foundation builder

    Introduction

    A hallucination is when the LLM confidently states something false. Reducing them is half of production prompt engineering.

    Beginner analogy: Like a confident toddler — sounds sure, often wrong. Engineering removes the false confidence.

    Understanding the topic

    Core concepts to understand:

    • Ground answers in retrieved context (RAG).
    • Ask for sources or 'I don't know' as a valid answer.
    • Lower temperature on factual tasks (0 or 0.1).
    • Verify with a second prompt.
    • Use a smaller, calibrated model for fact retrieval.

    Syntax reference

    Visual workflow / architecture:

    bash
    User question
    Retrieve relevant docs (RAG)
    "Answer ONLY from the context.
    If not in context, say 'I don't know.'"
    Generate
    Verify claims appear in context

    Real-world use

    Perplexity, Glean, Hebbia — all built on hallucination-reducing prompt patterns + RAG.

    Best practices

    • Allow 'I don't know' as a first-class answer.
    • Always show sources to the user.
    • Hard-fail downstream code on unverifiable claims.

    Hands-on exercise

    Interview preparation — practice these questions:

    • Q1. What is a hallucination?
    • Q2. How reduce hallucinations programmatically?
    • Q3. Why does RAG help?
    • Q4. Role of temperature?
    Ready to mark this lesson complete?Track your journey across the entire course.