Sitemap
Srikanth Gandla

Srikanth Gandla

Srikanth is a healthcare technology innovator, entrepreneur, and AI strategist dedicated to transforming healthcare through data-driven clinical innovation.

Understanding AI Hallucinations

6 min readDec 4, 2024

--

Press enter or click to view image in full size

Definition of AI Hallucinations
AI hallucinations occur when a generative model produces outputs that deviate from factual or logical correctness despite plausible formatting. Mathematically, hallucinations can be considered outputs where:

where θ represents model parameters.

Comparison to Human Hallucinations

I. Human hallucinations result from neural misfiring’s or sensory disconnections, often linked to psychological or neurological states.

II. In AI, hallucinations are driven by statistical misalignments between training data and input queries.

Examples of AI Hallucinations in Generative Models

I. A large language model generates nonexistent citations.

II. An image generator creates distorted or surreal objects based on incomplete context.

Causes of AI Hallucinations

Overfitting of Algorithms
When the loss function L(θ) overly minimizes training data error but generalizes poorly:

Model Complexity and Architecture
Excessively deep architectures like transformer-based models (e.g., GPT) might overestimate probabilities for nonrealistic outputs due to suboptimal gradient propagation

where zi is the pre-softmax logit, influenced by attention weights.

Biases and Inaccuracies in Training Data

Training biases skew P(x ∣D), leading to systemic hallucinations.

Lack of Context in User Prompts
Limited conditioning leads to outputs with high entropy:

Impacts on Business

Disinformation Risks
Generative AI may produce P(misleading_info) due to incomplete training data. This leads to false narratives, damaging credibility.

Trust Erosion
Hallucinations reduce

where E accuracy​ represents expectation of output correctness.

Operational Risks
Fields such as healthcare (P(misdiagnosis), finance P(wrong_decisions), and security are vulnerable.

Mitigation Strategies

Human Oversight
Integrating decision thresholds:

Using Filtering Tools
Probabilistic filters limit outputs beyond a certain threshold of likelihood.

Regular Testing and Retraining
Minimize L validation(θ) over periodic intervals with updated data:

Leveraging Hallucinations for Innovation

Idea Generation
Exploiting high-entropy outputs for creativity:

Synthetic Data Generation
Using controlled hallucinations to augment datasets:

Applications in Storytelling and Art
Harnessing surreal outputs for new artistic or narrative frameworks.

Ethical Considerations

Deploying Generative AI Systems
Establish fairness and guard against P(harm)

Balancing Innovation with Responsibility
Frameworks like AI Ethics Guidelines ={T,F,E}

  • Transparency (T)
  • Fairness (F)
  • Explainability (E)

Future Directions:

Improving Model Architectures:

The architecture of AI models plays a critical role in mitigating hallucinations. Enhancements in the following areas can significantly reduce the likelihood of incorrect outputs:

  1. Attention Mechanisms: Improving multi-head self-attention to better focus on relevant portions of input context. For instance, refining the attention score calculation:

where Q (queries), K (keys), and V (values) can be adjusted to emphasize data quality and context relevance.

2. Sparse Models: Transitioning from dense models to sparse models, where only the most relevant pathways are activated during computation. This reduces spurious correlations that can lead to hallucinations:

Here, σ determines the sparsity by activating only a subset of pathways gi(x).

Get Srikanth Gandla’s stories in your inbox

Join Medium for free to get updates from this writer.

3. Reinforcement Learning with Human Feedback (RLHF): Using reward models to penalize hallucinated outputs:

Developing Loss Functions to Penalize Hallucinations

Modifying loss functions to specifically target hallucinations can be effective. This involves integrating hallucination penalties into the loss computation:

  • L task​: Standard task-specific loss (e.g., cross-entropy for classification or mean squared error for regression).
  • L hallucination​: Penalty for generating low-probability, incoherent, or unverifiable outputs.
  • λ : A hyperparameter controlling the trade-off.

For example, L hallucination could be based on the divergence between generated outputs and a curated reference dataset:

where P real is a distribution of verified factual data.

Leveraging External Knowledge Sources

Models should dynamically integrate external knowledge (e.g., APIs, databases) during inference to cross-check their outputs. This can be achieved by incorporating retrieval-augmented generation (RAG) techniques:

Press enter or click to view image in full size

Example: When answering a question, the model retrieves relevant articles or structured data before generating its response.

Frameworks for Responsible Use

Organizations deploying generative AI need comprehensive frameworks to ensure ethical and reliable use. Such frameworks can include:

  • Accuracy Audits: Periodic evaluations using datasets with known ground truths. Metrics such as BLEU, ROUGE, and perplexity can indicate alignment with correct outputs:
  • Bias and Fairness Testing: Quantifying disparities in outputs across different demographic groups:
  • Explainability Metrics: Developing tools to explain why a model produced a specific result using techniques like SHAP (Shapley Additive Explanations).

Contextual Fine-Tuning

Fine-tuning models on domain-specific data reduces hallucinations by aligning them closely with the intended application. Techniques include:

  • Task-Specific Pretraining: Pretraining on relevant datasets before fine-tuning:
  • Few-Shot Learning with Prompt Engineering: Adapting large models with a minimal amount of task-specific data:

Ongoing Research in Modular Architectures

Modular architectures, where specific components handle distinct tasks, can isolate and mitigate the causes of hallucination:

  • Composable Modules: Each module optimizes for a specific function:

Modular design simplifies debugging and targeted improvements.

  • Causal Models: Incorporating causal inference to better understand relationships between inputs and outputs:

Community Collaboration and Open Standards

Encouraging shared research and datasets for benchmarking hallucinations can accelerate progress:

  • Open Datasets: Creating standard datasets for hallucination evaluation.
  • Benchmark Metrics: Introducing measures like Hallucination Rate (HR):

Future efforts in these areas will likely combine advancements in architecture, optimization techniques, and ethical considerations to minimize hallucinations while maximizing the potential of generative AI systems.

References :

  1. Research on Generative Models: https://arxiv.org/abs/1706.03762
  2. Hallucinations in Language Models: https://arxiv.org/abs/2211.05241
  3. Reinforcement Learning with Human Feedback (RLHF): https://arxiv.org/abs/1706.03741
  4. Bias and Fairness in AI Systems : https://arxiv.org/abs/1908.09635
  5. Mitigation Strategies for Hallucinations: https://arxiv.org/abs/2005.11401
  6. Frameworks for Responsible AI Use: Floridi, L., & Cowls, J. (2019). A Unified Framework of Five Principles for AI in Society. Harvard Data Science Review.
  7. Evaluating and Benchmarking Generative AI: https://arxiv.org/abs/2006.14799
  8. Synthetic Data for AI Training: https://arxiv.org/abs/1711.04340
  9. Impact of AI Hallucinations on Business and Society: https://hbr.org/
  10. Causal Models and Modular Architectures
  • Pearl, J. (2009). Causality: Models, Reasoning, and Inference. Cambridge University Press.
  • Foundational text on causal inference, relevant for understanding model reasoning.

--

--