Source-linked AI summary

Spilled Energy in Large Language Models

Adrian Robert Minut, Hazem Dewidar, Iacopo Masi

arXiv:2602.18671v4cs.AIcs.CL

TL;DR

LLM hallucinations remain a critical challenge, while existing probe-based detectors struggle to generalize across tasks. This paper introduces training-free energy-based metrics from output logits and finds that spilled energy robustly detects hallucinations across synthetic and real-world tasks without task-specific training.

  • Problem

    LLMs generate incorrect or misleading information, while probe classifiers have limited cross-task generalization for hallucination detection.

  • Method

    The paper reinterprets LLM softmax layers as energy-based models and derives training-free spilled-energy and marginalized-energy metrics directly from output logits.

  • Results

    Across synthetic arithmetic and diverse real-world benchmarks, spilled energy separates correct from incorrect generations and generalizes robustly without additional classifiers or task-specific training.

  • Takeaways & Limitations

    Spilled energy provides a principled, practical signal for hallucination and error detection across tasks and LLMs without training overhead.

  • Takeaways & Limitations

    Spilled energy can produce false positives on punctuation and sentence-initial words, so detection is most reliable when restricted to semantically informative answer tokens.

Abstract

from arXiv · show

We reinterpret the final Large Language Model (LLM) softmax classifier as an Energy-Based Model (EBM), decomposing the sequence-to-sequence probability chain into multiple interacting EBMs at inference. This principled approach allows us to track "energy spills" during decoding, which we empirically show correlate with factual errors, biases, and failures. Similar to Orgad et al. (2025), our method localizes the exact answer token and subsequently tests for hallucinations. Crucially, however, we achieve this without requiring trained probe classifiers or activation ablations. Instead, we introduce two completely training-free metrics derived directly from output logits: spilled energy, which captures the discrepancy between energy values across consecutive generation steps that should theoretically match, and marginalized energy, which is measurable at a single step. Evaluated on nine benchmarks across state-of-the-art LLMs (including LLaMA, Mistral, and Gemma) and on synthetic algebraic operations (Qwen3), our approach demonstrates robust, competitive hallucination detection and cross-task generalization. Notably, these results hold for both pretrained and instruction-tuned variants without introducing any training overhead. Code available at: github.com/OmnAI-Lab/spilled-energy

1 INTRODUCTION

The paper introduces a training-free, energy-based framework for detecting LLM hallucinations by decomposing autoregressive decoding and measuring energy inconsistencies that correlate with errors. It targets exact answer tokens, avoids task-specific probes and activation ablations, and generalizes across tasks, datasets, and architectures.

  • Motivation and positioning: The method defines hallucinations broadly as LLM errors, including factual mistakes, biased outputs, and common-sense reasoning failures, with truthfulness concentrated in exact answer tokens.This follows Orgad et al. (2025) while avoiding a separately trained probe classifier for each task and dataset.
  • Training-free detection: The approach requires no additional training, trained classifiers, or activation ablations, while directly reading LLM values to support cross-task generalization.The introduction contrasts this with prior methods whose probing classifiers do not generalize across different tasks.
  • Energy-based formulation: The final vocabulary softmax is reinterpreted as an Energy-Based Model, decomposing the sequence probability chain into interacting EBMs during autoregressive inference.This decomposition provides the basis for tracking energy spills during decoding.
  • Energy-based metrics: The framework introduces spilled energy, measuring discrepancies between theoretically equivalent energy values across decoding steps, and marginal energy, measurable at one step.These are complementary, training-free metrics derived directly from the model’s internal output values.
  • Evaluation and results: The authors report strong cross-dataset generalization and competitive performance across nine benchmarks on state-of-the-art Llama and Mistral instruction-tuned models.The method’s detection signal separates correct and incorrect classes across datasets and reflects model confidence.

2 RELATED WORK

Prior work connects energy-based models to trustworthy AI, formalizes hallucinations as unavoidable information-conservation violations, and develops hallucination detectors using LLM internal representations. These strands motivate output-based energy analysis as an alternative perspective on reliability and factuality.

  • EBM applications to Trustworthy AI: Energy-based models have been used to improve deep-network reliability and interpretability, including energy-based out-of-distribution detection and reinterpretation of discriminative classifiers.Liu et al. (2020) uses energy scores as a robust alternative to softmax confidence, while Grathwohl et al. (2020) reframes discriminative classifiers as EBMs.
  • Foundations of Hallucination in LLMs: LLMs produce diverse errors, including bias, reasoning failures, and factually unsupported information, while prior theory frames hallucinations as unavoidable.Karpowicz (2025) identifies hallucination and imagination with information-conservation violations, and Xu et al. (2025) gives a formal learning-theoretic proof of their inevitability.
  • Detecting and Mitigating LLM Hallucinations: Orgad et al. (2025) detect hallucinations by training classifiers on LLM internal representations to predict answer correctness in a white-box setting.Their work suggests LLMs may encode more factual knowledge in latent subspaces than is revealed in their outputs.

3 BACKGROUND AND FOUNDATIONS

This section introduces Energy-Based Models, where scalar energies define normalized probability distributions, and establishes notation for viewing autoregressive LLMs as sequences of next-token discriminative classifiers.

  • Energy-Based Models: Energy-Based Models assign scalar energies to configurations, with lower energies corresponding to higher likelihood under a normalized distribution.The distribution is defined as pθ(x) = exp(−Eθ(x)) / Zθ, where Zθ is the partition function.
  • Energy-Based Models: Unlike deterministic neural networks mapping x to y, EBMs define full probability distributions over data or latent variables.
  • Notation: An LLM vocabulary V contains all input and generated tokens, while sequence notation represents token positions as xi ∈ V.The LLM is modeled as a transformer-based sequence-to-sequence function producing vocabulary-sized outputs.
  • Autoregressive Modeling: Autoregressive factorization models sequence probability through recursive conditional probabilities for each next token given preceding tokens.Each conditional is implemented by a transformer parameterized by θ that predicts a discrete distribution over V.

4 HOW ENERGY SPILLS IN LLMS

The section derives a sequence-level energy decomposition for LLM decoding and identifies a training-free discrepancy between energies that should theoretically cancel. This spilled energy, alongside marginalized energy, provides efficiently computable signals for localized error detection.

  • Energy decomposition: Conditional token probabilities decompose into interacting energy-based terms whose sequence-level quantities should cancel across consecutive decoding steps.The marginal term at step i cancels with the preceding sequence probability, yielding the correct language-modeling formulation.
  • Energy decomposition: The conditional probability can be represented as a ratio of two energy-based models derived directly from softmax logits.One energy extracts the sampled token’s logit, while the other marginalizes over all vocabulary indices.
  • Energy decomposition: LLM cross-entropy training supervises the ground-truth token index while ignoring broader complete-sequence constraints.This leaves the cross-step cancellation property unoptimized, making it usable for hallucination detection.
  • Spilled energy: Spilled energy is the difference between two theoretically equal energies measured at different time steps and in different model components.Its value should be zero when the energy is modeled correctly at timestep i.
  • Detection metrics: The proposed metrics are marginalized energy and spilled energy, computed efficiently from logits and evaluated on localized exact-answer token intervals for error detection.A scaled spilled-energy variant is also defined by multiplying spilled energy by the absolute marginal energy.

5 EXPERIMENTS

Experiments evaluate spilled energy first on controlled multi-digit arithmetic errors and then across nine real-world NLP benchmarks. The method reliably separates correct from incorrect generations, benefits from exact-answer localization and instruction tuning, and generalizes without training overhead, though punctuation and sentence-initial tokens can cause false positives.

  • Synthetic arithmetic: Spilled energy assigns lower values to correct and higher values to incorrect arithmetic generations, outperforming logits especially for subtle [1, 10] errors.This separation holds across all tested error ranges and language models.
  • Answer localization: Exact-answer localization improves average AuROC by approximately 24% for both spilled and marginal energy across four LLMs and nine benchmarks.The ablation compares performance with the exact answer against settings without exact-answer selection.
  • Real-world benchmarks: Across nine benchmarks, spilled energy consistently outperforms logit confidence and substantially surpasses probing classifiers under cross-dataset evaluation without training.Probing classifiers perform well in matched train-test settings but degrade sharply when transferred across datasets.
  • Instruction tuning: Instruction tuning raises Spilled Energy detection from 68.69% to 73.16% for LLaMA-3 and from 73.94% to 77.49% for Mistral, while LLaMA-3 logit confidence falls from 56.89% to 54.62%.Instruction-tuned models generally amplify spilled energy’s advantage, although marginal energy can slightly exceed it on non-aligned Mistral.
  • Limitations: Spilled energy can produce false positives on punctuation and sentence-initial words because probability mass is naturally distributed across many plausible next tokens.These inflated values may occur even in otherwise correct generations.

6 CONCLUSION

The paper reframes the LLM softmax layer as an energy-based model and introduces spilled energy as a training-free signal for detecting hallucinations and output errors. Synthetic arithmetic experiments show that it reliably separates correct from incorrect generations.

  • The softmax layer of LLMs is reinterpreted as an energy-based model.
  • Spilled energy measures discrepancies between energy values that should remain equal across consecutive time steps.
  • The discrepancy provides a strong, training-free signal for detecting hallucinations and errors in LLM outputs.
  • Synthetic arithmetic experiments show that spilled energy reliably separates correct from incorrect generations.

ETHICS STATEMENT

The work follows the ICLR Code of Ethics and evaluates a training-free error-detection method using public datasets and benchmark models. The authors disclose prior evaluation on a subsequently removed Math dataset and report no human-subject, privacy, or foreseeable-harm concerns.

  • ETHICS STATEMENT: The study uses only publicly available datasets and widely used benchmark models, without training new models or collecting additional data.Its focus is methodological: detecting errors and hallucinations in large language models.
  • ETHICS STATEMENT: The Math dataset was used solely for evaluation before its copyright-related takedown, without redistribution.Reported results are limited to demonstrating methodological effectiveness.
  • ETHICS STATEMENT: The work involves no personally identifiable information, sensitive content, or human subjects, and raises no foreseeable risks of harm.The authors characterize the approach as contributing to trustworthy AI through training-free, generalizable error detection.

REPRODUCIBILITY STATEMENT · A APPENDIX

The paper describes its experimental details, configurations, evaluation protocols, and datasets to support reproducibility. It also commits to releasing implementation code and reproduction instructions upon acceptance.

  • REPRODUCIBILITY STATEMENT: Experimental details are provided in the main text and Section B.These details include model configurations, evaluation protocols, and datasets.
  • REPRODUCIBILITY STATEMENT: The authors commit to publicly releasing code implementing their method upon acceptance.The release is intended to make the implementation available to the community.
  • REPRODUCIBILITY STATEMENT: The planned release will include instructions for reproducing all reported experiments.The instructions are part of the materials promised upon acceptance.
  • REPRODUCIBILITY STATEMENT: The reproducibility materials are intended to allow the community to verify the paper’s findings.Verification is presented as a purpose of the code and instructions release.
  • REPRODUCIBILITY STATEMENT: The authors state that the released materials will help the community build upon their work.This is identified as an additional purpose of the planned public release.
  • A APPENDIX: The reproducibility commitment covers both documentation and implementation support.Documentation appears in the main text and Section B, while implementation support is planned through code and reproduction instructions.

A.1 PARTITION FUNCTIONS PROOF USED IN EQ. (4) · A.2 THE ROLE OF TEMPERATURE IN SPILLED ENERGY · A.3 WHY SPILLED ENERGY SHOULD BE ZERO?

The appendix proves that sequence-level and marginal partition functions coincide, then analyzes how temperature reshapes spilled energy. It also explains why spilled energy should theoretically vanish when corresponding cross-step energy terms cancel.

  • A.1 PARTITION FUNCTIONS PROOF USED IN EQ. (4): The sequence-to-sequence proof treats next-token prediction as vocabulary-wide multiclass classification and defines the relevant energy terms at each prefix.At step i, the model receives the prefix {x_i−1:1} and outputs logits over vocabulary V.
  • A.1 PARTITION FUNCTIONS PROOF USED IN EQ. (4): Expanding the prefix probability shows that the global and marginal partition functions coincide, establishing the identity used in Eq. (4).The derivation expands the logarithm in Eq. (13), obtaining the expression in Eq. (11).
  • A.2 THE ROLE OF TEMPERATURE IN SPILLED ENERGY: Temperature scaling perturbs the balance between the two energy terms, thereby introducing a systematic error into spilled energy.The appendix interprets scaling logits by 1/τ as injecting or removing energy from the system.
  • A.2 THE ROLE OF TEMPERATURE IN SPILLED ENERGY: At τ →∞, logits approach zero, all tokens become equally likely, and the model degenerates into a uniform random classifier.This limit corresponds to maximum entropy over the vocabulary.
  • A.2 THE ROLE OF TEMPERATURE IN SPILLED ENERGY: At τ →0+, the distribution collapses onto the maximum-logit token, making the model highly deterministic.Temperature therefore changes both token probabilities and the cumulative error landscape traced by spilled energy.
  • A.3 WHY SPILLED ENERGY SHOULD BE ZERO?: Spilled energy measures the difference between energy representations that should cancel across consecutive autoregressive decoding steps.The denominator probability at step i matches the numerator probability at step i−1 in the language-modeling chain.
  • A.3 WHY SPILLED ENERGY SHOULD BE ZERO?: The shared quantity E(x1, x0) is measured once as marginal energy and once as logit energy across adjacent steps.The appendix denotes these terms with m for marginalization and ℓ for logits, rather than probabilities.
  • A.3 WHY SPILLED ENERGY SHOULD BE ZERO?: Spilled energy should be zero because −E_m(x1, x0) + E_ℓ(x1, x0) must cancel when the sequence energy is modeled correctly.The architecture and loss do not explicitly force equality, so a nonzero difference represents spilled energy.

B REPRODUCIBILITY · B.1 EXACT ANSWER TOKEN DETECTION DETAILS · C LLM USAGE

The paper follows Orgad et al.’s validated protocol for real-world comparisons and releases reproducibility resources. Exact answer spans are localized through task-dependent extraction, verified against generations, and mapped to tokens for spilled-energy analysis.

  • B REPRODUCIBILITY: Real-world comparisons use Orgad et al.’s publicly available implementation and established evaluation protocol.The authors also release code supporting reproducibility and pipeline integration.
  • B.1 EXACT ANSWER TOKEN DETECTION DETAILS: Exact answer spans [u, w] are localized within generated sequences using Orgad et al.’s heuristics and an auxiliary instruction-tuned LLM.This targets tokens carrying the semantic weight of the answer.
  • B.1 EXACT ANSWER TOKEN DETECTION DETAILS: Closed-label tasks use string matching, whereas open-ended tasks use Mistral-7B-Instruct to extract short answers from long-form generations.The two strategies accommodate fixed answer sets and variable answer forms.
  • B.1 EXACT ANSWER TOKEN DETECTION DETAILS: The auxiliary extractor receives the original question and generated answer, returning only relevant answer tokens or NO ANSWER when appropriate.The prompt follows Orgad et al. (2025).
  • B.1 EXACT ANSWER TOKEN DETECTION DETAILS: Invalid extractions and NO ANSWER outputs trigger up to five retries; unresolved cases are excluded to prevent incorrect token identification.Valid extracted strings must be substrings of the original generation.
  • B.1 EXACT ANSWER TOKEN DETECTION DETAILS: Validated answer strings are mapped to token indices [u, w], and spilled-energy analysis is performed over or pooled across that interval.The passage gives min-pooling as an example.
  • B.1 EXACT ANSWER TOKEN DETECTION DETAILS: Answer localization achieves accuracy comparable to Orgad et al. (2025) across full datasets using Mistral-7B-Instruct.Datasets with finite answer sets, including IMDB, Winobias, and Winogrande, were excluded because their answers are easy to locate directly.
  • C LLM USAGE: Large language models were used only for text polishing and minor exposition refinements, not for substantive research content or scientific conclusions.The authors state that methodology and conclusions were developed entirely by them.

