hallucination
Hallucination is when a generative model issues fluent but false or unsupported statements as though they were facts.
In coding contexts, hallucination most often shows up as invented APIs, methods, or package names that look idiomatic but don’t exist. Fabricated dependency names are repeatable enough that attackers register them on public indexes and wait for someone to install them, an attack known as slopsquatting.
Researchers split hallucinations into factuality errors, which contradict verifiable real-world facts, and faithfulness errors, which diverge from the supplied input or context. Older work on text generation draws a narrower line between intrinsic hallucinations, which contradict the input source, and extrinsic hallucinations, which introduce content not grounded in it.
Causes for hallucinations include the probabilistic nature of next-token selection, training biases, and incentives that favor confident outputs over admitting uncertainty.
Mitigation strategies include grounding via retrieval, calibration or abstention, decoding constraints, and hallucination-aware training.
Related Resources
Tutorial
Build an LLM RAG Chatbot With LangChain
Large language models (LLMs) have taken the world by storm, demonstrating unprecedented capabilities in natural language tasks. In this step-by-step tutorial, you'll leverage LLMs to build your own retrieval-augmented generation (RAG) chatbot using synthetic data with LangChain and Neo4j.
For additional information on related topics, take a look at the following resources:
- First Steps With LangChain (Course)
- Build an LLM RAG Chatbot With LangChain (Quiz)
Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.
By Leodanis Pozo Ramos • Updated Sept. 10, 2026