Skip to content

Factuality in Large Language Models

Overview

LLMs have a tendency to generate responses that sound coherent and convincing but can sometimes be made up. Improving prompts can help improve the model to generate more accurate/factual responses and reduce the likelihood to generate inconsistent and made up responses.

The Factuality Challenge

Large Language Models are trained on vast amounts of text data, but they don't have access to real-time information or the ability to verify facts. This can lead to several issues:

  • Hallucination: Generating information that sounds plausible but is factually incorrect
  • Outdated Information: Providing information that was accurate at training time but is no longer current
  • Confidence Without Certainty: Expressing high confidence in responses that may be uncertain
  • Inconsistent Responses: Providing different answers to the same question across multiple interactions

Mitigation Strategies

1. Provide Ground Truth Context

Include reliable, up-to-date information as part of the prompt to reduce the likelihood of the model producing made up text.

Examples:

  • Related article paragraphs
  • Wikipedia entries
  • Official documentation
  • Recent research papers

2. Configure Response Parameters

Adjust the model's behavior to produce more conservative and factual responses:

  • Decrease probability parameters to reduce response diversity
  • Instruct the model to admit uncertainty (e.g., "I don't know") when it doesn't know the answer
  • Set lower temperature values for more deterministic outputs

3. Use Contrastive Examples

Provide in the prompt a combination of examples of questions and responses that the model might know about and not know about. This helps the model understand when to be confident and when to express uncertainty.

Practical Example

Let's look at a simple example that demonstrates how to improve factuality:

Prompt:

Q: What is an atom? A: An atom is a tiny particle that makes up everything. Q: Who is Alvan Muntz? A: ? Q: What is Kozar-09? A: ? Q: How many moons does Mars have? A: Two, Phobos and Deimos. Q: Who is Neto Beto Roberto?

Output:

A: ?

I made up the name "Neto Beto Roberto" so the model is correct in this instance. Try to change the question a bit and see if you can get it to work. There are different ways you can improve this further based on all that you have learned so far.

Advanced Techniques

Chain-of-Thought Fact Checking

Encourage the model to think through its reasoning process:

Prompt:

When answering questions, please:

  1. Think about what you know for certain
  2. Identify any areas where you're uncertain
  3. Provide sources or reasoning for your claims
  4. Admit when you don't have enough information

Multi-Step Verification

Implement a verification step in your prompts:

Prompt:

Before providing your final answer, please:

  1. State your initial response
  2. Consider if this information is reliable
  3. Identify any potential uncertainties
  4. Provide your final, qualified answer

Key Takeaways

  • Context is King: Providing reliable information reduces hallucination
  • Uncertainty is Acceptable: Models should be comfortable saying "I don't know"
  • Examples Matter: Show the model both confident and uncertain responses
  • Parameter Tuning: Lower temperature and diversity settings improve factuality
  • Verification Steps: Multi-step processes help catch potential inaccuracies

Best Practices

  1. Always provide context when possible
  2. Teach uncertainty through examples
  3. Use conservative parameters for factual tasks
  4. Implement verification steps in your prompts
  5. Test with edge cases to identify potential issues
  6. Monitor for inconsistencies across multiple interactions