TL;DR
This paper introduces LOS-Net, a lightweight, learnable model designed to detect hallucinations and data contamination in LLMs using only their output probability distributions. By moving beyond simple heuristics that look only at the probability of the chosen token, the authors demonstrate that the "shape" of the entire next-token distribution contains vital signals that significantly improve detection accuracy and transferability across different models.
What Problem Does This Paper Address?
As LLMs are deployed in sensitive areas, two major hurdles remain: Hallucination Detection (HD)—identifying when a model makes things up—and Data Contamination Detection (DCD)—identifying if a model is regurgitating copyrighted or benchmark training data.
Most existing "gray-box" methods (which don't require access to the model's internal weights) rely on Actual Token Probabilities (ATP). These methods use hand-crafted heuristics (like taking the mean log-probability or the "Min-K%" tokens) to flag suspicious outputs. However, the authors argue that ATP is an incomplete signal. For example, a model might assign a 0.5 probability to a token in two very different scenarios: one where the remaining 0.5 is concentrated on a single alternative (high competition), and another where it is spread across thousands of tokens (high uncertainty). Current methods treat these identically, missing the rich "signature" hidden in the full distribution.
Methods
The authors propose the LLM Output Signature (LOS), which combines the sequence of chosen token probabilities (ATP) with the full Token Distribution Sequence (TDS)—the entire probability vector over the vocabulary at each step.
To make this high-dimensional data manageable, they introduce LOS-Net:
- Preprocessing (Top-K): Since vocabularies can exceed 1 million tokens, they sort the distribution at each step and keep only the top $K$ probabilities (e.g., $K=1000$). This makes the input size constant and model-agnostic.
- Rank Encoding: They explicitly encode the rank of the actual token within the sorted distribution. This provides the model with context about how "surprised" the LLM was by the token it eventually produced.
- Architecture: LOS-Net is a small, encoder-only Transformer (approx. 1M parameters). It treats the sequence of distributions as a structured data modality, learning to spot the specific patterns associated with fabrication or memorization.
- Theoretical Unification: The authors prove that LOS-Net can mathematically approximate a broad class of existing heuristic-based methods (which they term "Gated Scoring Functions"), essentially positioning LOS-Net as a learnable generalization of previous research.
Datasets
The researchers evaluated LOS-Net across several benchmarks:
- Hallucination Detection: HotpotQA (fact-checking), IMDB (sentiment analysis), and "Roles in Movies" (biographical facts).
- Data Contamination: WikiMIA (Wikipedia excerpts) and BookMIA (a dataset of books known to be in LLM training sets vs. books released after the training cutoff).
- Target LLMs: Mistral-7b, Llama3-8b, Pythia-6.9b/12b, and Qwen-2.5-7b.
Key Insights and Ideas
- The Distribution Shape Matters: The "gap" between the top-predicted token and the rest of the distribution is a powerful indicator of model confidence that simple token probabilities ignore.
- Learning Beats Heuristics: Instead of researchers trying to find the "perfect" math formula to aggregate probabilities, a small neural network can learn complex, non-linear patterns of uncertainty that are specific to hallucinations or memorization.
- Model-Agnostic Signatures: Because LOS-Net operates on sorted probabilities rather than specific token IDs, the patterns it learns are surprisingly transferable. A LOS-Net trained on Llama can often detect issues in a Mistral or Pythia model without further training.
- Efficiency: Despite being a neural network, LOS-Net is extremely fast, with detection latencies around $10^{-5}$ seconds per instance, making it viable for real-time monitoring.
Key Results
- Superior Accuracy: In Hallucination Detection, LOS-Net outperformed all gray-box baselines. On the IMDB dataset, it improved AUC by up to 31 units over the best non-learnable baseline.
- Rivaling White-Box Methods: In several cases, LOS-Net (which only sees outputs) performed as well as or better than "Activation Probes," which require invasive access to the model's internal hidden states.
- Contamination SOTA: On the BookMIA benchmark, LOS-Net achieved near-perfect detection scores (e.g., 0.95 AUC on Llama3-30b), outperforming "reference-based" methods that require running a second, separate LLM for comparison.
- Robustness to Restricted APIs: The authors found that even with $K=10$ (only seeing the top 10 probabilities), LOS-Net still outperforms most baselines. This is critical for use with commercial APIs (like OpenAI's) that limit the number of logprobs returned.
Limitations and Future Work
- Supervision Required: Unlike simple heuristics, LOS-Net requires a labeled dataset of "correct" vs. "hallucinated" or "clean" vs. "contaminated" examples to train the detector.
- API Constraints: While $K=10$ works well, some APIs provide even fewer logprobs or none at all, which would render this method unusable.
- Future Directions: The authors suggest extending this framework to detect machine-generated text (AI vs. Human) and exploring how multiple prompts (sampling) could be integrated into the LOS representation to further boost reliability.
Summary updated