AI Hallucinations: Can Memory Hold the Answer?

Author:Murphy  |  View: 28830  |  Time: 2025-03-23 11:56:57

|LLM|HALLUCINATION| MEMORY|

image created by the author using AI

A hallucination is a fact, not an error; what is erroneous is a judgment based upon it. – Bertrand Russell

Large language models (LLMs) have shown remarkable performance, but are still plagued by hallucinations. Especially for sensitive applications this is no small problem, so several solutions have been studied. Nevertheless, the problem persists even though some mitigation strategies have helped reduce them.

A Requiem for the Transformer?

Chat Quijote and the Windmills: Navigating AI Hallucinations on the Path to Accuracy

Why hallucinations originate is still an open question, although there are some theories about what leads to their emergence (ignoring context in the case of contextual hallucinations and so on). An interesting point raised in a recent article is that the definition of hallucination in humans and models is different. In humans it is defined as a hallucination:

"when you hear, see, smell, taste, or feel things that appear to be real but only exist in your mind" – source

So the authors sought to align the occurrence of hallucinations in LLMs with the psychological concept [2]. The idea is to use a more appropriate lexicon to describe these phenomena:

Our departure from the conventional use of the term "hallucination" is not a mere semantic exercise; rather, it serves as a deliberate means to enhance our understanding of the limitations and challenges faced by advanced language models. – source

image source: here [2]

These definitions from a psychological perspective show a connection with the concept of memory, so some authors have decided to provide LLMs with a memory.

One of the most popular approaches is the concept of providing an external memory. Retrieval augmented generation (RAG) is the most popular paradigm in which information appropriate to the query is sought in an external memory. This retrieved context is then used for generation.

RAG is Dead, Long Live RAG

Cosine Similarity and Embeddings Are Still in Love?

There are, however, alternatives in which a memory with read/write access is present. LLMs have in fact inherited the same limitations as the transformer, including the inability to be able to update the knowledge of an LLM. To remain relevant, we would need a system that allows us to remove undesired, incorrect, or obsolete facts while adding new information. Fine-tuning is an expensive solution, but it is impractical if we want to update the ‘memory' of the model often.

An alternative is to conduct edits while maintaining the original frozen model. One of the most interesting approaches is General Retrieval Adaptors for Continual Editing (GRACE) [4]. Instead of editing the weights of the model you edit the weights of the adaptors. These adaptors are interconnected to the layers of the model, and they modify layer-to-layer transformations for select inputs.

image source: here [4]

In contrast, for humans, it is possible both to make an update of one's knowledge and to use it to generalize for unseen data. Usually, this capability is provided by the hippocampus which is important for episodic memory (the hippocampus would be for fast learning and the neocortex for slow learning).

HippoRAG: Endowing Large Language Models with Human Memory Dynamics

Inspired by this idea in this paper they proposed Larimar [3], a class of models that has episodic memory controlled. In other words, the controller learns the episodic memory while LLM (slow memory) learns the summary statistics of the input distribution. The controller acts as a global storage for factual updates and conditions LLM in a generation. This global memory can then be read and rewritten. The system is an encoder-decoder transformer in which the output is used to write to memory or to search for information in memory to send to the decoder.

image source: here [3]

Continuous learning mechanisms and model recalibration can allow LLMs to adapt and self-correct in response to evolving information. – source

We now have models that can edit their own memory, and we can test whether this ameliorates hallucination issues. In this work [1], they tested this hypothesis using a hallucination benchmark dataset. WikiBio was obtained using GPT-3 to generate Wikipedia-like biographies for 238 subjects.

Here the authors test two models:

  • Larimar, built from a BERT large encoder, a memory matrix (already trained with 7.6 M entry from wiki-text), and a GPT2-large as decoder.
  • GRACE model, GPT2-XL already fine-tuned.

In the task, the authors use the hallucinated entry followed by a corrected entry obtained from Wikipedia. In this way, they inform the model (updating the matrix in Larimar or conducting adapter editing in GRACE). They then ask the model to generate output for a prompt, thus generating a new WikiBio entry.

image source: here [1]

As you can see from the image, in Larimar, the model, can rewrite memory, read from it or directly generate. The authors note that you can force the model to align latent representations at various stages of the pipeline. In simple words, align the written representation in memory and the read representation. This alignment makes it possible to reduce hallucinations.

image source: here [1]

A better taxonomy of hallucinations allows us to better explain how hallucinations emerge. For example, in a recent study published in Nature [5], they focused on confabulations (one of the subtypes of hallucinations defined earlier as a confidant but misleading output).

We show how to detect confabulations by developing a quantitative measure of when an input is likely to cause an LLM to generate arbitrary and ungrounded answers. Detecting confabulations allows systems built on LLMs to avoid answering questions likely to cause confabulations, to make users aware of the unreliability of answers to a question or to supplement the LLM with more grounded search or retrieval. – source

image source: here [2]

This shows us that hallucinations are a heterogeneous family and it is difficult to find a single solution to all types.

At the same time discussing it in terms of memory allows for the development of approaches that reduce hallucinations. Adding external memory not only impacts continuous learning but also reduces hallucinations. these approaches are intriguing and show interest in alternative solutions to solve transformer limitations.

What do you think? Curious to try these approaches? Let me know in the comments


If you have found this interesting:

You can look for my other articles, and you can also connect or reach me on LinkedIn. Check this repository containing weekly updated ML & AI news. I am open to collaborations and projects and you can reach me on LinkedIn. You can also subscribe for free to get notified when I publish a new story.

Get an email whenever Salvatore Raieli publishes.

Here is the link to my GitHub repository, where I am collecting code and many resources related to machine learning, Artificial Intelligence, and more.

GitHub – SalvatoreRa/tutorial: Tutorials on machine learning, artificial intelligence, data science…

or you may be interested in one of my recent articles:

Balancing Cost and Performance: A Comparative Study of RAG and Long-Context LLMs

Can Generative AI Lead to AI Collapse?

DeepMind's AlphaProof: Achieving Podium Glory at the Math OlympiadModel

Beyond Human Feedback: How to Teach a Genial AI Student

Reference

Here is the list of the principal references I consulted to write this article, only the first name for an article is cited.

  1. Kollias, 2024, Generation Constraint Scaling Can Mitigate Hallucination, link
  2. Barberette, 2024, Redefining "Hallucination" in LLMs: Towards a psychology-informed framework for mitigating misinformation, link
  3. Das, 2024, Larimar: Large Language Models with Episodic Memory Control, link
  4. Hartvigsen, 2022, Aging with GRACE: Lifelong Model Editing with Discrete Key-Value Adaptors, link
  5. Farquhar, 2024, Detecting hallucinations in large language models using semantic entropy, link

Tags: Artificial Intelligence Data Science Machine Learning Programming Technology

Comment