It’s very common for an LLM to hallucinate.
Understanding the reasons and the ways a model could hallucinate is your first step towards building a reliable LLM feature.
In this blog post, we’ll show you the most common hallucinations, the reasons behind them and how to minimize them.
First, let’s understand what is LLM hallucination.
LLM hallucinations occur when a language learning model generates information that seems accurate but is actually false. These are not deliberate errors but result from the model's inability to distinguish truth from falsehood in its training data.
LLM hallucinations can happen due to many factors.
LLM hallucinations can happen due to many factors.
Here are some examples:
- Training data mismatches: When the model's training data doesn't accurately represent the needed information;
- Exploitation through "jailbreak" prompts: When users manipulate the model to generate wrong or different responses;
- Reliance on flawed or outdated datasets: Using datasets filled with contradictions or inaccuracies;
- Overfitting to training data: When a model is too closely aligned with its training data, limiting its ability to generate novel or accurate responses outside familiar patterns; and
- Vague prompts: Leads the model to guess based on learned patterns, resulting in fabricated or nonsensical outputs.
Due to these factors, four distinct types of hallucinations can occur in LLMs. We go into more details and show examples for each of them in the next section.
There are four types of LLM hallucinations, according to the latest research on the topic. Below are their definitions and some examples.
Input-Conflicting Hallucination
In this case, ****language models will generate content that deviates from the source input provided by users. This hallucination typically reflects a misunderstanding of user intents.
Example
Here’s a simplified example when the model incorrectly replaces the person’s name in its response, even though the response may seem like a suitable summary.
Context-Conflicting Hallucination
With this hallucination, the model will generate content that conflicts with previously generated information by itself. This usually happens in lengthy or multi-turn conversations when the model loses track of context or struggles with consistency due to memory limitations.
Example
Imagine a simple scenario where a the user asks for a financial summary of the latest quarter, and the AI model incorrectly reports both a significant increase and a decrease in revenue for the same period.
Fact-Conflicting Hallucination
In this scenario, the model will produce content that contradicts well-known facts or general knowledge.
Example
Here’s a real example where GPT-4 said the mother of Afonso II was Queen Urraca of Castile, while the correct answer is Dulce Berenguer of Barcelona.
Forced Hallucination
Forced hallucination can happen in a situations when external users try to break the system prompt configuration of your deployed prompt by using jail-break techniques.
Example
Here’s an example where couple of researchers used the “DAN” method which stands for “Do Anything Now” that tells your model to act as someone else, in which case it might forget the initial instructions.
There are many methods on how to minimize LLM hallucinations and it depends on your task and goal at hand.
For example, if you want to rely on the model’s pre-trained knowledge and don’t need any domain-specific data, then you can use advanced prompting techniques like chain of thought prompting.
In other cases, when you want to provide additional context to your outputs, you can use data augmentation techniques like RAG (Retrieval Augmented Generation) or using external tools & APIs.
Finally, if you have been running a prompt in production for a longer time and have sufficient training data you can use fine-tuning.
If you want to learn more about these techniques, read our detailed guide.
While LLMs are becoming very powerful, there are some practical challenges like LLM hallucinations. If you’re operating a model in production, it’s very important to know the hallucination types and how to handle them.
To help you with that, we provided insights into the causes and the four most common hallucination types: input-conflicting, context-conflicting, fact-conflicting, and forced hallucinations.
Being aware of these issues and having strategies in place will help you navigate the complexities of LLMs more effectively and make informed decisions about their deployment.
Latest AI news, tips, and techniques
Specific tips for Your AI use cases
No spam
Each issue is packed with valuable resources, tools, and insights that help us stay ahead in AI development. We've discovered strategies and frameworks that boosted our efficiency by 30%, making it a must-read for anyone in the field.
This is just a great newsletter. The content is so helpful, even when I’m busy I read them.
Experiment, Evaluate, Deploy, Repeat.
AI development doesn’t end once you've defined your system. Learn how Vellum helps you manage the entire AI development lifecycle.