Hallucination is the tendency of large language models to generate statements that are plausible-sounding but factually incorrect, unverifiable, or entirely fabricated. A model might confidently state that “the Eiffel Tower was designed by Gustave Eiffel in 1889” (true) and then add that “it was originally painted bright red” (false). The false detail is a hallucination.
Hallucinations are not random gibberish. They are coherent, grammatical, and often contextually appropriate. This makes them especially dangerous because they are hard to spot. A user reading the output might not realize the model invented a citation, misstated a date, or confused two similar-sounding facts.
Types of hallucination
- Factual hallucination - Inventing statistics, dates, names, or events. “In 2019, OpenAI had 500 employees.” (The actual number was much smaller.)
- Source hallucination - Citing papers, articles, or websites that do not exist. “According to a 2023 study by Johnson et al. in Nature…” (No such study exists.)
- Confabulation - Filling gaps in knowledge with invented details. A model asked about a real person might add fictional biographical details.
- Logical hallucination - Drawing conclusions that do not follow from the premises. “All cats are mammals. All dogs are mammals. Therefore, all cats are dogs.”
- Instruction hallucination - Claiming to have performed an action it cannot do. “I have sent the email to your contact.” (The model cannot send emails.)
Why models hallucinate
Language models are trained to predict the next token, not to retrieve facts from a database. They learn statistical patterns in text: which words tend to follow which, which names co-occur with which dates. When asked a question whose answer was rare or absent in training data, the model generates the most statistically likely completion, which may be false.
Key causes include:
- Knowledge cutoff - Training data has an end date. Events, discoveries, and publications after that date are unknown.
- Training data errors - The web contains false information. Models learn these errors alongside truths.
- Ambiguity - A question might have multiple valid answers. The model picks one without acknowledging uncertainty.
- Overgeneralization - Patterns learned from common cases are applied to rare edge cases incorrectly.
- Attention limitations - In long contexts, models may miss or misattribute details from earlier in the prompt.
Detecting hallucinations
- Fact-checking - Cross-reference claims against reliable sources (Wikipedia, official databases, primary sources)
- Consistency checks - Ask the same question multiple times and compare answers. Hallucinations often vary between runs.
- Confidence probing - Ask the model to rate its own confidence. While not perfectly reliable, low confidence often correlates with hallucination.
- Source verification - When a model cites a source, verify that source exists and says what the model claims.
- Retrieval grounding - Use RAG to ground answers in retrieved documents rather than latent knowledge.
Mitigating hallucination
- RAG (Retrieval-Augmented Generation) - Force the model to answer based on retrieved documents rather than training memory. If the fact is not in the context, the model should say so.
- Prompt engineering - Instructions like “If you are unsure, say you do not know” or “Only use information from the provided context” reduce hallucination rates.
- Fine-tuning for honesty - Training models to express uncertainty and refuse to answer when they lack information.
- Tool use - Giving models access to calculators, search APIs, and databases so they can verify facts rather than guess.
- Human review - For high-stakes applications, having humans verify model outputs before they are used.
Hallucination vs creativity
There is a blurry line between hallucination and creativity. When a model writes a fictional story, it is inventing details by design. When it answers a factual question, invention is a bug. The same capability that makes LLMs creative storytellers makes them unreliable fact-sources. The difference is the user’s expectation and the context of the query.
How crawler.sh helps reduce hallucination
crawler.sh addresses hallucination at the source by providing models with current, verifiable, well-structured content:
- Fresh data - Crawl the latest documentation, news, and research rather than relying on stale training data. A model answering “What are the latest features?” needs current information.
- Source grounding - Each extracted document retains its original URL. RAG systems can cite these sources, letting users verify claims.
- Clean extraction - Removing ads, navigation, and boilerplate means the model focuses on factual content rather than marketing copy or irrelevant text.
- Complete context - JavaScript rendering captures dynamically loaded content that static crawlers miss, ensuring the model has the full picture.
- Structured Markdown - Well-formatted headings and lists help models parse hierarchy correctly, reducing misattribution errors where the model confuses related facts.
When used in a RAG pipeline, crawler.sh ensures that the retrieved context the model sees is:
- Current (not stale training data)
- Source-linked (verifiable)
- Clean (no misleading boilerplate)
- Complete (JS-rendered content included)
This does not eliminate hallucination entirely, but it dramatically reduces the rate by grounding the model in actual documents rather than latent statistical patterns.