Ever asked a chatbot for a fact and got a wildly wrong answer? That weird moment is called an LLM hallucination.
💡 In Simple Words: A hallucination is when a large language model (LLM) makes up information that sounds right but isn’t true. It’s like a storyteller who adds details to keep the tale interesting, even if those details never happened.
What is Hallucination in LLMs?
An LLM (large language model) is a type of AI that learns to predict the next word in a sentence by looking at massive amounts of text. Hallucination happens when the model predicts words that form a statement that looks plausible but is actually false. Think of it like a GPS that sometimes tells you to turn onto a road that doesn’t exist – the directions sound logical, but the road isn’t real.
Types of Hallucination
| Type | Description | Example |
|---|---|---|
| Factual | Incorrect facts or dates. | "The Eiffel Tower was built in 1800" (actually 1889). |
| Reasoning | Wrong logical steps or conclusions. | Solving a math problem with a mis‑applied formula. |
| Instructional | Providing wrong steps for a task. | "To boil water, add salt first" (salt isn’t needed). |
Why Do LLMs Hallucinate?
- Training data gaps: The model never saw the correct answer during training.
- Probability over truth: LLMs choose words that are statistically likely, not necessarily true.
- Prompt ambiguity: Vague questions lead the model to guess.
- Length pressure: When asked for long answers, the model may fill in blanks with invented details.
How to Detect Hallucinations
- Cross‑check with a reliable source (Wikipedia, textbooks, official docs).
- Look for overly specific but unverifiable details (exact dates, names, numbers).
- Use a “grounding” prompt: ask the model to cite its source.
- Apply a sanity check: does the answer match common sense?
Ways to Reduce Hallucination
- Prompt engineering: Make the question clear and ask for citations.
- Retrieval‑augmented generation (RAG): Combine the LLM with a search engine that pulls real documents before answering.
- Temperature control: Lower the temperature setting (e.g., from 0.8 to 0.2) so the model picks safer, more common words.
- Fine‑tuning on verified data: Train the model further on high‑quality, fact‑checked text.
- Post‑processing filters: Run the output through a fact‑checking API.
Simple Mitigation Flowchart
graph TD
A[User asks a question] --> B[Model generates answer]
B --> C{Is answer cited?}
C -- Yes --> D[Check citation credibility]
C -- No --> E[Prompt for source]
D --> F{Credible?}
F -- Yes --> G[Accept answer]
F -- No --> H[Flag as possible hallucination]
E --> B
Quick Summary for Exams
- Hallucination = confident false output.
- Three main types: factual, reasoning, instructional.
- Causes: data gaps, probability bias, vague prompts, long‑form pressure.
- Detection: source check, look for unverifiable specifics, ask for citations.
- Reduction: clear prompts, RAG, low temperature, fine‑tuning, fact‑check filters.
📝 Likely Exam Questions
- Define hallucination in the context of large language models.
Answer: A hallucination is when an LLM produces an answer that sounds plausible but is factually incorrect, often because it prioritizes statistical likelihood over truth. - List and briefly describe two common types of LLM hallucination.
Answer: Factual hallucination – wrong facts or dates; Reasoning hallucination – incorrect logical steps or conclusions. - Explain why lowering the temperature parameter can help reduce hallucinations.
Answer: Temperature controls randomness; a lower value makes the model choose higher‑probability (safer) words, reducing the chance of inventing unlikely details. - What is retrieval‑augmented generation and how does it mitigate hallucination?
Answer: Retrieval‑augmented generation (RAG) fetches real documents from a database before the LLM generates text, grounding the answer in verified information. - Give one practical tip for a student to spot a hallucinated answer during a data‑science project.
Answer: Ask the model to provide a citation or source, then quickly verify that source; missing or bogus citations often signal hallucination.
#LLM#hallucination#data science#AI#exam prep
More from us