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.
By Leodanis Pozo Ramos • Updated Aug. 2, 2026