← Latest papers
📊 statistics

MMD-Flagger: Leveraging Maximum Mean Discrepancy to Detect Hallucinations

The paper introduces MMD-Flagger, a test-time hallucination detection method for Large Language Models that leverages Maximum Mean Discrepancy to analyze the stability of outputs across varying decoding temperatures, enabling reliable identification of factual errors without ground-truth labels.

Original authors: Kensuke Mitsuzawa, Damien Garreau

Published 2026-08-20
📖 5 min read🧠 Deep dive

Original authors: Kensuke Mitsuzawa, Damien Garreau

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

In the rapidly evolving world of artificial intelligence, large language models have become powerful tools capable of generating human-like text, answering complex questions, and even assisting in autonomous decision-making. However, these systems possess a persistent flaw: they sometimes produce statements that sound fluent and confident but are entirely factually incorrect. This phenomenon, known as hallucination, poses a significant safety risk, especially when these models are deployed in critical areas like law, medicine, or autonomous driving, where a single false step could lead to disastrous outcomes. The core challenge for researchers is how to detect these errors in real-time without access to a "gold standard" answer key. Since these models operate without external verification during live use, scientists must find a way to judge the reliability of an answer based solely on the model's own behavior. The key to this lies in understanding how the model reacts to slight changes in its internal settings; if a model is truly confident and grounded in fact, its answers should remain consistent even when the conditions of its generation shift slightly. If, however, the answer is a fabrication, the model's output tends to become unstable and erratic under those same shifts.

Building on this principle, a team of researchers from France and Germany has developed a new method called MMD-Flagger to catch these hallucinations. Their approach does not rely on checking facts against a database or training a new model to spot errors. Instead, it acts as a stability monitor that watches how a language model's output changes when the temperature of its generation process is adjusted. In the context of these models, "temperature" is a setting that controls how much randomness is introduced when the model chooses its next word. A low temperature makes the model very predictable and repetitive, while a high temperature allows for more creative and varied responses. The researchers hypothesized that a truthful answer would remain relatively stable across these different settings, whereas a hallucinated answer would wobble and change shape dramatically as the temperature shifted.

To test this idea, the researchers created a system that generates multiple versions of an answer for the same question, each time using a different temperature setting. They then compared the original answer against these varied versions using a statistical tool called Maximum Mean Discrepancy. This tool measures how different two groups of data are from one another. By plotting these differences across a range of temperatures, the system creates a visual path, or trajectory. The researchers found that when the model is telling the truth, this path is smooth and predictable, often rising steadily as the randomness increases. However, when the model is hallucinating, the path takes on a distinct, sharp U-shape. This dip in the middle of the curve serves as a clear signal that the model is struggling to maintain a consistent meaning, effectively flagging the response as untrustworthy.

The team evaluated this method using modern language models, including the Llama-3 and Gemma-3 families, on a benchmark dataset designed to test factual accuracy across multiple languages. They compared their new method against several existing techniques that rely on text similarity or internal model states. The results showed that the effectiveness of hallucination detection is highly dependent on the specific model architecture; while MMD-Flagger (Ensemble) achieved the best performance on Llama-3.1-8B and Gemma-3-4B, other estimators performed better on Llama-3.2-3B. The system proved flexible enough to work with various types of data extracted from the model, such as the raw meaning of words or the hidden layers of the neural network. In one specific test case involving a question about a cat in a TV show, the system successfully identified a hallucinated answer that other methods missed, catching the moment the model's output began to drift into nonsense as the temperature changed. Conversely, in a different case study regarding a Glasgow music group, the analysis revealed a scenario where MMD-Flagger failed to detect a hallucination that another method (KLE) correctly identified, highlighting that the trajectory of the model's output can sometimes remain deceptively smooth even when the content is incorrect.

Despite these promising results, the researchers acknowledge that the method has limitations. Because it requires generating many variations of an answer to build a reliable stability profile, it can be computationally expensive and slower than simply asking the model for an answer once. This makes it less ideal for applications requiring instant responses, though it remains a powerful tool for safety-critical systems where accuracy is paramount. The study suggests that by monitoring the stability of a model's output across different conditions, we can build a more trustworthy layer of oversight for artificial intelligence. This approach offers a way to audit the reliability of autonomous agents without needing to know the correct answer in advance, providing a crucial step toward safer and more dependable AI systems.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →