Building with AILesson 68 of 80

Module 7 · Safety, security and the adversary

Reducing hallucination by mechanism, not by instruction

In this lesson

  • 9 min read
  • 7 reading sections
  • Knowledge check
  • Lesson 8 of 10 in this chapter

This chapter’s goalThreat-model an AI feature and defend it by architecture: name every channel by which untrusted text reaches the model and every channel by which its output reaches a privileged action or the outside world, restrict each with a control that does not depend on the model’s obedience, layer moderation and abstention with measured false-positive costs, and state plainly what a user must be told and what you cannot promise about a provider’s handling of their data.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

What “do not hallucinate” does

Almost nothing you can measure. The instruction asks the model to distinguish its supported outputs from its unsupported ones, and it has no access to that distinction. Every token is produced the same way, by the same process, whether or not the fact it completes is true. The model that writes a correct date and the model that writes a plausible wrong one are the same model doing the same thing. Asking it to stop is asking for a self-knowledge that is not there.

Temperature zero does not help either. It picks the most probable token, and the most probable token can be the confident wrong one. The sampling lesson in the first module explained why.

What does help is a set of mechanisms that change what the model is given, what it is allowed to produce, and what is checked afterwards. Here they are, roughly in order of effect.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Python, from Zero, for AI exam.

Stuck on something?Ask Sayali, your AI tutor

How to cite: Addaly (2026) ‘Reducing hallucination by mechanism, not by instruction’, in Building with AI. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/building-with-ai/reducing-hallucination-by-mechanism (Accessed: 29 November 2026).