LLM hallucinations
Галлюцинации LLM
An LLM hallucinates when it presents invented information as fact or adds claims that its source material does not support. A citation to a paper that does not exist is a common example.
What counts as a hallucination?
An LLM can write a fluent answer that is factually wrong or that goes beyond the evidence it was asked to use. It might invent a library method, attribute a quote to the wrong person, or add a decision to a meeting summary even though no one made that decision. An unsupported claim is not necessarily false: it could be true by coincidence. What matters in a task such as summarizing a document is whether the document supports it. Deliberate invention in a fiction-writing task is not a hallucination.
Why does it happen?
A language model generates text by predicting the next token, a piece of text such as a word fragment or a punctuation mark. It makes that prediction using the prompt and the text it has already generated. A plausible continuation is not the same as a verified statement. The model can reproduce the shape of an academic citation without checking that the paper exists. Missing context, outdated information, and questions that assume something false can all lead to plausible-looking errors.
Example: a product documentation assistant
A developer asks a chatbot whether version 2.4 of an SDK supports automatic retries. The search system returns a page about retries in version 3.0. If the chatbot says, “Yes, version 2.4 retries failed requests by default,” that page does not support the answer. The assistant should look for documentation for 2.4 or say it could not verify the behavior for that version. Saying “No” would be equally unsupported: a missing source is not evidence that the feature is absent.
How teams reduce the risk
- Retrieve the right evidence. Retrieval-augmented generation (RAG) gives the model relevant material at answer time. For versioned documentation, filter by version before generating the answer. Retrieval helps only if it supplies the evidence the question actually requires.
- Validate high-impact claims. Check that citations support the statements they accompany. For fields such as prices or availability, query the authoritative system instead of asking the model to reconstruct the value.
- Handle missing evidence explicitly. Depending on the product, the assistant can ask a clarifying question, explain what it could not verify, or route the request to a human.
Lowering the sampling temperature makes generation less random, not more grounded. A model can repeat the same false claim every time. Likewise, enforcing a JSON schema can fix the output structure without making the values correct.
How it comes up in interviews
A common question is how to tell whether retrieval or generation caused a bad answer. Check first whether the assistant received the evidence it needed, then whether its claims follow from that evidence. If no matching document reached the model, investigate retrieval; if the right passage was available but the answer contradicted it, investigate generation. Build an evaluation set with both answerable and unanswerable questions, and track unnecessary abstentions as well as unsupported claims. A bot that never answers may make fewer factual errors, but it is not more useful.