D.1 ADDITIONAL RESULTS FOR SYNTHETIC ARITHMETIC

Additional synthetic-arithmetic results show that the method generalizes across LLMs, including Mistral-7B-Instruct v0.3 and LLaMa-3-8B, with higher-resolution histogram and ROC visualizations.

  • D.1 ADDITIONAL RESULTS FOR SYNTHETIC ARITHMETIC: The synthetic-arithmetic findings extend to Mistral-7B-Instruct v0.3 and LLaMa-3-8B, indicating generalization across LLMs.Figure 5 augments the main-paper results with these additional models.
  • D.1 ADDITIONAL RESULTS FOR SYNTHETIC ARITHMETIC: Figures 6 and 7 provide higher-resolution histograms and ROC curves in separate frames, adding results for Mistral-7B-Instruct v0.3 and LLaMa-3-8B.These figures extend and detail Figure 3 from the main paper.

D.2 ADDITIONAL QUALITATIVE RESULTS … D.3.2 FAILURE CASES

The additional results show that spilled energy performs reliably on knowledge-based factual content but can struggle with reasoning and numerical information, despite working well on math questions. Qualitative examples show agreement between logits and the proposed method on both correct and incorrect answers, including failure cases.

  • D.2 ADDITIONAL QUALITATIVE RESULTS: Spilled energy appears reliable for knowledge-based factual content but sometimes struggles with reasoning and numerical information, despite working well on math questions.The authors note that predicting when and why it succeeds remains difficult.
  • D.2 ADDITIONAL QUALITATIVE RESULTS: Figures 5–7 examine spilled-energy distributions and ROC curves across models, error ranges, and increasing difficulty on 13-digit Math Sums.Incorrect answers use uniformly sampled offsets from 1e3–1e4, 1e2–1e3, or 1–10 for easy, medium, and hard settings.
  • D.2 ADDITIONAL QUALITATIVE RESULTS: Figures 8–10 compare Orgad et al. (2025) with Spilled ∆E using Min pooling across datasets and Llama, Mistral, and Mistral-Instruct models.Positive percentage differences indicate cases where Spilled ∆E outperforms Orgad et al. (2025).
  • D.3 ADDITIONAL RESULTS FOR CROSS-TESTING WITH REAL WORLD BENCHMARKS: Table 5 reports AuROC hallucination-detection performance across nine benchmarks and different LLMs, including an average measuring cross-task generalization.The comparisons include Orgad et al. (2025) and Logit Eℓ under varied pooling methods.
  • D.3 ADDITIONAL RESULTS FOR CROSS-TESTING WITH REAL WORLD BENCHMARKS: The pooling window supports Max, Mean, Last Token, and After Last Token measurements, illustrated by energies 11, 2.08, −3, and 1, respectively.These values correspond to the example pooling-window measurements described in the additional results.
  • D.3.1 SUCCESS CASES: Across factual examples, the proposed method matches logits on correct and incorrect answers about planets, mammals, authors, photosynthesis, continents, animals, substances, and oceans.Examples include correct answers such as Mars, the Blue Whale, Leonardo da Vinci, carbon dioxide, Africa, cheetah, diamond, and the Pacific Ocean, alongside incorrect alternatives.
Loading 2602.18671v4…