liveBook · Manning

Hallucination

As explained in Generative AI in Action

An AI hallucination is generated content that is coherent or plausible but factually unsupported, nonsensical, or fabricated.

A hallucination is generated output that makes something up or presents a fabricated or nonsensical answer as if it were sound. An LLM is trained to produce coherent, context-aware text, not necessarily factually accurate answers. In an enterprise chatbot, that distinction matters most when customers may rely on the response. section 1.4 section 1.5

Inaccurate but task-relevant context can prompt a hallucination. A larger context window is not automatically safer: it lets an application supply more information, but may also increase the complexity and uncertainty of the answer. Hallucinations can misinform users, disrupt business decisions, weaken customer trust, and cause financial or reputational harm. section 1.4 section 8.1.1 section 13.1.2

A plausible answer with a false claim

At Google’s Bard launch, a response about discoveries from the James Webb Space Telescope incorrectly said it took the first pictures of exoplanets. The answer’s conversational form did not make that claim reliable. section 13.1.2

Reduce exposure rather than expecting to eliminate hallucinations:

  • Provide accurate, current information. Ground answers in supplied data through retrieval-augmented generation (RAG), or frame a suitable task as summarization rather than open-ended question answering. section 13.1.2 section 6.8
  • Use prompt context and examples, and instruct a chatbot to say it does not know rather than invent an answer. Add pre- and post-generation checks where correctness matters. section 13.1.2 section 6.4.1
  • Tune generation settings for the task. Very high temperature can produce more hallucinations and nonsensical text; a large context window alone does not replace grounding. section 3.2.4 section 8.1.1
  • Keep a human responsible for the final decision in life-and-death situations, with AI acting as a copilot. section 1.5
Listing 3.11 Completions output with the temperature at 1.8
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,                #1
      "logprobs": null,
      "text": "\n\n1. ComfortGroom Pet Furnishing \n2. Pampered TreaBankant Carers \n3. Toptech Sunny Haven Promotion.",
      "content_filter_results"={...}
    },
    {
      "finish_reason": "stop",
      "index": 1,               #2
      "logprobs": null,
      "text": "\n\n1: Naturalistov ClearlywowGroomingz 
                    Pet Luxusia \n2: VipalMinderers Pet 
                    Starencatines grooming \n3: Brisasia 
                    Crownsnus Take Care Buddsroshesipalising",
      "content_filter_results"={...}
    },
    {
      "finish_reason": "length",
      "index": 2,
      "logprobs": null,
      "text": "\n\n1. TrustowStar Pet Salon\n 
              2. Hartipad TailTagz Grooming & Styles\n 
              3. LittleLoft Millonista Cosmania DipSavez 
                 Hubopolis ShineBright Princessly 
                 Prosnoiffarianistics Kensoph Cowlosophy 
                 Expressionala Navixfordti Mundulante Effority 
                 DivineSponn BordloveDV EnityzBFA Prestageinato 
                 SuperGold Cloutoilyna Critinarillies 
                 Prochromomumphance Toud",
                 "content_filter_results"={...}
    }
  ],
  ...
}

Compare the generated responses at temperature 1.8 with the lower-temperature examples: several names become nonsensical, illustrating why more randomness is not always useful. section 3.2.4

How Generative AI in Action covers it

How deep it goes
Defines fabricated output, explains likely causes, and lists mitigations without claiming hallucinations can currently be eliminated.
Examples
Uses Bard’s incorrect telescope claim and high-temperature text generation to illustrate factual error and nonsensical output.
What you can do after
Apply it via prompt engineering and RAG to reduce unsupported answers, while retaining human oversight for consequential decisions.
How it connects
Links hallucination to prompt engineering, retrieval-augmented generation, temperature, context windows, grounding, and human oversight.

Also explained in

Compare how 29 books explain hallucination →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Generative AI in Action. The section links point to the parts of the book it draws on.