Lesson 2 · Beginner · 15 min
How Gemini responds: token prediction and hallucinations
Understand token prediction mechanics in Gemini. Learn why the model invents plausible facts and how to constrain its output with sources.
- Goal
- You will master Gemini's probabilistic token prediction to anticipate hallucinations and force the model onto verified sources.
- Skills
- Check

Your first attempt, unaided
Ask Gemini to cite three Supreme Court rulings on remote work from 2024 with case reference numbers. Check if those references actually exist.
Gemini possesses no internal reasoning or critical fact-checking mechanism: it predicts the mathematically most probable next token based on your prompt text. Lacking ground truth, it invents believable dates, citations, and statistics to produce a convincing answer. To secure factual accuracy, always supply reference documents and explicitly command the model to state when information is missing.
1Subword token prediction: a probabilistic engine
Subword token prediction forms the probabilistic engine driving all Gemini responses. The model does not query a verified database of facts: it continuously calculates the statistical likelihood of subsequent language units.
Language models slice input text into elementary chunks called tokens (averaging roughly four characters). Gemini evaluates probability distributions across thousands of candidate tokens to craft each sentence. While this mechanism produces fluent prose, it provides zero inherent factual guarantee. Deprived of clear reference documents, the system fills gaps with highly plausible hallucinations.
Mechanism Model action Workplace risk Recommended countermeasure Token segmentation Breaks words into subword fragments Math confusion on rare codes or figures Write critical numbers in digits and spelled out Probabilistic prediction Selects the most fluent next token Inventing convincing but false arguments Ground the prompt with verified source text Absence of verification Lacks an internal truth checker Expressing erroneous claims with confidence Enforce an explicit fallback instruction 

Diagram 'How Gemini builds an answer'Diagram generated by AI and reviewed 2A convincing bibliography that is entirely fictitious
A convincing bibliography that is entirely fictitious illustrates the model natural inclination to manufacture scholarly citations whenever users prompt for references without supplying authoritative source texts.
A compliance officer asks Gemini for recent appellate rulings on corporate remote work policies.
Weak prompt.
Provide three appellate court decisions from 2024 regarding mandatory remote work allowances, including exact docket reference numbers.Gemini outputs three neatly formatted legal citations with authentic-sounding docket codes, yet none of the referenced cases exist in official court records.
Strong prompt.
Based strictly on the attached official labor law bulletin [paste excerpt], list the reported rulings. If a docket number is not stated in the source text, write: Not specified in source.The difference. The model is strictly bounded to the supplied text excerpt, while the explicit negative fallback stops the probabilistic drive to fill knowledge gaps with fabricated citations.
3Trigger an hallucination then eliminate it through grounding
Trigger an hallucination then eliminate it through grounding to observe firsthand the fundamental difference between uncontrolled statistical completion and strict source-based document extraction.
Select a short press release. Ask Gemini a question about an unmentioned operational topic (such as factory capital expenditure when the release only covers recruitment). Note the hallucination, then re-prompt with strict grounding.
Run this prompt:
'Based strictly on the excerpt below, what total budget was allocated to the initiative? If the text does not state the amount, respond exactly: Unspecified in source.'
Self-evaluation rubric: (a) the initial unconstrained prompt reveals a plausible hallucination ; (b) the second prompt supplies the complete verified text ; (c) the negative boundary constraint eliminates false claims.
4Mistaking an assertive tone for factual correctness
Mistaking an assertive tone for factual correctness remains a perilous trap because the fluent prose of Gemini regularly conceals profound factual inaccuracies.
Asking Gemini 'Are you completely sure about this number?' initiates no external verification. The model merely optimizes for politeness and continuity, frequently reaffirming its initial hallucination with additional manufactured justifications.
Fix: never request verbal reassurance from the model; require verbatim quotations from the source text or run Google Search double-check.
Rule to remember: stylistic self-assurance in a large language model never constitutes evidence of factual accuracy.
5Quiz
Three questions, instant feedback. Each option comes with an explanation.
6Proof of mastery
Share your hallucination test: the ungrounded prompt that yielded false data, followed by the grounded prompt using a source snippet and abstention clause.
This lesson counts towards the Beginner badgeSee the four badges
Criteria
What you wrote at the start of the lesson
Going further
The glossary defines hallucination, grounding, and language model. The next lesson, Write a good Gemini prompt: the four PTCF pillars, introduces formal prompt architecture. You can also explore Gemini hallucination hunt to practice spotting subtle synthetic errors.
Frequently asked questions
What is a token in Gemini?
A token is a word fragment (roughly 4 characters in English). Gemini chunks text into tokens and mathematically computes the most probable subsequent token.
Why does Gemini hallucinate facts?
Because it does not query an internal truth database: it produces statistically coherent text sequences. Without explicit source constraints, it generates plausible but fictional statements.
How can hallucinations be stopped?
By supplying the reference text directly in the prompt and explicitly forbidding the model from relying on unstated external knowledge.