DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Implementing Ethical AI: Practical Techniques for Aligning AI Agents With Human Values
  • AI Strategies for Enhanced Language Model Performance
  • Retrieval-Augmented Generation (RAG): Enhancing AI-Language Models With Real-World Knowledge
  • Navigating the Landscape of Smaller Language Models

Trending

  • Building a DevOps-Ready Internal Developer Platform: A Hands-On Guide to Golden Paths, Self-Service, and Automated Delivery Pipelines
  • Designing API-First EMR Architectures in .NET: Enabling Modular Growth in Compliance-Driven Systems
  • From Indicators to Insights: Automating IOC Enrichment Using Python and Threat Feeds
  • How to Format Articles for DZone
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. How to Reduce LLM Hallucination

How to Reduce LLM Hallucination

AI hallucinations stem from flawed training data and overcomplexity. Discover research-backed strategies to reduce hallucinations.

By 
Hiren Dhaduk user avatar
Hiren Dhaduk
·
Nov. 02, 23 · Analysis
Likes (1)
Comment
Save
Tweet
Share
3.9K Views

Join the DZone community and get the full member experience.

Join For Free

LLM hallucination refers to the phenomenon where large language models like chatbots or computer vision systems generate nonsensical or inaccurate outputs that do not conform to real patterns or objects. These false AI outputs stem from various factors. Overfitting to limited or skewed training data is a major culprit. High model complexity also contributes, enabling the AI to perceive correlations that don't exist.

Major companies developing generative AI systems are taking steps to address the problem of AI hallucinations, though some experts believe removing false outputs entirely may not be possible. 

Google has connected its models to the internet to ground responses in training data and web information. OpenAI uses human feedback and reinforcement learning to refine ChatGPT's outputs. They proposed "process supervision," rewarding models for correct reasoning steps rather than just final answers. This could improve explainability, though some doubt its efficacy against fabrications.

Still, companies and users can take measures to counteract and limit the potential harm from AI hallucinations. Ongoing efforts are needed to maximize truthfulness and usefulness while minimizing the risks. There are promising approaches, but mitigating hallucinations will remain an active challenge as the technology evolves.

Methods to Reduce LLM Hallucinations

1. Use High-Quality Training Data

Because generative AI models generate outputs based on their training data, using high-quality, relevant datasets is vital to minimizing hallucinations. Models trained on diverse, balanced, well-structured data are better equipped to understand tasks and produce unbiased, accurate outputs.

Quality training data allows them to learn nuanced patterns and correlations. It also prevents models from learning inaccurate associations.

2. Clarify Intended Uses 

Clearly defining an AI system's specific purpose and permissible uses helps steer it away from hallucinated content. Establish the responsibilities and limitations of a model's role to equip its focus on useful, relevant responses.

When developers and users spell out intended applications, AI has a benchmark for gauging whether its generations align with expectations. This discourages meandering into unrelated speculations that lack grounding in their training. Well-defined objectives offer context for the AI to self-evaluate its responses.

Articulate desired functions and uses so generative models can stay anchored in practical reality rather than conjuring up hallucinatory content disconnected from their purpose. Define the "why" to steer them toward truthful value.

3. Leverage Data Templates to Guide AI Outputs

Use structured data templates to limit AI hallucinations. Templates provide a consistent format for data feeding into models. This promotes alignment with desired output guidelines. With predefined templates guiding data organization and content, models learn to generate outputs adhering to the expected patterns. The formats shape model reasoning to stay tethered to structured realities rather than fabricating fanciful content.

Reliance on tidy, uniform data templates reduces room for uncertainty in the model's interpretations. It must hew closely to the ingestible examples. This consistency constrains the space for unpredictable meandering.

4. Limit Responses

Set constraints and limits on potential model outputs to reduce uncontrolled speculation. Define clear probabilistic thresholds and use filtering tools to bind possible responses and keep generation grounded. It promotes consistency and accuracy. 

5. Test and Refine the System Continually

Thorough testing before deployment and ongoing monitoring refine performance over time. Evaluating outputs identifies areas for adjustment, while new data can be used to retrain models and update their knowledge. This continual refinement counters outdated or skewed reasoning.

6. Rely on Human Oversight

Include human oversight to provide a critical safeguard. As human experts review outputs, they can catch and correct any hallucinated content with contextual judgment, which machines lack. Combining AI capabilities with human wisdom offers the best of both worlds.

7. Chain of Thought Prompting

Large language models (LLMs) have a known weakness in multi-step reasoning like math despite excelling at generative tasks like mimicking Shakespearean prose. Recent research shows that performance on reasoning tasks improves when models are prompted with a few examples that decompose the problem into sequential steps, creating a logical chain of thought. 

Simply prompting the model to "think step-by-step" produces similar results without handcrafted examples. Just nudging the LLM to methodically walk through its reasoning turn-by-turn, instead of creating freeform text, better focuses its capabilities for tasks requiring structured analysis. This shows prompt engineering can meaningfully enhance how logically LLMs tackle problems, complementing their fluency in language generation. A small hint toward ordered thinking helps offset their tendency for beautiful but aimless rambling.

8. Task Decomposition and Agents

Recent research explores using multiple AI "agents" to improve performance on complex prompts requiring multi-step reasoning. This approach uses an initial router agent to decompose the prompt into specific sub-tasks. Each sub-task is handled by a dedicated expert agent — with all agents being large language models (LLMs). 

The router agent breaks down the overall prompt into logical segments aligned with the capabilities of available expert agents. These agents may reformulate the prompt fragments they receive to leverage their specialized skills best. By chaining together multiple LLMs, each focused on a particular type of reasoning, the collective system can solve challenges beyond any individual component.

For example, a question asking for information about a public figure could be routed to a search agent, which retrieves relevant data for a summarization agent to condense into an answer. For a query about scheduling a meeting, calendar, and weather agents could give the necessary details to a summarization agent. 

This approach aims to coordinate the strengths of different LLMs to improve step-by-step reasoning. Rather than a single, generalist model, specialized agents tackle sub-tasks they are best suited for. The router agent enables the modular orchestration to handle complex prompts in a structured way. 

Summing Up

Mitigating hallucinations requires consistent efforts, as some fabrication may be inevitable in LLMs. High-quality training data, clear use cases, templates, rigorous testing, and human oversight help maximize truthfulness. While risks persist, responsible development and collaboration can nurture AI's benefits. If generative models are carefully steered with ethical grounding, their tremendous potential can be used for societal good. There are challenges but also possibilities if we thoughtfully guide these powerful tools.

AI Data (computing) ChatGPT Language model

Published at DZone with permission of Hiren Dhaduk. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Implementing Ethical AI: Practical Techniques for Aligning AI Agents With Human Values
  • AI Strategies for Enhanced Language Model Performance
  • Retrieval-Augmented Generation (RAG): Enhancing AI-Language Models With Real-World Knowledge
  • Navigating the Landscape of Smaller Language Models

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook