# Hallucination

## <mark style="color:purple;">What is AI Hallucination?</mark>

{% hint style="warning" %} <mark style="color:red;">**AI hallucination**</mark> occurs when a <mark style="color:red;">**Generative AI Model generates false, misleading, or illogical information and presents it as fact**</mark>. This issue arises because LLMs are trained on vast amounts of text data and use statistical patterns to predict the next word in a sequence, rather than understanding the underlying reality of the content they generate.
{% endhint %}

### Why?

{% hint style="success" %}
Large language models hallucinate—producing confident but false outputs—because their training and evaluation processes reward guessing over admitting uncertainty.
{% endhint %}

{% embed url="<https://openai.com/index/why-language-models-hallucinate/>" %}

### **Some Real Life Cases:**

<details>

<summary>Case 1: Lawyer Citing Fake Cases Generated by ChatGPT</summary>

In 2023, New York lawyer Steven Schwartz utilized ChatGPT to draft a legal brief for a personal injury case. The brief included several fictitious court cases fabricated by the AI, which opposing counsel could not verify. When challenged, Schwartz and his colleague, Peter LoDuca, doubled down on their assertions until the court ordered them to provide the cases. Upon failing to do so, they were fined $5,000. Furthermore, the court mandated that any future filings involving generative AI content must explicitly disclose such use to ensure accuracy checks.

</details>

<details>

<summary>Case 2: AI-Generated Misinformation</summary>

AI-generated false information can spread rapidly, leading to public misunderstanding. An example of this occurred with Google’s Bard chatbot, which incorrectly claimed that the James Webb Space Telescope had taken the first image of an exoplanet. This misinformation quickly disseminated after its release, demonstrating the potential for AI to propagate erroneous news​.

<https://www.theverge.com/2023/2/8/23590864/google-ai-chatbot-bard-mistake-error-exoplanet-demo>

</details>

### Mitigation Techniques

{% hint style="success" %}

* **Use Better Large Language Models:** Whenever possible, utilize more powerful large models, as they tend to produce fewer hallucinations.
* **Use AI Search Engines:** Employ applications like Perplexity, which are optimized for search tasks using large models. These applications provide answers based on internet data content. (\*Although they can still have hallucinations, the chances are significantly lower.)
* **Human-in-the-Loop:** Have humans meticulously verify AI-generated indexes, cases, and other content.
* **Refine Your Prompts:** Use more detailed and sophisticated prompts and prompt structures to obtain more accurate results.
* **Use Advanced Reasoning LLM:** Choose models specifically trained or fine-tuned for logical reasoning and step-by-step problem-solving tasks, such as GPT-4 with chain-of-thought (CoT) prompting or Claude 3, which systematically reduce hallucinations through explicit reasoning processes.
  {% endhint %}

**Here is a page on the OpenAI Cookbook that provides guidelines and examples for developing guardrails to prevent hallucinations in AI models.**

{% embed url="<https://cookbook.openai.com/examples/developing_hallucination_guardrails>" %}

{% hint style="success" %}
**In summary, always meticulously verify any content generated by large models before using it.**
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aiandbusiness.com/learn/large-language-models-llms/hallucination.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
