HALLUCINATION

When a model confidently produces something false or made up, such as an API that does not exist.

Zero retention: everything you type stays in this browser. Verify it yourself in DevTools.
Plain-language definition

What Does Hallucination Mean?

A hallucination is when an AI model produces something false or invented and presents it as fact. Examples include a citation to a paper that does not exist, a function that is not in the library, or a configuration option that was never real. It happens because language models generate likely-sounding text based on patterns, not by looking facts up, so a plausible guess and a true statement can look the same to the model. Hallucinations are less common in newer models and when the model has the real information in front of it, but they have not been eliminated.

Why Does Hallucination Matter?

In coding, hallucinations show up as calls to methods that do not exist, outdated syntax or made-up command flags. The fix is mostly about the setup: give the agent the real documentation or source, tell it the exact commands in an instructions file, and make it run tests or the build so invented code fails fast instead of reaching review.

What Does Hallucination Look Like in Practice?

Asked to read a config file, a model writes config.loadSync(path), but the library only has config.load(path). In a chat, you might not notice until later. In an agent setup where AGENTS.md says "run npm test before you finish," the test fails, the agent reads the error, and corrects the call itself. The hallucination still happened, but it never reached a human reviewer.

What Do People Get Wrong About Hallucination?

Hallucination is not the model lying. It has no intent; it is producing the most plausible continuation. That is also why asking "are you sure?" is not a reliable check. Verify against a real source or a test.

Which Terms Are Related?

  • RAG (retrieval-augmented generation): Looking up relevant documents first and giving them to the model, so its answer is grounded in real sources.
  • Eval: A repeatable test set with a scoring method, used to measure whether an AI system does its job and catch regressions.
  • Temperature: A setting that controls how random or predictable a model output is when it picks each next token.
  • Large language model: An AI model trained on vast amounts of text to predict the next token, which lets it write, answer questions and code.
  • Tool use: A model asking its application to run a defined function, such as search or run tests, and using the result.

All 28 terms are in the AI glossary. For models side by side, see frontier vs open-weight.

Frequently Asked Questions

Can hallucinations be prevented completely?

Not today. They can be reduced a lot by giving the model accurate sources, asking it to quote them, and checking results with tests or tools. Any output that matters should still be verified.

Does lowering temperature stop hallucinations?

It can make outputs more consistent, but a model can give the same wrong answer every time. Lower temperature reduces randomness, not ignorance. Better context and verification help more.

Why do models invent citations?

A citation has a predictable shape, with authors, a title and a year, so the model can generate one that looks right without retrieving a real source. Tools that search and quote real documents reduce this.

Was this helpful?