💻
RAG and LLM Bootcamp
  • Welcome to the Bootcamp
    • Course Structure
    • Course Syllabus and Timelines
    • Know your Educators
    • Action Items and Prerequisites
    • Kick-Off Session for the Bootcamp
  • Basics of LLMs
    • What is Generative AI?
    • What is a Large Language Model?
    • Advantages and Applications of LLMs
    • Bonus Resource: Multimodal LLMs and Google Gemini
  • Word Vectors, Simplified
    • What is a Word Vector?
    • Word Vector Relationships
    • Role of Context in LLMs
    • Transforming Vectors into LLM Responses
    • Bonus: Overview of the Transformer Architecture
      • Attention Mechanism
      • Multi-Head Attention and Transformer Architecture
      • Vision Transformers (ViTs)
    • Bonus: Future of LLMs? | By Transformer Co-inventor
    • Graded Quiz 1
  • Prompt Engineering and Token Limits
    • What is Prompt Engineering
    • Prompt Engineering and In-context Learning
    • For Starters: Best Practices
    • Navigating Token Limits
    • Hallucinations in LLMs
    • Prompt Engineering Excercise (Ungraded)
      • Story for the Excercise: The eSports Enigma
      • Your Task fror the Module
  • RAG and LLM Architecture
    • What is Retrieval Augmented Generation (RAG)?
    • Primer to RAG: Pre-trained and Fine-Tuned LLMs
    • In-context Learning
    • High-level LLM Architecture Components for In-context Learning
    • Diving Deeper: LLM Architecture Components
    • Basic RAG Architecture with Key Components
    • RAG versus Fine-Tuning and Prompt Engineering
    • Versatility and Efficiency in RAG
    • Key Benefits of using RAG in an Enterprise/Production Setup
    • Hands-on Demo: Performing Similarity Search in Vectors (Bonus Module)
    • Using kNN and LSH to Enhance Similarity Search (Bonus Module)
    • Bonus Video: Implementing End-to-End RAG | 1-Hour Session
    • Graded Quiz 2
  • Hands-on Development
    • Prerequisites (Must)
    • Docker Basics
    • Your Hands-on RAG Journey
    • 1 – First RAG Pipeline
      • Building with Open AI
      • How it Works
      • Using Open AI Alternatives
      • RAG with Open Source and Running "Examples"
    • 2 – Amazon Discounts App
      • How the Project Works
      • Building the App
    • 3 – Private RAG with Mistral, Ollama and Pathway
      • Building a Private RAG project
      • (Bonus) Adaptive RAG Overview
    • 4 – Realtime RAG with LlamaIndex/Langchain and Pathway
      • Understand the Basics
      • Implementation with LlamaIndex and Langchain
  • Final Project + Giveaways
    • Prizes and Giveaways
    • Suggested Tracks for Ideation
    • Sample Projects and Additional Resources
    • Submit Project for Review
Powered by GitBook
On this page
  • Types of Hallucinations and Examples
  • What causes hallucinations in LLMs?
  • Mitigating Hallucinations
  1. Prompt Engineering and Token Limits

Hallucinations in LLMs

PreviousNavigating Token LimitsNextPrompt Engineering Excercise (Ungraded)

Last updated 11 months ago

Hallucinations in LLMs occur when the model generates false or misleading information, and sometimes unfortunately in a convincing way. The phenomenon, interestingly, is so common that "hallucinate" became 2023's Word of the Year.

This tendency can be particularly challenging since LLMs generate responses based on patterns in their training data, not on a foundational understanding of facts or logical reasoning. As a result, while LLMs can produce text that is impressively coherent, they can also produce content that includes details entirely "hallucinated" or invented, particularly when the topic is outside their training data or the prompts lack specificity.

Types of Hallucinations and Examples

To fully grasp the concept, let's explore the various forms of hallucinations that LLMs might produce, accompanied by illustrative examples:

  • Sentence Contradictions: The model may generate a sentence that contradicts previous statements within the same text. For example, if an LLM first states, "The Eiffel Tower is located in Paris," and later claims, "The Eiffel Tower can be found in Berlin," it has produced a contradictory hallucination.

  • Prompt Contradictions: Here, the model's output directly conflicts with the factual information or instructions provided in the prompt. If asked to describe a vegetarian meal and the model includes "chicken" as an ingredient, this would be a prompt contradiction.

  • Factual Hallucinations: These are incorrect assertions about factual information. For instance, if an LLM incorrectly states, "Neil Armstrong landed on Mars in 1969," it's a clear case of a factual hallucination.

  • Nonsensical or Irrelevant Information: The model might generate content that is either irrelevant or makes no sense within the given context. For example, in response to a prompt asking for the history of the internet, if the LLM starts discussing the dietary habits of penguins, it's providing nonsensical or irrelevant information.

What causes hallucinations in LLMs?

These hallucinations can stem from various sources:

  • Data Quality: LLMs train on data from the internet, which is not always accurate or unbiased. This can lead to the replication of these inaccuracies in their outputs.

  • Generation Method: LLMs aim to balance between generating text that is creative and coherent and maintaining factual accuracy. This balance sometimes tips, compromising accuracy for fluency.

  • Input Context: Vague or nonspecific prompts can lead to misunderstandings by the LLM, resulting in inaccurate outputs.

Mitigating Hallucinations

To ensure Large Language Models (LLMs) are reliable for production use and minimize the risk of hallucinations, it's essential to employ a comprehensive approach focused on responsible AI practices and the strategic use of techniques like Retrieval-Augmented Generation (RAG). For a quick understanding, our approach can be categorized into two primary buckets:

1. Responsible AI and Awareness

  • Being Aware: Acknowledge the propensity of LLMs to produce hallucinations. Understanding this limitation is the first step towards addressing it.

  • Rigorous Testing: Conduct extensive testing across diverse prompts to identify and understand the model's vulnerability to hallucinations. This helps in fine-tuning the model to improve accuracy.

  • Human Oversight: Implement a robust mechanism for human review and intervention. This ensures any inaccuracies or fabrications are identified and corrected, maintaining the integrity of the output.

2. Building the Foundations for RAG

  • Retrieval-Augmented Generation (RAG): Prepares the ground for integrating RAG into the workflow. RAG combines the generative capabilities of LLMs with real-time, verifiable data retrieval, significantly reducing the occurrence and effects of hallucinations by anchoring the model's outputs in factual accuracy. By leveraging verified external information, RAG ensures the produced content is not only coherent but also reliably accurate.

In the following module, we'll dive into how Retrieval-Augmented Generation (RAG) functions and its critical role in enhancing the reliability of LLM outputs for production use. This advanced technique stands as a cornerstone in the ongoing effort to mitigate the challenges posed by hallucinations, paving the way for more robust and dependable applications of AI technologies.

😄