TL;DR
When deploying Large Language Models (LLMs) via restricted APIs, detecting hallucinations and data contamination usually relies on simple, handcrafted heuristics over the probabilities of the generated tokens. This paper introduces LOS-Net, a lightweight model that learns directly from the full next-token probability distributions (the "LLM Output Signature"), achieving state-of-the-art detection accuracy with near-zero latency.
What Problem Does This Paper Address?
To safely deploy LLMs, we need to know when they are fabricating information (hallucinating) or leaking copyrighted training data (contamination). Doing this in a "gray-box" setting—where you only have API access to output probabilities rather than internal hidden states—is incredibly challenging.
Current gray-box approaches typically look only at the probabilities of the actual tokens generated, a metric the authors call Actual Token Probabilities (ATP). However, this discards a massive amount of information. For example, if a model predicts a token with a 50% probability, ATP treats it the same whether the remaining 50% is concentrated entirely on one alternative token (low uncertainty) or spread thinly across thousands of tokens (high uncertainty). This paper addresses this information loss by leveraging the full next-token probability distribution.
Methods
The authors introduce a unified data representation called the LLM Output Signature (LOS), which combines the standard ATP with the Token Distribution Sequence (TDS)—the complete next-token probability matrix across the entire vocabulary.
To make this high-dimensional data practical to work with, they implement a few clever tricks:
- Top-K Filtering: They sort each row of the distribution matrix and retain only the top $K$ probabilities, drastically reducing computational complexity and standardizing the input across different model vocabularies.
- Rank Encoding: They explicitly encode the rank of the actual token within the sorted distribution to capture the "gap" between what the model generated and what it most expected to generate.
- LOS-Net Architecture: They feed this processed signature into a lightweight (~1M parameters) encoder-only Transformer.
Crucially, the authors provide a theoretical proof showing that LOS-Net can mathematically approximate a broad class of "Gated Scoring Functions," meaning it unifies and generalizes many popular existing heuristic methods (like Min-K%).
Datasets
The approach was evaluated across two distinct tasks using several benchmarks:
- Hallucination Detection (HD): Evaluated on HotpotQA (multi-hop question answering without context), IMDB (movie review sentiment classification), and Movies (factual accuracy regarding actor roles).
- Data Contamination Detection (DCD): Evaluated on WikiMIA-32/64 (Wikipedia snippets categorized by creation timestamp) and BookMIA (excerpts from books used to simulate real-world copyright infringement auditing).
Key Insights and Ideas
- Uncertainty is in the Shape: The shape of the next-token probability distribution contains vital clues about model confidence that single-token probabilities completely mask.
- Top-K is More Than Enough: Surprisingly, taking just the top $K=10$ tokens captures over 99% of the total probability mass. This means LOS-Net can be effectively deployed even on highly restricted commercial APIs (like OpenAI's) that only expose a small number of top logprobs.
- Strong Cross-Model Generalization: The patterns of uncertainty captured by LOS-Net transfer remarkably well across different model sizes and architectures without requiring heavy retraining.
Key Results
- Massive Accuracy Gains: LOS-Net consistently outperformed existing gray-box baselines. On the IMDB hallucination dataset, it boosted AUC by approximately 31 points for Mistral-7b and 17 points for Llama3-8b compared to the best traditional baselines.
- Beating White-Box Probes: In several setups, the gray-box LOS-Net actually outperformed "Activation Probes"—methods that require full, restrictive white-box access to the model's internal hidden states.
- Blazing Fast Latency: LOS-Net features an incredibly low inference latency of $\sim 10^{-5}$ seconds per instance. This is five orders of magnitude faster than popular uncertainty-estimation methods like Semantic Entropy (which requires generating multiple alternative responses and takes ~7 seconds per sample), making LOS-Net highly viable for real-time, online error detection.
Limitations and Future Work
The primary limitation of LOS-Net is that it is a supervised learning approach. Unlike zero-shot heuristics that work out-of-the-box, LOS-Net requires a labeled dataset of hallucinations or contaminated text to train its transformer backbone.
For future work, the authors suggest extending the LLM Output Signature to incorporate "exact-token" flags or adapting the framework to handle multi-prompting scenarios to capture even richer behavioral signatures from the models.
Summary updated