Manuscript Offprint
arXiv:2610.22723LEMON: Equivariant Learning over Attention Maps for Zero-Shot Misbehavior Monitoring on New LLMs
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Large language models exhibit misbehaviors that hinder deployment in high-stakes settings. One approach to monitor such failures is to use an external LLM as a monitor, but this is prohibitively expensive. A well-known and efficient class of monitors can detect such failures from internal representations (such as activation probes), but are tied to the model they were trained on, requiring costly re-annotation as new LLMs appear. A natural way to avoid this repeated annotation cost is to develop internal-representation based monitors that transfer zero-shot across LLMs. However, such transfer is challenging because internal representations are not naturally aligned across models; in particular, attention maps, known to contain signals of misbehavior, may differ in head function, ordering, and model depth. In this work, we characterize those cross-model attention mismatches as algebraic symmetries and use geometric deep learning principles to build LEMON (Language-model Equivariant MONitoring Network) an online graph neural network-based monitor, whose predictions are invariant under these symmetries. LEMON processes attention maps token-by-token, as they are produced and outputs a score after every token (or every window of W tokens) at negligible cost. Across 16 LLMs and six datasets, in the zero-shot cross-model setting, LEMON outperforms all baselines on both hallucination and jailbreak monitoring tasks, improving over the strongest by up to 14 ROC-AUC points.
Same signal, different coordinates

Our architecture: LEMON
the signal can sit at a different coordinate in each LLM
mismatch group

W-equivariant message passing
Online monitoring an unseen LLM

no labels from the unseen LLM;
the error is flagged
while generating
Figure 1: Our framework for zero-shot monitoring of misbehavior across LLMs. (left) The attention map is a stack of attention maps indexed by (layer, head). (middle) LEMON operates on a structured, attributed graph constructed from the attention maps and applies W-equivariant message passing. (right) LEMON can flag misbehavior during generation.
Equal supervision.
Code will be released soon.
1 Introduction
Despite their impressive capabilities, LLMs are known to exhibit undesirable behaviors: they may memorize training data (Carlini et al., 2021; Nasr et al., 2023), hallucinate responses (Pagnoni et al., 2021; Cao et al., 2022; Qiu et al., 2023), fall prey to flawed reasoning (Song et al., 2026), and be jailbroken (Wei et al., 2023; Zou et al., 2023), i.e., persuaded to generate harmful or otherwise restricted content. As LLMs find growing use in high-stakes domains, developing lightweight, online monitors that flag potential misbehavior on-the-fly becomes increasingly important.
Misbehaviors can be monitored with separate, capable LLMs acting as judges: they can process the provided prompt, along with the generated response to assess whether a specific misbehavior has occurred (Manakul et al., 2023; Souly et al., 2024; Mazeika et al., 2024). This approach is, however, fundamentally incompatible with online applications due to its prohibitive computational cost incurred by the additionally required LLM executions. A complementary and more agile class of monitors leverage instead the internal signals of the target LLM itself (Azaria & Mitchell, 2023; Kramár et al., 2026): data such as hidden representations, attention maps, output token log-probabilities. A pioneering example is that of probing classifiers (Belinkov, 2022), which train logistic regression models over activations to detect, e.g., the presence of the high-level concept of incorrectness. More recent approaches have generalized this idea by learning from more holistic views of the model's internal computation and developing tailored architectures to process them Bar-Shalom et al. (2025); Frasca et al. (2026); Samuel et al. (2026). With their low latency, these approaches are fundamentally more suitable to monitor the generation process on the fly. The best performing methods in this class, however, typically require access to annotated training datasets to estimate their parameters. This represents a limiting factor preventing their immediate application to newly released LLMs, as each requires curating new misbehavior datasets and monitor retraining.
Encouragingly, evidence suggests that internal representations preserve a similar underlying structure across models, differing primarily in the coordinates used to encode it. For example, (Huh et al., 2024; Morcos et al., 2018; Moschella et al., 2022) showed that the activation spaces of different models capture similar semantic information and can even be related through linear transformations. Likewise, (Ivanitskiy et al., 2025; Elhelo & Geva, 2025) found recurring patterns in attention maps across models, although, potentially, at distinct layer-head locations. These observations motivate the main question we tackle in this paper: “Can we develop a learnable monitor capturing shared, model-agnostic, features from attention maps that are predictive for misbehaviors?”
In this paper, we first demonstrate, through a concrete example of hallucination detection (see Figure 2), that a well-known attention-based heuristic score (Chuang et al., 2024) shows essentially no correlation across corresponding layers and heads across different models. We then show that these mismatches can be characterized by algebraic symmetries of multi-head attention. These correspond to transformations of the attention maps that change them while leaving the overall attention function unchanged. We argue that these should, therefore, be treated equivalently by the processing architecture, i.e., that we should design an invariant monitor. We formally characterize these symmetries, which intuitively correspond to independently permuting the attention heads within each layer of the model, while also accounting for shifts (translations) of the layers themselves . Motivated by prior work (Frasca et al., 2026), we formulate training a misbehavior monitor as a learning problem over an attention-induced directed graph, which we propose to endow with -structured attention scores as node and edge features, subject to the symmetries highlighted
Throughout, online monitoring means producing a score after each token (or each window of W tokens) during generation.
The resulting symmetry group is the wreath product , where captures independent permutations of the heads within each of the layers, and acts by cyclically permuting the layers.
above. We hence develop LEMON (Language-model Equivariant MONitoring Network), a graph neural network architecture designed to be invariant to these symmetries, thereby explicitly agnostic to cross-model mismatches and hence directly applicable to unseen LLMs in a zero-shot fashion (see Figure 1).
LEMON is evaluated comprehensively on two monitoring tasks, hallucination and jailbreak detection, across 16 LLMs and six datasets. In this zero-shot setting, LEMON substantially outperforms baselines while remaining extremely lightweight: it introduces less than 8% total overhead relative to standard generation. Moreover, LEMON operates online, allowing to halt a response mid-generation, so that a misbehavior can be detected before completion. We formalize this setting of selective generation along with token-level coverage and risk metrics, and show that it offers a useful trade-off between abstaining from generation and reducing error rates.
Contributions. (1) We characterize a class of algebraic symmetries in multi-head attention that induce layer-head mismatches across models. (2) We introduce LEMON, a symmetry-aware monitor that transfers zero-shot to unseen LLMs. (3) LEMON operates online, enabling selective generation with less than 8% overhead. (4) Across 16 LLMs and six datasets on hallucination and jailbreak detection, LEMON consistently outperforms prior baselines.
Equivariant Neural Networks. Invariance and equivariance principles guide the design of neural architectures for structured data by encoding known symmetries, such as rotations, translations (Kondor & Trivedi, 2018; Esteves et al., 2018; 2019; Cohen & Welling, 2016; Thomas et al., 2018), and permutations (Zaheer et al., 2017; Maron et al., 2018), so that models do not need to relearn them from data. A canonical example is Graph Neural Networks (GNNs) (Gilmer et al., 2017), with Message Passing Neural Networks (MPNNs) as a particular instantiation that aggregates neighboring information in a permutation-equivariant manner.
Cross-model representation universality. A growing body of evidence suggests that independently trained neural networks converge on similar internal representations. Prior work has focused mostly on activations: model stitching (Bansal et al., 2021), representation-similarity measures (Kornblith et al., 2019), the platonic representation hypothesis (Huh et al., 2024), and neurons that recur across LLM seeds and families (Gurnee et al., 2024). For attention, studies have found head roles that recur across models, e.g., induction and retrieval heads (Olsson et al., 2022; Wu et al., 2025; Elhelo & Geva, 2025) In both cases, the model appear to be converging toward similar computation, despite expressed in different coordinates. To the best of our knowledge, we are the first to move beyond hand-crafted procedures for recovering those coordinates, and instead learn a permutation-equivariant function that extracts the relevant signal for monitoring any unseen LLM zero-shot.
3 Extracting Universal Attention Representations
While attention computation (Vaswani et al., 2017) is widely used across LLMs, layer-head indices are not comparable across models: functionally similar heads may appear at different coordinates.
Motivating example. To make this coordinate mismatch concrete, we consider LookbackLens (LB) (Chuang et al., 2024), a per-token, per-head feature derived from attention scores for detecting hallucinations in LLMs. This setting allows us to test whether functionally similar signals occupy consistent coordinates across models. The basic idea behind the example is simple: LB takes on low values at specific layers and heads for tokens that are likely to hallucinate. However, we show that the particular layers and heads exhibiting this hallucination-associated pattern differ substantially across models. Here, we highlight only the key insights, deferring the full details of the example to Section A and further background on LB to Section B. We use the RagTruth data-to-text benchmark (Niu et al., 2024), and the two LLMs, LLAMA-2-7B (Touvron et al., 2023) and MISTRAL-7B (Jiang et al., 2023a), both of which have the same number of layers and heads – 32. The two heatmaps in Figure 2 (left) show this feature over each model's (layer head) grid: both exhibit a pronounced hallucination-associated signal, but at different coordinates. For example, at layer 30, head 13 (the highlighted cell), the feature is near-maximal in Llama-2-7B yet vanishes in Mistral-7B. The scatter plot in Figure 2 (right) makes this precise: each point pairs the two models' feature values at one matched ( ) coordinate. If heads and layers played the same roles in both models, the points would concentrate along the diagonal; instead they are essentially uncorrelated (Pearson across all cells), with the highlighted cell landing in the bottom-right corner (★). Although we present this insight using a single token for clarity, Section A shows that the same phenomenon holds across all hallucinated tokens.
Aligning heads is not enough. A natural fix to this mismatch is to undo it by relabeling each LLM's layer-head coordinates into a shared canonical indexing, thereby matching heads across models, and then training a standard classifier on the aligned features. We develop such an alignment procedure (Section E), but show experimentally (Section 4) that it is suboptimal compared to an architecture that is inherently invariant to these mismatches, which is the main focus of this work. We conclude this section with the central research question of this work:
Are the attention signatures of misbehavior shared across LLMs up to a relabeling of heads and layers? And can a monitor learn to read it in an unseen LLM?


Figure 2: Motivating example: Head and layer roles vary across LLMs. The same hallucinated token produces distinct head patterns, with matched values uncorrelated .
3.1 Preliminaries and Setup
Given a misbehavior identification task of interest, e.g., hallucination, we assume access to labeled data collected from LLMs, indexed by . Each example consists of a query , optionally accompanied by contextual information , and a response generated by the model. Each example is associated with a binary label , which may be defined either at the token level or at the whole sentence level. The complete dataset is given by, , where the superscript denotes the -th example associated with the -th LLM, and denotes the number of labeled examples available for model . We use the LLM's attention as its internal signal, representing each example by the attention map , where is the number of the considered tokens in the sentence, and and are the numbers of layers and heads in LLM . Thus, the training dataset is given by: , where is the attention map for the -th example from LLM . Our goal is to develop an architecture that learns to extract model-invariant attentional signals from , enabling zero-shot transfer to a previously unseen LLM for which no task-specific labeled data are available.
3.2 Cross-Model Attention Symmetries and Equivariant Layers
In what follows, we formalize cross-model mismatches in attention maps as symmetries and characterize them as group actions. We then introduce LEMON a network invariant to these symmetries.
Attention head-permutation symmetries. In a standard Multi-Head Attention (MHA) block at layer , each head produces an attention map and value projections , and the concatenated head outputs are mixed by an output projection . For any head permutation with the corresponding block-permutation matrix , inserting \mathbf{P}_\ell^\mathrm{B} \mathbf{P}_\ell^\mathrm{B}^\top = \mathbf{I} into the MHA output gives,

Figure 3: MHA symmetries.
(1)
Grouped (multi-query) attention shares query/key/value projections among subsets of heads; permutations must then act within each sharing group. The extension is straightforward.
where are the layer- token representations. Hence the relabeling , , leaves the function computed by the block unchanged – with a possibly different permutation at every layer, as indicated by the subscript . Figure 3 illustrates the case , where denotes the -th head block of .
Joint layer-head symmetries. Stacking MHA blocks over depths yields attention maps . Unlike heads, layers admit no exact interchange identity — they are sequentially composed, so their order matters — yet their absolute indices carry no fixed meaning across models of different depths. Following (Bar-Shalom et al., 2025; Kasten et al., 2024), we model layer relabelings by : a modeling prior, not an exact symmetry, that removes dependence on absolute layer indices across depths. Since the head permutations might be different across the different layers, we encode the joint symmetry as the wreath product – exactly the group whose elements pair a cyclic layer relabeling with an independent head permutation at every depth. The action, illustrated in Figure 4, is

Figure 4: Action of on for : rows are reordered by ; heads within each row by .
elements pair a cyclic layer relabeling with an independent head permutation at every depth. The action, illustrated in Figure 4, is
Tokens. Token order is meaningful, so the token axes admit no exact symmetry. Still, the absolute indices carry no shared meaning across tokenizers and sequence lengths, so we treat translation along the token axes as an approximate symmetry, modeled by the cyclic group acting on both axes by the same shift. Figure 5 visualizes the full symmetries of the attention map A.
In the next section, we use the symmetry analysis above to guide the design of LEMON, combining components suited to the data and

Figure 5: A symmetries.
its symmetries without necessarily enforcing exact invariance throughout. This is analogous to Vision Transformers with positional encodings outperforming CNNs despite breaking translation symmetry.
3.3 From attention maps to Graphs with Structured Features
Overview. The attention map A admits a natural graph representation, with tokens as ordered nodes and attention scores defining node and edge attributes. Motivated by CHARM (Frasca et al., 2026), we cast the task as learning on this attributed directed graph. Our formulation differs from (Frasca et al., 2026) in two key ways: (i) node and edge attributes retain their structured attention slices, which transform under the layer-head symmetry W developed in Section 3.2, and (ii) the graph is sequential, preserving token order. We then introduce LEMON, a message-passing-based architecture whose updates respect W and that operates online, producing scores token by token as the response is generated.
Attention graphs. Concretely, we view the attention as an attributed directed graph : each token position is a node with self-attention attribute (scores across all layers and heads); each directed edge carries cross-attention attribute (attention from token to token ). Importantly, these node and edge attributes are structured tensors rather than vectors.
Our Language-model Equivariant MOnitoring Network (LEMON) architecture. LEMON follows the Message Passing Neural Network (MPNN) framework (Gilmer et al., 2017), with the key distinction that the update function is W-equivariant. We focus here on the core construction and defer preprocessing and further implementation details to Section D. Let denote node features at layer , edge features, and the preceding-token neighbors of node . Each edge feature is initialized by applying a shared linear map to the corresponding attention score independently across layers and heads. For node features, we combine self-attention scores with token probabilities, a model-agnostic signal that is also comparable across models. More specifically, we concatenate self-attention scores with token probabilities and map the resulting features to with a shared linear layer.
LEMON's message passing. Our Message-Passing (MP) component builds on GINE (Hu et al., 2019), with the key modification that its update function respects the group symmetry W derived in Section 3.2. More specifically, at each layer l, an MPNN updates the node features according to,
where, crucially, is an update function that is -equivariant.
Constructing the update function . Building on the general characterization of linear -equivariant layers (Wang et al., 2020), we extend their construction to nonlinear neural networks, yielding a more general class of -equivariant maps. We define as follows:
where
where is the all-ones vector and and are any functions equivariant to and , respectively ; See Section C.1 for an illustration.
Two instantiations of up_W. We consider two W-equivariant variants of LEMON: LEMON-W, which mixes information across layers and heads, and LEMON-W-per-cell, which applies the same update independently to each layer-head cell (see Section D). This mirrors the difference between a full DeepSets (Zaheer et al., 2017) equivariant layer and its element-wise term alone.
After stacking several equivariant MPNN layers, we apply a causal cross-token transformer across nodes independently for each layer-head coordinate (see Section D). Finally, we apply a W-invariant prediction head, operating at either the node or graph level depending on the granularity of the task.
Response tokens use their model probability; prompt tokens use 0.
Note that, for clarity, Equations (4) and (5) omits features, although they are included in the implementation
LEMON is online. MP follows forward-only graph edges, the cross-token transformer attends only to past positions, and the prediction head acts independently across tokens. Hence, a node prediction depends only on tokens (see Figure 6). This has two consequences: (i) LEMON can score tokens (or window of tokens) as they are generated, incrementally adding each new node at linear cost in the prefix length rather than recomputing the full quadratic

Figure 6: LEMON is online.
graph. (ii) A prefix receives the same score online as within the completed response, so offline training on full responses and online deployment are provably the same computation. We note that CHARM (Frasca et al., 2026) also shares this online property.
4 Experiments: Monitoring for LLM misbehaviors with LEMON
In this section, we present a comprehensive empirical evaluation of LEMON for monitoring LLM misbehaviors, focusing on two: hallucinations and jailbreaks. Our evaluation consists of 16 LLMs, spanning six architecture families, sizes from 135M to 13B, and release dates from 2023 to 2025, and a diverse set of 6 datasets. We use the ROC-AUC ( 100) as our evaluation metric, consistent with prior work (Frasca et al., 2026; Azaria & Mitchell, 2023; Chuang et al., 2024). We report the main results here; additional results and experimental details are provided in Section G.
Training setup. Unless otherwise specified, we use a leave-one-out (LOO) setup. Given a pool of K LLMs, we train on K - 1 models and evaluate on the remaining held-out model, rotating the split so that each LLM serves as the test target exactly once. Thus, our LEMON monitor is always evaluated on unseen LLMs. Our LLM pool is the following K = 6 LLMs: LLAMA-2-7B, LLAMA-2-13B (Touvron et al., 2023), MISTRAL-7B (Jiang et al., 2023a), MISTRAL-NEMO-12B (Sreenivas et al., 2024), QWEN2.5-3B, and QWEN2.5-7B (Yang et al., 2024).
Methods in comparison. We compare LEMON against the following task-agnostic, learnable baselines : (i) CHARM (Frasca et al., 2026), a GNN-based architecture that operates on attention graphs but does not explicitly account for the equivariance properties considered in our approach; and (ii) Hidden-state probing (HS), which trains a probe on the LLM's hidden representations. We additionally compare against task-specific baselines, which we introduce separately in the corresponding experimental subsections.
4.1 Hallucination Monitoring
For our hallucination experiments, we use the RAGTruth benchmark (Niu et al., 2024), which consists of 3 token-level tasks: (i) Data2Text (D2T); (ii) Natural Questions (NQ); and (iii) Summarization (SUM). While RAGTruth provides labels for only a subset of the LLMs in our pool, we annotate the outputs of the remaining LLMs ourselves using QWEN2.5-32B as the labeling tool; See Section F for further details. Finally, LEMON, as well as all baseline methods described below, are trained on the union of the three tasks, while evaluation results are reported separately for each.
All trained baselines follow the same cross-LLM transfer protocol as LEMON.
We use hidden states from layer 24 of each LLM for probing. We pad the sequences to a fixed length to account for the different feature dimensions across LLMs.
Table 1: LOO results. Each row is one held-out LLM; every value is the AUC averaged over the three tasks. Per-task breakdown: Table 10. best per row; = second best.
| Held-out LLM | Prob | LB | HS | CHARM | LB+Align | LEMON (Ours) | |
|---|---|---|---|---|---|---|---|
| W | W-per-cell | ||||||
| Llama-2-7B | 57.8 | 48.8 | 52.9 | 45.5 | 61.3 | 71.4 | 74.9 |
| Llama-2-13B | 52.3 | 53.9 | 52.5 | 57.3 | 54.2 | 73.8 | 75.5 |
| Mistral-7B | 67.6 | 49.5 | 51.0 | 42.2 | 57.5 | 68.2 | 68.5 |
| Mistral-Nemo | 58.3 | 52.4 | 50.3 | 44.2 | 60.6 | 63.9 | 64.8 |
| Qwen2.5-3B | 61.6 | 54.3 | 49.3 | 41.9 | 50.1 | 66.0 | 66.2 |
| Qwen2.5-7B | 61.1 | 50.0 | 52.2 | 57.8 | 58.7 | 63.6 | 66.3 |
| Mean (18 shards) | 59.8 | 51.5 | 51.4 | 48.1 | 57.1 | 67.8 | 69.4 |
Table 2: Monitoring for errors in the wild. Bold = best per row; underline = second best.
| Dataset | Target LLM | Test size | Prob | LEMON (Ours) | |
|---|---|---|---|---|---|
| W | W-per-cell | ||||
| Mu-SHROOM | Mistral-7B-v0.2 | 53 | 58.7 | ||
| Pythia-Chat-7B | 54 | 61.8 | |||
| Mean (Mu-SHROOM) | 60.3 | 68.2 | 68.4 | ||
| PsiloQA | TinyLlama-1.1B | 100 | 50.1 | ||
| Zephyr-7B-β | 100 | 48.3 | |||
| Phi-4-mini | 99 | 59.7 | |||
| Hermes-2-Mistral-7B | 100 | 54.2 | |||
| Pythia-Chat-7B (v0.16) | 100 | 36.3 | |||
| SmolLM2-1.7B | 99 | 57.7 | |||
| SmolLM2-360M | 100 | 56.1 | |||
| SmolLM2-135M | 100 | 54.8 | |||
| Mean (PsiloQA) | 52.1 | 67.1 | 67.5 | ||
| Mean (all 10 shards) | 53.8 | 67.4 | 67.7 | ||
Task-specific baselines. We compare LEMON against the following task-specific baselines: (i) LookbackLens (LB) (Chuang et al., 2024), a heuristic that uses attention ratios to detect hallucinations, see Section B for details; (ii) a probability-based baseline (Prob), which uses the LLM's output token probabilities to detect hallucinations; and (iii) LookbackLens+Alignment (LB+Align), which applies the LookbackLens baseline to attention features after aligning them using our alignment method described in Section E.
LOO results. The results are presented in Table 1. Both LEMON variants substantially outperform all baselines. LEMON achieves the best performance in 16 of 18 model-benchmark combinations, and on average, LEMON-W-per-cell improves over the strongest baseline, Prob, by approximately 10 ROC-AUC points. We also note that LEMON-W-per-cell slightly outperforms LEMON-W, suggesting that layer-head mixing, even when performed in a manner equivariant to W, is not always beneficial. The learnable baselines perform around chance in the LOO setting, highlighting the importance of accounting for cross-model symmetries when generalizing to unseen models. We complement these results with two additional analyses. First, in Section G.6, we show that LEMON can be adapted to the held-out LLM using only a small number of labeled examples, yielding further improvements over its zero-shot performance. Second, in Section G.7, we consider a substantially more challenging setting in which LEMON is trained on a single LLM (i.e., ) and evaluated on the remaining five. Despite the substantially reduced training diversity relative to the LOO setting, LEMON continues to outperform all baselines by a large margin.
Estimating errors in the wild. To further simulate a real-world deployment of LEMON, we evaluate its monitoring performance in the wild — on both new datasets and new LLMs that were unseen during training. Specifically, we use the datasets Mu-SHROOM(Vázquez et al., 2025) and PsiloQA(Rykov et al., 2025). Both datasets consist of open-domain QA, where the target LLM answers solely from its parametric knowledge. This setting differs substantially from RAGTruth's context-grounded generation task. We evaluate on the official held-out test split of each dataset using 10 target LLMs spanning five different architecture families. To evaluate LEMON's ability to estimate errors in the wild, we assess the six trained LEMON models for each variant used in Table 1 (see the last two columns). Specifically, we evaluate each model on the 10 shards described above and report the mean±std across the six models for each variant. We compare against the strongest baseline from Table 1, namely Prob. Both LEMON variants transfer essentially without degradation: averaged over the 10 shards, LEMON-W reaches 67.4 and LEMON-W-per-cell
Both datasets provide character-level span annotations rather than token-level labels; we mark a token as positive if it overlaps with an annotated span.
67.7. which is roughly 14 AUC points above the strongest baseline, Prob, which scores 53.8. Finally, we note that the spread across the six checkpoints is small (median std 1.7): the choice of training pool barely matters, so any single monitor could be deployed as-is and perform well.
Selective generation. Due to space limitations, we defer this experiment to Section G.5 and summarize it here. Because LEMON is causal, it can score a response while it is being generated. We use it as an online confidence signal that halts generation once a hallucination becomes likely, and serve only the preceding prefix. Sweeping the halting threshold traces a risk-coverage curve El-Yaniv et al. (2010), which trades the fraction of content served against the hallucination rate of what is served (formalized in Section H). LEMON attains the lowest area under this curve (AURC) in 17 of 18 shards, averaging 8.9 (LEMON-W-per-cell) and 9.1 (LEMON-W) against 12.3 for Prob.
4.2 Jailbreak Monitoring
Setup. We use the REDBENCH (Dang et al., 2026) dataset, appending a single universal GCG suffix (Zou et al., 2023) to every harmful request, taken from HarmBench (Mazeika et al., 2024). The suffix is fixed across every request and every monitored LLM; see Section G.3 for further details. Each of the same LLMs generates a response greedily, whose attack success is scored by STRONGREJECT (Souly et al., 2024) on a scale from 0 to 1; we binarize its label at 0.5. Unlike hallucination, which is labeled at the token level, this task has a single binary label for the entire graph, so LEMON is read out at the final prompt token. Here, the monitor observes only the prompt, predicting attack success before any response tokens are generated. We use 3000 prompts per LLM, split 1800/450/750 into train/validation/test at the prompt level and shared across all six LLMs.
Table 3: Jailbreak monitoring results. Bold = best; underline = second best.
| Left-out | Attn→Sys | CHARM | HS | LEMON (Ours) | |
|---|---|---|---|---|---|
| -pc | |||||
| Llama-2-7B | 59.1 | 30.4 | 73.1 | 75.1 | 62.6 |
| Llama-2-13B | 47.8 | 73.7 | 26.4 | 69.5 | 66.5 |
| Mistral-7B | 61.5 | 53.9 | 50.9 | 67.5 | 59.2 |
| Mistral-Nemo | 47.3 | 58.3 | 48.7 | 55.0 | 57.3 |
| Qwen2.5-3B | 67.6 | 38.5 | 45.7 | 63.9 | 64.8 |
| Qwen2.5-7B | 67.8 | 46.1 | 38.6 | 59.3 | 69.1 |
| Mean | 58.5 | 50.1 | 47.2 | 65.0 | 63.3 |
A training-free baseline. Beyond the learning-based baselines introduced in Section 4, motivated by previous works (Hung et al., 2025; Ben-Tov et al., 2026) we use the following baseline, which measures how much the final prompt token attends to instruction tokens (which may include the system-prompt) averaging across tokens, layers, and heads: . Lower values indicate weaker attention to the instruction/system prompt, so we use as the jailbreak predictor. The results are summarized in Table 3. On average, both LEMON variants outperform all baselines: LEMON- improves over the strongest baseline by 6.5 AUC points, while LEMON--per-cell improves by 4.8 points. We note that in this case LEMON- performs better than LEMON--per-cell by almost 2 AUC units – which suggests that sharing information across layers and heads is beneficial for this task. Moreover, across all six LLMs, LEMON consistently ranks either first or second.
4.3 Ablation Studies
To ablate LEMON, we compare the main variants with four ablations: (i) LEMON with no cross-token mixing (no-cross), measuring the importance of sequence modeling; (ii) non-equivariant LEMON (Dense), which mixes information across layers and heads in a
Table 4: LEMON ablations in the LOO setup. Mean OOD ROC-AUC over the three tasks per held-out LLM. Bold = best in column, underline = second best.
| Variant | Held-out LLM (mean over 3 tasks) | ||||||
|---|---|---|---|---|---|---|---|
| L2-7B | L2-13B | M-7B | Nemo | Q-3B | Q-7B | Mean | |
| LEMON-W | 71.4 | 73.8 | 68.2 | 63.9 | 63.6 | 67.8 | |
| LEMON-W-pc | 74.9 | 75.5 | 68.5 | 66.2 | 66.3 | 69.4 | |
| LEMON-W (no prob) | 69.6 | 66.5 | 68.2 | 62.2 | 61.4 | 59.6 | 64.6 |
| LEMON-W-pc (no prob) | 70.2 | 67.2 | 66.6 | 63.4 | 65.6 | 60.5 | 65.6 |
| LEMON-W (no cross) | 72.0 | 68.7 | 63.1 | 63.9 | 64.9 | 68.0 | |
| LEMON-W-pc (no cross) | 74.8 | ||||||
| LEMON (Dense) | 56.5 | 67.4 | 58.3 | 59.7 | 51.1 | 59.1 | 58.7 |
| LEMON (without graph) | 64.7 | 67.1 | 67.1 | 61.9 | 63.0 | 63.0 | 64.5 |

Figure 7: Cost of monitoring with LEMON.
non-equivariant manner; (iii) LEMON with no graph structure (without graph), using only probabilities as node features; and (iv) LEMON with no probability (no prob) node features. The results are in Table 4. We observe that the main variants, LEMON-W and LEMON-W-per-cell, outperform all ablations by a large margin, except LEMON (no cross) variant, which, importantly, is still invariant to , underscoring the importance of our derivation in Section 3.2. The non-equivariant variant performs worst, highlighting the importance of equivariance for cross-LLM transfer.
4.4 Run-Time Analysis
We report LEMON's online monitoring cost in Figure 7. We compare an unmonitored decode step against all the three terms monitoring adds: (i) extracting attention (which forces the eager kernel in place of SDPA, and is paid at every token), (ii) updating the graph, and (iii) running LEMON as the critic. We report this on the largest LLM in our pool, LLAMA-2-13B, on the first sample of the RAGTruth NQ shard. Monitoring is extremely cheap: on average it adds with LEMON-W and with LEMON-W-per-cell on LLAMA-2-13B. Notably, the critic itself is the smallest of the three terms — 0.3 of the 2.6 ms added by LEMON-W-per-cell— so the execution of the equivariant architecture is negligible, and what remains is dominated by attention extraction and graph maintenance, both of which could be further optimized with tailored hardware kernels.
5 Conclusion
We introduce LEMON, a learnable attention-based monitor that transfers to unseen decoder-only LLMs without target-model supervision. Our monitor, LEMON, is based on GNNs and is specifically designed to account for symmetries that may arise across attention heads and layers of different LLMs, which is precisely what enables it to generalize zero-shot in the wild. Importantly, LEMON is lightweight, adding less than monitoring overhead, and operates online: it can flag misbehavior during the generation process itself, without requiring the full response to be completed.
Many directions remain open. LEMON can be evaluated on additional tasks, such as machine-generated text detection, memorization, and more. The application of selective generation with LEMON can be studied further, as can its use with other, model-specific monitors. Extending LEMON to multimodal models, such as vision-language models, is an interesting avenue for future
LEMON (Dense) replaces the W-equivariant update of Equation (3) by plain MLPs.
research. Finally, using LEMON as an interpretability tool – to automatically find important layer-head coordinates, is interesting.
Acknowledgments
F.F. conducted this work supported by an Aly Kaufman Post-Doctoral Fellowship. G.B. is supported by the Jacobs Qualcomm PhD Fellowship. H.M. is supported by the Israel Science Foundation through a personal grant (ISF 264/23) and an equipment grant (ISF 532/23), and by the Career Advancement Chairs in Artificial Intelligence – Schmidt Futures.
Reproducibility statement
The LEMON architecture is described in Section 3 and detailed in Sections D and D.1. Training details, the LLMs, and the datasets and splits are given in Sections G, G.2 and G.3; our annotation procedure is in Section F, and the selective-generation metrics are defined in Section H. We will release our code, trained checkpoints, and annotations upon publication.
References
Abdelrahman Abouelenin, Atabak Ashfaq, Adam Atkinson, Hany Awadalla, Nguyen Bach, Jianmin Bao, Alon Benhaim, Martin Cai, Vishrav Chaudhary, Congcong Chen, et al. Phi-4-mini technical report: Compact yet powerful multimodal language models via mixture-of-loras. arXiv preprint arXiv:2503.01743, 2025.
Loubna Ben Allal, Anton Lozhkov, Elie Bakouch, Gabriel Martín Blázquez, Guilherme Penedo, Lewis Tunstall, Andrés Marafioti, Hynek Kydliček, Agustín Piqueres Lajarín, Vaibhav Srivastav, et al. Smollm2: When smol goes big-data-centric training of a small language model. arXiv preprint arXiv:2502.02737, 2025.
Amos Azaria and Tom Mitchell. The internal state of an LLM knows when it's lying. In Findings of the Association for Computational Linguistics: EMNLP 2023, pp. 967–976, 2023.
Yuntao Bai, Andy Jones, Kamal Ndousse, Amanda Askell, Anna Chen, Nova DasSarma, Dawn Drain, Stanislav Fort, Deep Ganguli, Tom Henighan, et al. Training a helpful and harmless assistant with reinforcement learning from human feedback. arXiv preprint arXiv:2204.05862, 2022.
Yejin Bang, Ziwei Ji, Alan Schelten, Anthony Hartshorn, Tara Fowler, Cheng Zhang, Nicola Cancedda, and Pascale Fung. HalluLens: LLM hallucination benchmark. In Wanxiang Che, Joyce Nabende, Ekaterina Shutova, and Mohammad Taher Pilehvar (eds.), Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 24128–24156, Vienna, Austria, July 2025. Association for Computational Linguistics. ISBN 979-8-89176-251-0. doi: 10.18653/v1/2025.acl-long.1176. URL https://aclanthology.org/2025.acl-long.1176/.
Yamini Bansal, Preetum Nakkiran, and Boaz Barak. Revisiting model stitching to compare neural representations. Advances in neural information processing systems, 34:225–236, 2021.
Guy Bar-Shalom, Fabrizio Frasca, Yaniv Galron, Yftah Ziser, and Haggai Maron. Beyond token probes: Hallucination detection via activation tensors with ACT-ViT. In Advances in Neural Information Processing Systems, volume 38, 2025.
Guy Bar-Shalom, Fabrizio Frasca, Derek Lim, Yoav Gelberg, Yftah Ziser, Ran El-Yaniv, Gal Chechik, and Haggai Maron. Beyond next token probabilities: Learnable, fast detection of hallucinations and data contamination on LLM output distributions. In Proceedings of the AAAI Conference on Artificial Intelligence, 2026.
Yonatan Belinkov. Probing classifiers: Promises, shortcomings, and advances. Computational Linguistics, 2022.
Matan Ben-Tov, Mor Geva, and Mahmood Sharif. Universal jailbreak suffixes are strong attention hijackers. Transactions of the Association for Computational Linguistics, 14:1028–1050, 2026.
Sidney Black, Stella Biderman, Eric Hallahan, Quentin Anthony, Leo Gao, Laurence Golding, Horace He, Connor Leahy, Kyle McDonell, Jason Phang, et al. Gpt-neox-20b: An open-source autoregressive language model. In Proceedings of BigScience Episode# 5-Workshop on Challenges & Perspectives in Creating Large Language Models, pp. 95–136, 2022.
Meng Cao, Yue Dong, and Jackie Cheung. Hallucinated but factual! Inspecting the factuality of hallucinations in abstractive summarization. In Smaranda Muresan, Preslav Nakov, and Aline Villavicencio (eds.), Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 3340–3354, Dublin, Ireland, May 2022. Association for Computational Linguistics.
Nicholas Carlini, Florian Tramer, Eric Wallace, Matthew Jagielski, Ariel Herbert-Voss, Katherine Lee, Adam Roberts, Tom Brown, Dawn Song, Ulfar Erlingsson, et al. Extracting training data from large language models. In 30th USENIX security symposium (USENIX Security 21), pp. 2633–2650, 2021.
John J Cherian, Isaac Gibbs, and Emmanuel J Candès. Large language model validity via enhanced conformal prediction methods. Advances in Neural Information Processing Systems, 37:114812–114842, 2024.
C. K. Chow. An optimum character recognition system using decision functions. IRE Transactions on Electronic Computers, EC-6(4):247–254, 1957. doi: 10.1109/TEC.1957.5222035.
Yung-Sung Chuang, Linlu Qiu, Cheng-Yu Hsieh, Ranjay Krishna, Yoon Kim, and James R. Glass. Lookback Lens: Detecting and mitigating contextual hallucinations in large language models using only attention maps. In Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, pp. 1419–1436. Association for Computational Linguistics, 2024.
Taco Cohen and Max Welling. Group equivariant convolutional networks. In International conference on machine learning, pp. 2990–2999. PMLR, 2016.
Together Computer. OpenChatKit: An Open Toolkit and Base Model for Dialogue-style Applications, 3 2023. URL https://github.com/togethercomputer/OpenChatKit.
Quy-Anh Dang, Chris Ngo, and Truong-Son Hy. Redbench: A universal dataset for comprehensive red teaming of large language models. arXiv preprint arXiv:2601.03699, 2026.
Ran El-Yaniv et al. On the foundations of noise-free selective classification. Journal of Machine Learning Research, 11(5), 2010.
Amit Elhelo and Mor Geva. Inferring functionality of attention heads from their parameters. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 17701–17733, 2025.
Carlos Esteves, Christine Allen-Blanchette, Ameesh Makadia, and Kostas Daniilidis. Learning so (3) equivariant representations with spherical cnns. In Proceedings of the european conference on computer vision (ECCV), pp. 52–68, 2018.
Carlos Esteves, Yinshuang Xu, Christine Allen-Blanchette, and Kostas Daniilidis. Equivariant multi-view networks. In Proceedings of the IEEE/CVF international conference on computer vision, pp. 1568–1577, 2019.
Sebastian Farquhar, Jannik Kossen, Lorenz Kuhn, and Yarin Gal. Detecting hallucinations in large language models using semantic entropy. Nature, 630(8017):625–630, 2024. ISSN 1476-4687. doi:10.1038/s41586-024-07421-0. URL https://doi.org/10.1038/s41586-024-07421-0.
Fabrizio Frasca, Guy Bar-Shalom, Yftah Ziser, and Haggai Maron. Neural message-passing on attention graphs for hallucination detection. In International Conference on Learning Representations, volume 2026, pp. 449–475, 2026.
Tianyu Fu, Zihan Min, Hanling Zhang, Jichao Yan, Guohao Dai, Wanli Ouyang, and Yu Wang. Cache-to-cache: Direct semantic communication between large language models. In The Fourteenth International Conference on Learning Representations, 2026. URL https://openreview.net/forum?id=LeatkxrBCi.
Leo Gao, John Schulman, and Jacob Hilton. Scaling laws for reward model overoptimization. In International conference on machine learning, pp. 10835–10866. PMLR, 2023.
Yonatan Geifman and Ran El-Yaniv. Selective classification for deep neural networks. Advances in neural information processing systems, 30, 2017.
Yonatan Geifman and Ran El-Yaniv. Selectivenet: A deep neural network with an integrated reject option. In International conference on machine learning, pp. 2151–2159. PMLR, 2019.
Justin Gilmer, Samuel S. Schoenholz, Patrick F. Riley, Oriol Vinyals, and George E. Dahl. Neural message passing for quantum chemistry. In International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pp. 1263–1272. PMLR, 2017.
Nuno M Guerreiro, Elena Voita, and André FT Martins. Looking for a needle in a haystack: A comprehensive study of hallucinations in neural machine translation. arXiv preprint arXiv:2208.05309, 2022.
Wes Gurnee, Theo Horsley, Zifan Carl Guo, Tara Rezaei Kheirkhah, Qinyi Sun, Will Hathaway, Neel Nanda, and Dimitris Bertsimas. Universal neurons in gpt2 language models. arXiv preprint arXiv:2401.12181, 2024.
Weihua Hu, Bowen Liu, Joseph Gomes, Marinka Zitnik, Percy Liang, Vijay Pande, and Jure Leskovec. Strategies for pre-training graph neural networks. arXiv preprint arXiv:1905.12265, 2019.
Yuheng Huang, Jiayang Song, Zhijie Wang, Shengming Zhao, Huaming Chen, Felix Juefei-Xu, and Lei Ma. Look before you leap: An exploratory study of uncertainty measurement for large language models. arXiv preprint arXiv:2307.10236, 2023.
Huang et al. A survey on hallucination in large language models: Principles, taxonomy, challenges, and open questions. ACM Transactions on Information Systems, 2023.
Minyoung Huh, Brian Cheung, Tongzhou Wang, and Phillip Isola. The platonic representation hypothesis. arXiv preprint arXiv:2405.07987, 2024.
Kuo-Han Hung, Ching-Yun Ko, Ambrish Rawat, I-Hsin Chung, Winston H Hsu, and Pin-Yu Chen. Attention tracker: Detecting prompt injection attacks in llms. In Findings of the Association for Computational Linguistics: NAACL 2025, pp. 2309–2322, 2025.
Michael Ivanitskiy, Cecilia Diniz Behn, and Samy Wu Fung. Motifs in attention patterns of large language models. In Mechanistic Interpretability Workshop at NeurIPS 2025, 2025. URL https://openreview.net/forum?id=ND2WsCwlDQ.
Ziwei Ji, Nayeon Lee, Rita Frieske, Tiezheng Yu, Dan Su, Yan Xu, Etsuko Ishii, Ye Jin Bang, Andrea Madotto, and Pascale Fung. Survey of hallucination in natural language generation. ACM Computing Surveys, 55(12):1–38, 2023.
Albert Q. Jiang, Alexandre Sablayrolles, Arthur Mensch, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Florian Bressand, Gianna Lengyel, Guillaume Lample, Lucile Saulnier, Lélio Renard Lavaud, Marie-Anne Lachaux, Pierre Stock, Teven Le Scao, Thibaut Lavril, Thomas Wang, Timothée Lacroix, and William El Sayed. Mistral 7b. arXiv:2310.06825, 2023a.
Yihang Jiang, Xiaoyang Li, Guangxu Zhu, Hang Li, Jing Deng, Kaifeng Han, Chao Shen, Qingjiang Shi, and Rui Zhang. 6g non-terrestrial networks enabled low-altitude economy: Opportunities and challenges. arXiv preprint arXiv:2311.09047, 2023b.
Saurav Kadavath, Tom Conerly, Amanda Askell, Tom Henighan, Dawn Drain, Ethan Perez, Nicholas Schiefer, Zac Hatfield-Dodds, Nova DasSarma, Eli Tran-Johnson, et al. Language models (mostly) know what they know. arXiv preprint arXiv:2207.05221, 2022.
Yoni Kasten, Wuyue Lu, and Haggai Maron. Fast encoder-based 3d from casual videos via point track processing. Advances in Neural Information Processing Systems, 37:96150–96180, 2024.
Risi Kondor and Shubhendu Trivedi. On the generalization of equivariance and convolution in neural networks to the action of compact groups. In International conference on machine learning, pp. 2747–2755. PMLR, 2018.
Tomek Korbak, Mikita Balesni, Elizabeth Barnes, Yoshua Bengio, Joe Benton, Joseph Bloom, Mark Chen, Alan Cooney, Allan Dafoe, Anca Dragan, et al. Chain of thought monitorability: A new and fragile opportunity for ai safety. arXiv preprint arXiv:2507.11473, 2025.
Simon Kornblith, Mohammad Norouzi, Honglak Lee, and Geoffrey Hinton. Similarity of neural network representations revisited. In International conference on machine learning, pp. 3519–3529. PMIR, 2019.
János Kramár, Joshua Engels, Zheng Wang, Bilal Chughtai, Rohin Shah, Neel Nanda, and Arthur Conmy. Building production-ready probes for gemini. arXiv preprint arXiv:2601.11516, 2026.
Lorenz Kuhn, Yarin Gal, and Sebastian Farquhar. Semantic uncertainty: Linguistic invariances for uncertainty estimation in natural language generation, 2023. URL https://arxiv.org/abs/2302.09664.
Tianyu Liu, Yizhe Zhang, Chris Brockett, Yi Mao, Zhifang Sui, Weizhu Chen, and Bill Dolan. A token-level reference-free hallucination detection benchmark for free-form text generation. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics, pp. 6723–6737, 2022.
Yang Liu, Dan Iter, Yichong Xu, Shuohang Wang, Ruochen Xu, and Chenguang Zhu. G-eval: Nlg evaluation using gpt-4 with better human alignment. In Proceedings of the 2023 conference on empirical methods in natural language processing, pp. 2511–2522, 2023.
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2019.
Potsawee Manakul, Adian Liusie, and Mark J. F. Gales. SelfCheckGPT: Zero-resource black-box hallucination detection for generative large language models. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pp. 9004–9017, 2023.
Emanuele Marconato, Samuele Bortolotti, Emile van Krieken, Antonio Vergari, Andrea Passerini, and Stefano Teso. Bears make neuro-symbolic models aware of their reasoning shortcuts, 2024.
Haggai Maron, Heli Ben-Hamu, Nadav Shamir, and Yaron Lipman. Invariant and equivariant graph networks. arXiv preprint arXiv:1812.09902, 2018.
Mantas Mazeika, Long Phan, Xuwang Yin, Andy Zou, Zifan Wang, Norman Mu, Elham Sakhaee, Nathaniel Li, Steven Basart, Bo Li, David Forsyth, and Dan Hendrycks. Harmbench: A standardized evaluation framework for automated red teaming and robust refusal. 2024.
Ari Morcos, Maithra Raghu, and Samy Bengio. Insights on representational similarity in neural networks with canonical correlation. Advances in neural information processing systems, 31, 2018.
Luca Moschella, Valentino Maiorca, Marco Fumero, Antonio Norelli, Francesco Locatello, and Emanuele Rodolà. Relative representations enable zero-shot latent space communication. arXiv preprint arXiv:2209.15430, 2022.
Milad Nasr, Nicholas Carlini, Jonathan Hayase, Matthew Jagielski, A Feder Cooper, Daphne Ippolito, Christopher A Choquette-Choo, Eric Wallace, Florian Tramèr, and Katherine Lee. Scalable extraction of training data from (production) language models. arXiv preprint arXiv:2311.17035, 2023.
Cheng Niu, Yuanhao Wu, Juno Zhu, Siliang Xu, Kashun Shum, Randy Zhong, Juntong Song, and Tong Zhang. Ragtruth: A hallucination corpus for developing trustworthy retrieval-augmented language models. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 10862–10878, 2024.
Catherine Olsson, Nelson Elhage, Neel Nanda, Nicholas Joseph, Nova DasSarma, Tom Henighan, Ben Mann, Amanda Askell, Yuntao Bai, Anna Chen, et al. In-context learning and induction heads. arXiv preprint arXiv:2209.11895, 2022.
Artidoro Pagnoni, Vidhisha Balachandran, and Yulia Tsvetkov. Understanding factuality in abstractive summarization with FRANK: A benchmark for factuality metrics. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 4812–4829. Association for Computational Linguistics, 2021.
Dagmara Panas, Ali Payani, and Vaishak Belle. Unreasonable effectiveness of LLM reasoning: a doubly cautionary tale of temporal question-answering. Transactions on Machine Learning Research, 2025. ISSN 2835-8856. URL https://openreview.net/forum?id=1DkD0Nd8Rd.
Paszke et al. Pytorch: An imperative style, high-performance deep learning library. Advances in neural information processing systems, 32, 2019.
Yifu Qiu, Yftah Ziser, Anna Korhonen, Edoardo Ponti, and Shay Cohen. Detecting and mitigating hallucinations in multilingual summarisation. In Houda Bouamor, Juan Pino, and Kalika Bali (eds.), Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pp. 8914–8932, Singapore, December 2023. Association for Computational Linguistics.
Rawte et al. The troubling emergence of hallucination in large language models—an extensive definition, quantification, and prescriptive remediations. arXiv preprint arXiv:2310.04988, 2023.
Elisei Rykov, Kseniia Petrushina, Maksim Savkin, Valerii Olisov, Artem Vazhentsev, Kseniia Titova, Alexander Panchenko, Vasily Konovalov, and Julia Belikova. When models lie, we learn: Multilingual span-level hallucination detection with psiloqa. arXiv preprint arXiv:2510.04849, 2025.
Dvir Samuel, Guy Bar-Shalom, Fabrizio Frasca, Ethan Fetaya, Yftah Ziser, Gal Chechik, and Haggai Maron. Uniprobe: A learnable token-level hallucination detector for large vlms using multi-structural internal representations. arXiv preprint arXiv:2608.10835, 2026.
Mrinank Sharma, Meg Tong, Tomasz Korbak, David Duvenaud, Amanda Askell, Samuel R Bowman, Esin DURMUS, Zac Hatfield-Dodds, Scott R Johnston, Shauna M Kravec, et al. Towards understanding sycophancy in language models. In The Twelfth International Conference on Learning Representations, 2024.
Peiyang Song, Pengrui Han, and Noah Goodman. Large language model reasoning failures. arXiv preprint arXiv:2602.06176, 2026.
Alexandra Souly, Qingyuan Lu, Dillon Bowen, Tu Trinh, Elvis Hsieh, Sana Pandey, Pieter Abbeel, Justin Svegliato, Scott Emmons, Olivia Watkins, et al. A strongreject for empty jailbreaks. Advances in Neural Information Processing Systems, 37:125416–125440, 2024.
Sharath Turuvekere Sreenivas, Saurav Muralidharan, Raviraj Joshi, Marcin Chochowski, Ameya Sunil Mahabaleshwarkar, Gerald Shen, Jiaqi Zeng, Zijia Chen, Yoshi Suhara, Shizhe Diao, et al. Llm pruning and distillation in practice: The minitron approach. arXiv preprint arXiv:2408.11796, 2024.
Nathaniel Thomas, Tess Smidt, Steven Kearnes, Lusann Yang, Li Li, Kai Kohlhoff, and Patrick Riley. Tensor field networks: Rotation-and translation-equivariant neural networks for 3d point clouds. arXiv preprint arXiv:1802.08219, 2018.
Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, Dan Bikel, Lukas Blecher, Cristian Canton Ferrer, Moya Chen, Guillem Cucurull, David Esiobu, Jude Fernandes, Jeremy Fu, Wenyin Fu, Brian Fuller, Cynthia Gao, Vedanuj Goswami, Naman Goyal, Anthony Hartshorn, Saghar Hosseini, Rui Hou, Hakan Inan, Marcin Kardas, Viktor Kerkez, Madian Khabsa, Isabel Kloumann, Artem Korenev, Punit Koura, Marie-Anne Lachaux, Thibaut Lavril, Jenya Lee, Diana Liskovich, Yinghai Lu, Yuning Mao, Xavier Martinet, Todor Mihaylov, Pushkar Mishra, Igor Molybog, Yixin
Nie, Andrew Poulton, Jeremy Reizenstein, Rashi Rungta, Kalyan Saladi, Alan Schelten, Ruan Silva, Eric Michael Smith, Ranjan Subramanian, Xiaoqing Ellen Tan, Binh Tang, Ross Taylor, Adina Williams, Jian Xiang Kuan, Puxin Xu, Zheng Yan, Iliyan Zarov, Yuchen Zhang, Angela Fan, Melanie Kambadur, Sharan Narang, Aurélien Rodriguez, Robert Stojnic, Sergey Edunov, and Thomas Scialom. Llama 2: Open foundation and fine-tuned chat models. arXiv:2307.09288, 2023.
Lewis Tunstall, Edward Beeching, Nathan Lambert, Nazneen Rajani, Kashif Rasul, Younes Belkada, Shengyi Huang, Leandro Von Werra, Clémentine Fourrier, Nathan Habib, et al. Zephyr: Direct distillation of lm alignment. arXiv preprint arXiv:2310.16944, 2023.
Neeraj Varshney, Wenlin Yao, Hongming Zhang, Jianshu Chen, and Dong Yu. A stitch in time saves nine: Detecting and mitigating hallucinations of llms by validating low-confidence generation. arXiv preprint arXiv:2307.03987, 2023.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
Raúl Vázquez, Timothee Mickus, Elaine Zosa, Teemu Vahtola, Jörg Tiedemann, Aman Sinha, Vincent Segonne, Fernando Sánchez-Vega, Alessandro Raganato, Jindřich Libovický, et al. Semeval-2025 task 3: Mu-shroom, the multilingual shared-task on hallucinations and related observable overgeneration mistakes. In Proceedings of the 19th International Workshop on Semantic Evaluation (SemEval-2025), pp. 2472–2497, 2025.
Renhao Wang, Marjan Albooyeh, and Siamak Ravanbakhsh. Equivariant networks for hierarchical structures. Advances in Neural Information Processing Systems, 33:13806–13817, 2020.
Yixu Wang, Yan Teng, Kexin Huang, Chengqi Lyu, Songyang Zhang, Wenwei Zhang, Xingjun Ma, Yu-Gang Jiang, Yu Qiao, and Yingchun Wang. Fake alignment: Are llms really aligned well? In Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers), pp. 4696–4712, 2024.
Alexander Wei, Nika Haghtalab, and Jacob Steinhardt. Jailbroken: How does llm safety training fail? Advances in neural information processing systems, 36:80079–80110, 2023.
Christopher Wolfram and Aaron Schein. Layers at similar depths generate similar activations across LLM architectures. In Second Conference on Language Modeling, 2025. URL https://openreview.net/forum?id=8wKec6faAT.
Wenhao Wu, Yizhong Wang, Guangxuan Xiao, Hao Peng, and Yao Fu. Retrieval head mechanistically explains long-context factuality. In International Conference on Learning Representations, volume 2025, pp. 62143–62156, 2025.
Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? arXiv preprint arXiv:1810.00826, 2018.
Tiancheng Yang, Lin Zhang, Jiaye Lin, Guimin Hu, Di Wang, and Lijie Hu. D-leaf: Localizing and correcting hallucinations in multimodal llms via layer-to-head attention diagnostics. arXiv e-prints, pp. arXiv-2509, 2025.
Yang et al. Qwen2 technical report. arXiv preprint arXiv:2407.10671, 2024.
Yifan Yao, Jinhao Duan, Kaidi Xu, Yuanfang Cai, Zhibo Sun, and Yue Zhang. A survey on large language model (llm) security and privacy: The good, the bad, and the ugly. High-Confidence Computing, 4(2):100211, 2024.
Yu Yuan, Lili Zhao, Kai Zhang, Guangting Zheng, and Qi Liu. Do llms overcome shortcut learning? an evaluation of shortcut challenges in large language models. In Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, pp. 12188–12200, 2024.
Manzil Zaheer, Satwik Kottur, Siamak Ravanbakhsh, Barnabas Poczos, Russ R Salakhutdinov, and Alexander Smola. Deep sets. Advances in neural information processing systems, 30, 2017.
Peiyuan Zhang, Guangtao Zeng, Tianduo Wang, and Wei Lu. Tinyllama: An open-source small language model. arXiv preprint arXiv:2401.02385, 2024.
Lianmin Zheng, Wei-Lin Chiang, Ying Sheng, Siyuan Zhuang, Zhanghao Wu, Yonghao Zhuang, Zi Lin, Zhuohan Li, Dacheng Li, Eric Xing, et al. Judging llm-as-a-judge with mt-bench and chatbot arena. Advances in neural information processing systems, 36:46595–46623, 2023.
Andy Zou, Zifan Wang, Nicholas Carlini, Milad Nasr, J Zico Kolter, and Matt Fredrikson. Universal and transferable adversarial attacks on aligned language models. arXiv preprint arXiv:2307.15043, 2023.
Appendix roadmap
The appendix is organized as follows.
-
Section A, Motivating Example: Full Query and Responses. This section provides further details on the motivating example introduced in Section 3.
-
Section B, LookbackLens Features. This section describes the LookbackLens features used in our attention-ratio baselines.
-
Section C, Architecture Visualization. This section provides visualizations of architectural components that we describe in the main text.
– Section C.1, W-equivariant layer.
– Section C.2, LEMON architecture.
- Section D, From attention maps to Graphs with Structured Features - Extended Section. This section describes how we cast the attention map as an attributed directed graph, the preprocessing pipeline, and the LANGUAGE-MODEL EQUIVARIANT MONITORING NETWORK (LEMON) architecture.
– Section D.1, Language-model Equivariant Monitoring Network (LEMON) – A Detailed Description.
-
Section E, Alignment Methods. This section provides the full details of the head alignment methods we use in our experiments.
-
Section F, Dataset Annotation. This section documents how the RAGTruth-native annotations are used and how the three additional LLMs were annotated, together with a manual audit of the resulting labels.
• Section G, Experiments: Monitoring for LLM misbehaviors with LEMON—Extended Section.
– Section G.1, Baselines and Ablations: Implementation Details.
– Section G.2, LLMs Used In Our Experiments.
– Section G.3, Datasets Used In Our Experiments.
– Section G.4, LOO results — Extended results.
– Section G.5, Selective Generation.
– Section G.6, Few-shot adaptation.
– Section G.7, LOI Results.
- Section H, Selective Generation: Formal Framework. This section formalizes the selective-generation setting of Section G.5: the selective generator, the served output, and the coverage, token-coverage, selective-risk, and token-savings estimators, together with the construction of a selective generator from a confidence function.
– Section H.1, Constructing Selective Generators and the Risk-Coverage Curve.
A Motivating Example: Full Query and Responses
Here we provide the full details regarding the motivating example in Section 3. The example is a single data-to-text instance from RAGTruth (sample 147), answered by both Llama-2-7B and Mistral-7B. The task is to write an overview of a business (“The Lark”, a Santa Barbara restaurant) from a structured JSON record, using only the provided data. In the responses below, all spans annotated as hallucinated by RAGTruth are boxed, and the specific token analyzed in Figure 2 — Sunday — is shown in bold within its box. Both models hallucinate this token (Sunday), in different sentences and at different output positions.
Why "sunday" is a hallucination. The structured data lists per-day opening hours that vary across the week (Monday closed), yet both models collapse them into a fabricated open-every-day claim: "open Monday through Sunday from 17:00 to 22:00" (Llama-2-7B) and "open from Monday to Sunday from 5 pm to midnight" (Mistral-7B). RAGTruth annotates this claim as a hallucinated span in each response, and "sunday" is hallucinated as part of the invented range. This provides a clean choice for comparison: the error is localized, appears in both models within the same fabricated claim, and the token "sunday" is identical across models, allowing a direct comparison of their attention maps. See Table 5 for the tokenization of all day names in both models.
Query
Instruction. Write an objective overview about the following local business based only on the provided structured data in the JSON format. You should include details and cover the information mentioned in the customers' reviews. The overview should be 100–200 words. Don't make up information.
Context (structured data, reviews abbreviated). {'name': 'The Lark', 'address': '131 Anacapa St, Ste A', 'city': 'Santa Barbara', 'state': 'CA', 'categories': 'Nightlife, Bars, Cocktail Bars, Food, American (New), Desserts, Restaurants', 'hours': {'Monday': '0:0-0:0', 'Tuesday': '17:0-21:0', 'Wednesday': '17:0-21:0', 'Thursday': '17:0-21:0', 'Friday': '17:0-22:0', 'Saturday': '17:0-22:0', 'Sunday': '17:0-21:0'}, 'attributes': {'BusinessParking': {'street': True, ...}, 'RestaurantsReservations': True, 'OutdoorSeating': True, 'WiFi': 'free', 'RestaurantsTakeOut': False, 'RestaurantsGoodForGroups': True, 'Music': False, 'Ambience': {'trendy': True, 'classy': True, ...}}, 'business_stars': 4.0, 'review_info': [{'review_stars': 5.0, 'review_text': 'Truly a delicious "Shared Dining Experience" ...Crispy Brussel Sprouts ...Highly recommend making reservations ...'}, {'review_stars': 3.0, 'review_text': 'The food was good to great, where the experience fell apart was in the service ...'}, {'review_stars': 5.0, 'review_text': 'My partner and I celebrated our anniversary ...our waiter Oscar was friendly ...'}]}
Llama-2-7B response
Based on the provided structured data, here is an objective overview of The Lark: The Lark is a popular nightlife spot located in the heart of Santa Barbara's Funk Zone. With categories such as Nightlife, Bars, Cocktail Bars, Food, American (New),
Desserts, and Restaurants, The Lark offers a unique shared dining experience for groups of all sizes. Their hours of operation are Monday through Sunday from 17:00 to 22:00, with validated parking available off-street and street parking nearby.
According to customer reviews, the quality of the food at The Lark is consistently high, with standout dishes including crispy Brussels sprouts, winter beets marinated in balsamic vinegar, caramelized cauliflower, cast iron Morro Bay black cod, creekstone prime hanger steak, and buttermilk fried chicken. Wine enthusiasts will appreciate the extensive selection of wine-by-the-glass options, including Grimm's Bluff, Happy Canyon, and Rose of Cabernet Sauvignon.
However, some customers have reported issues with the service at The Lark, including a lack of attentiveness from servers and confusion with regard to reservations. Despite these minor drawbacks, the majority of customers have praised The Lark for its cozy atmosphere, excellent food, and exceptional service. One reviewer even noted that their server, Laurel, went above and beyond to ensure a special night, earning a 5-star rating for service. Overall, The Lark appears to be a top choice for dinner and drinks in Santa Barbara, offering a memorable dining experience for visitors and locals alike.
Mistral-7B response
The Lark is a restaurant located in the heart of the Santa Barbara Funk Zone at 131 Anacapa St, Ste A. The restaurant offers a variety of food options including American cuisine, desserts, and cocktails. The restaurant has outdoor seating and serves WiFi. It is classified under the categories of Nightlife, Bars, Cocktail Bars, Food, American (New), Desserts, Restaurants, and is open from Monday to Sunday from 5 pm to midnight. Based on customer reviews, the restaurant appears to have a good reputation for its food quality and the friendliness of its staff. However, some customers have reported issues with the service and the attentiveness of the staff. Overall, The Lark seems like a good place to visit for a romantic dinner or a casual evening out with friends.
| Day | LLAMA-2-7B | MISTRAL-7B |
|---|---|---|
| Monday | Monday | Monday |
| Tuesday | Tuesday | Tuesday |
| Wednesday | Wednesday | Wednesday |
| Thursday | Thursday | Thursday |
| Friday | Friday | Friday |
| Saturday | Saturday | Saturday |
| Sunday | Sunday | Sunday |
Table 5: Subword tokenization of the seven day names for LLAMA-2-7B and MISTRAL-7B.
Generality of Figure 2. The comparison of Figure 2 is not specific to the selected token. We repeat it for every hallucinated content word the two models share as follows: for each RAGTruth test sample answered by both LLMs, we take every word (alphabetic, longer than three characters) that both tokenizers represent as a single token and that both models' annotations flag as hallucinated, and compute the Pearson correlation between the two models' LookbackLens maps at that token. Over all, we have 104 such tokens (44 question answering, 15 summarization, 45 data-to-text), the correlation never exceeds (mean 0.07, median 0.07, minimum -0.03). The misalignment shown in Figure 2 is thus the rule rather than an artifact of the chosen example.
B LookbackLens Features
Here we provide further details on LookbackLens (LB) features (Chuang et al., 2024). Chuang et al. (2024) showed that how much the model “looks back” at the prompt and context when generating each token is predictive of contextual hallucinations: if a response token is produced while attending mainly to earlier response tokens rather than to the input, it is more likely to be a hallucination. They define a simple heuristic per (layer, head) and per response token. Consider the t-th response token. It is produced by the query at the preceding position, whose attention distribution at layer and head h we denote , where is the number of prompt/context tokens; it is supported on the prompt tokens and the response tokens generated so far.
prompt response

query row
Figure 8: LookbackLens: average attention from the query generating the t-th response token to the prompt ( ) vs. the earlier response ( ). This example assumes a single layer and a single attention head.
LB compares the average attention mass placed on the two segments,
with . Their heuristic is the prompt-attention ratio
low means the model attended mostly to the response so far, and is taken as a signal of possible hallucination. See Figure 8 for an example of a single layer and head. In our baselines, we flatten , zero-pad to where and are the maximum number of layers and heads in our LLM pool, and train logistic regression.
C Architectures Visualization
C.1 W-equivariant layer
In Figure 9 we provide a visual depiction of the W-equivariant layer described in Section 3.2. Each layer slice is processed independently by a shared (Siamese) , while the information-sharing path sums the input over heads, applies across layers, and broadcasts the result back over heads; the outputs of the two paths are summed to produce .

information-sharing path
Figure 9: The W-equivariant layer . The Siamese path (dashed, top) applies to each layer slice independently; the information-sharing path (bottom) sums over heads, applies across layers, and broadcasts the result back over heads. The two paths are summed.
C.2 LEMON architecture
In Figure 10 we provide a visual depiction of the full LEMON architecture.

Figure 10: The LEMON architecture. Top: the end-to-end pipeline. Bottom, left to right: one equivariant MPNN layer—parallel supernode/response streams with W-equivariant updates (Equations (6) and (7)); the shared causal cross-token Transformer, applied independently at each layer-head cell ; and the invariant prediction head for the per-token case (Equation (8)).
D From attention maps to Graphs with Structured Features - Extended Section
Preprocessing the attention graph. The full preprocessing pipeline is illustrated in Figure 11. Following (Frasca et al., 2026), we discard both prompt-to-prompt (p→p) edges, and sparsify the remaining edges by thresholding low attention values . We also pool all prompt nodes into a single supernode s and aggregate their outgoing edges to the response nodes, leaving a graph over response tokens only (plus s). Finally, we pool consecutive response tokens

Figure 11: Preprocessing: p→p edges (red) discarded; weak edges (gray, dashed) thresholded away; prompt nodes (boxed) pooled into supernode s; response tokens (boxed) pooled into windows (W=2 shown). Right: adjacency of the final graph with super and response stream blocks (edge colors match).
into non-overlapping windows (W), so the nodes of the final graph correspond to response windows rather than individual tokens. Together, these steps substantially reduce graph size while preserving both the structure and the information relevant to hallucination detection. The same pipeline is used for the jailbreak experiments, with two changes that follow from the monitor there observing only the prompt: the nodes are the prompt's own tokens, so it is the chat template's system span that is pooled into the supernode , and no window pooling is applied (W=1), since these prompts are short to begin with. We next introduce the LANGUAGE-MODEL EQUIVARIANT MONITORING NETWORK (LEMON), our architecture for processing these structured attributed graphs.
D.1 Language-model Equivariant MONitoring Network (LEMON) – A Detailed Description
LEMON follows the Message Passing Neural Network (MPNN) framework (Gilmer et al., 2017), with a key extension: every nonlinear map on node and edge tensors is a W-equivariant layer.
Overview. We denote by the number of nodes in the preprocessed graph. LEMON first projects node and edge features into hidden dimension , yielding and ; see details in Section 3.3. We recall that the node features combine the self-attention scores with token probabilities: each response token is assigned its probability and each prompt token the value 0, and this scalar is broadcast across all layers and heads, concatenated with the self-attention score, and mapped to by a shared linear layer. It then applies (i) K MPNN layers in parallel to the super-node and response-node streams, using GINE-style aggregation (Hu
We set the threshold to throughout the paper. (Frasca et al., 2026) has shown that this threshold substantially reduces the graph size, while maintaining the relevant information for hallucination detection.
The edges from the prompt tokens to a given response token are merged into a single edge from s, whose attribute is the entry-wise mean over the merged (post-threshold) edges.
We set the window size to throughout the paper. Each window becomes a single node whose attribute is the entry-wise mean over its tokens' attributes. Edge endpoints are remapped to the window nodes, and edges that consequently connect the same pair of nodes are merged into a single edge whose attribute is the entry-wise mean over the merged edges. Per-token labels pool conservatively: a window is labeled hallucinated iff any of its tokens is.
The span is a genuine 24-token system message only for the two Qwen models; for the other four it is a 2–4 token role marker, so pooling it is close to a no-op there.
Under the window pooling above, each response-window node carries the mean probability of the tokens it pools, while the supernode s carries the probability of the first response token. We ablate this signal in Section 4.3 (the no prob variant).
et al., 2019; Xu et al., 2018) with a W-equivariant update function. (ii) A shared causal Transformer encoder is then applied independently to each layer-head cell ( ) to enable global token interaction while preserving sequence order. Finally, (iii) an invariant prediction head operates on the resulting node features. We next formalize the (i) equivariant MPNN layers, (ii) cross-token mixing, and (iii) prediction head. In what follows we describe each component in detail, and we defer the full architecture visualization to Figure 10.
(i) Equivariant MPNN layers. Let index the supernode and response streams, respectively. At layer , we follow a GINE-style aggregation rule (Hu et al., 2019; Xu et al., 2018) to update the node features, and specifically, we use as the update function, which is -equivariant:
where is the set of in-neighbours of in stream , is a learnable scalar. The two stream outputs are then fused by an MLP. We stack such layers, so the final node features are .
We consider two instantiations of from Equation (4), both equivariant to : (a) LEMON-W, a variant that mixes information across layers and heads, instantiating and as Transformers; and (b) LEMON-W-per-cell, a variant that applies an MLP to each node feature independently.
(ii) Cross-token transformer. So far, information has propagated only along graph edges. To exchange information across the full token sequence, we apply a shared causal Transformer encoder independently at each layer-head cell : the slices , ordered by token position, form a length- sequence that the encoder maps to the output node features . Information is thus exchanged across tokens, but not across layers or heads.
(iii) Prediction head. Given the backbone output , we obtain the invariant hallucination score as follows:
For graph-level tasks, we read out a single score from the last token , which under causality has seen the entire sequence:
Since this readout selects along the token axis only, W-invariance is preserved.
With a fixed (non-learnable) sinusoidal absolute positional encoding, applied only in this cross-token encoder.
Algorithm 1 HEADALIGN(X, y)
Require: (source training), (test sample)
Ensure: (aligned test features)
1: for all ,
2: for all ,
3: for do
4:
5:
6:
7: end for
8:
9: for each layer and matched pair do
10: for all
11: end for
12: return
E Alignment Methods
This appendix gives the full formulation of the alignment-based approach we use in our experiments. Rather than building cross-model head-permutation symmetry into an equivariant backbone, this approach enforces it in feature space: each LLM's layer–head attention features are aligned to a shared canonical indexing, after which any off-the-shelf classifier can be trained on the aligned representations.
Setup. To formulate cross-LLM detection via alignment, we decompose it into three sequential maps.
-
A feature extractor collapses raw attentions (i.e., ) to per-token layer-head scalars (LookbackLens (Chuang et al., 2024) is one instantiation; see Section B for details).
-
An alignment map then reindexes the layer-head axes into a canonical ordering.
-
Finally, a classifier produces one hallucination score per token.
The end-to-end predictor is
where .
Aligning two LLMs’ attention features. Let and be a source and target LLM with heads and layers, and heads and layers, respectively (we assume the head count is fixed across layers within each model, as in standard transformers). Denote by the source training features, where is the total number of tokens pooled over all labelled source training samples, and by the features of a single unlabelled test sample with tokens; each entry , is the scalar feature at token , layer , and head . Because head order within each layer is an arbitrary permutation, applying a classifier trained on to raw would fail under zero-shot transfer (as we also demonstrate in Section 4); the goal is therefore to reindex into the source layer–head coordinate system, producing .
We reindex y by matching each target layer and head to a source layer and head in two steps, as follows.
Layer correspondence. Source layer is matched to target layer via proportional depth scaling (Wolfram & Schein, 2025; Fu et al., 2026) (fixed, not optimized) as follows:
Head alignment. For each source layer , we define mean features as follows:

Figure 12: Unequal . Layer map pairs source and target layers; only heads are matched.
where and collect all layer-head means. is precomputed once from labelled source training data; is computed at inference from the test sample alone—no target labels are required. We build the per-layer rectangular cost matrix with entries and solve, for , the linear assignment problem:
via the Hungarian algorithm. The aligned test tensor is assembled as with for each layer and matched pair ; unmatched source positions remain zero when . Given a classifier trained on (using source labels), the predicted hallucination scores are , instantiating the alignment map in the decomposition above; see Figure 12 for a schematic of the unequal-dimension case. Algorithm 1 states the alignment procedure concretely.
Extension to multiple source LLMs. We now turn to the case of source LLMs' features and a test sample . We designate the source with the fewest heads as canonical reference , align all other sources to this canonical reference, and apply the same alignment to at inference. Each source contributes training features and binary token-level hallucination labels ; the test input contains features only (no target labels). We elaborate in the following, and give the full procedure in Algorithm 2.
Offline alignment. Precompute the mean features for the canonical reference as follows:
where and is the number of reference training tokens. For each , solve the per-layer Hungarian matchings of Equation (12) between and (using ) and apply the resulting permutations to , yielding (with ). Train classifier on the concatenation of all sources (including the reference).
Inference. For each test sample , we align it to our canonical reference using HEADALIGN( ), and then score it using the trained classifier . Importantly, at inference we do not assume access to a pool of target-LLM samples: each test example is aligned from its own token features alone, without target labels.
Algorithm 2 MULTISOURCEHEADALIGN( )
Require: and (token labels) for ; (unlabelled test features)
Ensure: (predicted score per test token)
Offline:
1: ref
2: for all ,
3: for , do
4: for all ,
5: for do
6:
7:
8:
9: end for
10:
11: for each token , layer , and matched pair do
12:
13: end for
14: end for
15:
16:
Inference:
17:
18: return
F Dataset Annotation
RAGTruth (Niu et al., 2024) provides responses with hallucination annotations for three of our six LLMs on Summarization, Question Answering, and Data-to-Text; we use those as published, and annotate the remaining three LLMs ourselves, as detailed next.
Native RAGTruth models. For LLAMA-2-7B, LLAMA-2-13B, and MISTRAL-7B, we use the responses and hallucination spans exactly as released—no regeneration and no re-judging. Our only change concerns the Summarization training split, where the native release contains the same source context twice: we drop one of the two duplicates, so that every model's Summarization training set—native or newly generated—contains the same 2514 examples.
Newly annotated models. We extend RAGTruth with token-level hallucination labels for MISTRAL-NEMO-12B, QWEN2.5-3B, and QWEN2.5-7B. Annotation proceeds in two stages: each model generates one response per unique query-context pair, then QWEN2.5-32B labels unsupported or contradictory spans under the original RAGTruth judging template.
Annotation rules. We annotate under the following fixed rules:
-
What counts as a hallucination. A span is labeled hallucinated if it is unsupported by or contradicted by the source—i.e. both fabricated/baseless content and content that conflicts with the source are flagged. The source is the news article (Summarization), the supporting passages (Question Answering), or the structured record together with its embedded customer reviews (Data-to-Text).
-
Judging template. The judge receives the original RAGTruth input_str for the example, instantiated per task: it is shown the source and the model response, then instructed to “identify and label any hallucinated statements … that are unsupported or contradicted by” the source and to “compile the labeled hallucinated spans into a JSON list, with each list item representing a separate hallucinated span.”
-
Output format. The judge returns a JSON list of text spans; it decodes greedily with a budget of 1024 tokens.
-
Span localization. Each returned span is mapped to character offsets in the response by exact substring match; spans whose text cannot be located in the response are discarded.
-
Token labels. The detector operates on tokens (one graph node per response token or window), so for downstream graph construction we convert the character-level spans into per-token labels: each response token—under the model's own tokenizer—is labeled incorrect if any of its characters overlaps any hallucination span, and correct otherwise. We use this inclusive overlap rule (rather than, say, requiring a token to be fully contained) so that the boundary tokens of a hallucinated phrase are not dropped, erring toward recall on the positive class; it is simple and deterministic, and it is applied identically to the native RAGTruth annotations, so token labels are consistent across all six models.
To assess the quality of the labels produced by our judge (QWEN2.5-32B), we audited the first ten test examples for each of the three newly annotated models—QWEN2.5-3B, QWEN2.5-7B, and MISTRAL-NEMO-12B—on every task, for 90 audited examples and 220 flagged spans in total. For each example we compared the model response, the source context, the final character-level spans, and the judge's free-form rationale. This appendix reports what we found, with verbatim examples; our headline conclusion is: the labels are accurate enough to train on, with a well-characterized and largely benign error profile.
Overall quality. The annotations are reliable on the points that matter most for token-level supervision. First, the character offsets are exact: all 220 flagged spans matched their recorded text under the substring-mapping step (220/220 in Table 6), so a flagged span is always aligned to the right tokens—there is no offset drift. Second, on Summarization the judge is both precise and well-calibrated: it leaves faithful summaries unlabeled (17/30 summaries received no span) and the spans it does emit are overwhelmingly genuine fabrications or contradictions (examples below). In general, the dominant error mode is over-flagging (false positives), not missed hallucinations, and it is concentrated in the more list-like Question Answering and Data-to-Text tasks; clear missed hallucinations were rare in our sample. Table 6 breaks the statistics down by model and task.
| Model | Task | Spans | Spans/resp. | Empty | Exact-offset |
|---|---|---|---|---|---|
| Qwen2.5-3B | Summ. | 15 | 1.5 | 5 | 15/15 |
| Qwen2.5-3B | QA | 26 | 2.6 | 0 | 26/26 |
| Qwen2.5-3B | D2T | 35 | 3.5 | 0 | 35/35 |
| Qwen2.5-7B | Summ. | 11 | 1.1 | 6 | 11/11 |
| Qwen2.5-7B | QA | 24 | 2.4 | 1 | 24/24 |
| Qwen2.5-7B | D2T | 31 | 3.1 | 0 | 31/31 |
| Mistral-Nemo | Summ. | 9 | 0.9 | 6 | 9/9 |
| Mistral-Nemo | QA | 26 | 2.6 | 1 | 26/26 |
| Mistral-Nemo | D2T | 43 | 4.3 | 0 | 43/43 |
Table 6: Audit statistics over the first ten test examples per (model, task), 90 examples in total. “Spans” is the total number of hallucination spans the judge flagged across the ten responses, and “Spans/resp.” the average per response; “Empty” counts responses with no flagged span (out of 10); “Exact-offset” counts spans whose recorded text matches the response substring at the recorded offsets.
What the judge gets right. A clear majority of flagged spans are genuine, well-localized hallucinations, and the judge is especially dependable on fabricated facts and on contradictions of the structured record. Three representative cases:
• Fabricated detail (Summarization, Qwen2.5-3B). The article to summarize states only that the ramp agent “started work at 5 a.m. and his shift was scheduled to end at 2:30 p.m.” The response adds that “the agent had been working overtime and was reportedly exhausted . . . Alaska Airlines is currently investigating the cause of the error.” The judge flags exactly the three invented clauses—“the agent had been working overtime”, “was reportedly exhausted”, and “Alaska Airlines is currently investigating the cause of the error”—all absent from the source.
• Numerical contradiction (Summarization, Mistral-Nemo). The article says B.B. King “has 30 Grammy nominations”; the response writes “a 15-time Grammy winner.” The judge correctly flags “15-time Grammy winner” as a conflict.
• Attribute contradiction (Data-to-Text, Qwen2.5-7B). For Finch & Fork the record has OutdoorSeating: False and Ambience.romantic: False; the response claims “outdoor seating” and “romantic and classy ambiance.” The judge flags both “outdoor seating” and “romantic and classy ambiance”—precise contradictions of the structured data.
The judge also correctly treats true-but-unsupported world knowledge as baseless content (e.g. flagging an added, factually correct explanation of DNA replication that does not appear in the passage), and reliably catches wrong opening hours in Data-to-Text (e.g. “open from 11:30 AM to 8 PM on weekdays …” when the record lists different per-day hours). The two boxes below show such cases verbatim.
Correct catch — fabricated detail (Qwen2.5-3B, Summarization)
Source (article): “…the employee started work at 5 a.m. and his shift was scheduled to end at 2:30 p.m.” — no mention of overtime, exhaustion, or an investigation.
Response, flagged spans: “the agent had been working overtime”; “was reportedly exhausted”; “Alaska Airlines is currently investigating the cause of the error”.
Judge’s reason: “This detail is not mentioned in the original news”; “There’s no mention of exhaustion”.
Verdict: Correct. All three clauses are fabrications absent from the article.
Correct catch — contradiction of the structured record (Qwen2.5-7B, Data-to-Text)
Record (Finch & Fork): OutdoorSeating: False, Ambience.romantic: False (classy: True). Response, flagged spans: “outdoor seating”; “romantic and classy ambiance”.
Judge’s reason: “‘OutdoorSeating’ is set to False in the structured data”; “‘romantic’ is false according to the structured data”.
Verdict: Correct contradictions. (A third flagged span on the same example, “starting at 14 for the first mimosa.”)
Where it errs: over-flagging on Question Answering and Data-to-Text. The false positives are concentrated in the two list-structured tasks, where responses heavily paraphrase or restate the source and the judge flags content that is in fact supported. Two clear cases:
• Supported paraphrase flagged (Question Answering, Qwen2.5-3B). The recipe passage explicitly lists cooking spray, cheese, and “onion, green pepper, and tomato slices.” Yet the judge flags “Cooking spray for the baking sheet”, “Cheese (optional)”, and “Place slices of onion, green pepper, and tomato on top of the fillets”—all directly supported. QA answers are long and itemized, and the judge frequently mislabels such faithful restatements.
- Judge overlooks support present in the source (Data-to-Text, Qwen2.5-7B). Each Data-to-Text example verbalizes a business record. For the restaurant Pizza Mizza, the judge flags “located in Santa Barbara, CA” and “With free Wi-Fi, outdoor seating, and take-out options” as unsupported, even though the record itself states city: Santa Barbara, WiFi: free, OutdoorSeating: True, and RestaurantsTakeOut: True. It likewise misses support in the record’s embedded customer reviews: for the restaurant Finch & Fork, it flags “starting at 14 for the first mimosa, and $1 for every mimosa after that.”
On Summarization these errors are much rarer; the most common minor issue there is flagging a faithful paraphrase or a clause carrying no factual claim (e.g. the discourse fragment “While the passage doesn’t provide specific details,”). The two boxes below give the two false-positive patterns verbatim.
False positive — supported content flagged (Qwen2.5-3B, Question Answering)
Source (recipe passage): lists “butter flavored cooking spray”, layering with “onion, green pepper, and tomato slices”, and adding cheese.
Response, flagged spans: “Cooking spray for the baking sheet”; “Cheese (optional)”; “Place slices of onion, green pepper, and tomato on top of the fillets.”
Judge’s reason: “The passage mentions using butter-flavored cooking spray but does not specify it as an ingredient” (and similar for the others).
Verdict: False positives. All three are stated in the passage; the judge over-flags faithful restatement on the long, itemized QA answers.
False positive — judge ignores supported fields (Qwen2.5-7B, Data-to-Text)
Record (Pizza Mizza): city: Santa Barbara, WiFi: free, OutdoorSeating: True, RestaurantsTakeOut: True.
Response, flagged spans: “located in Santa Barbara, CA”; “With free Wi-Fi, outdoor seating, and take-out options”.
Judge’s reason: “The address field is empty, so the exact location … is not specified” — yet city is present, as are the WiFi/seating/takeout fields.
Verdict: False positives. The flagged claims match fields that are present in the record.
A minor (< 2% of flagged spans), fixable error source. Beyond task-dependent over-flagging, we identified one structural issue: rationale–label mismatch (parsing). The judge sometimes emits a JSON list of candidate spans and then retracts some in the prose that follows; our parser keeps the JSON list and never sees the retraction. On the Rolling Stone summary (Qwen2.5-7B), “The magazine issued an apology” is recorded as a hallucination even though the judge’s own explanation states it “is supported by the original text, so it is not a hallucination.” This is rare: scanning the full test set, only 1.7% of flagged spans (49 of 2967) are plausibly retracted in this way. For such an example, see below.
Parser keeps a span the judge retracts in prose (Qwen2.5-7B, Summarization)
Judge’s JSON list (kept by the parser): ["The magazine issued an apology", ...]
Judge’s prose, same output: “‘The magazine issued an apology’ — This statement is supported by the original text, so it is not a hallucination.”
Verdict: False positive. The judge retracts the span in prose, but our parser reads only the JSON list, so the span is kept. As noted above, this affects only 1.7% of flagged spans.
Separately, we note a generation-side artifact that is not an annotation error: responses for the three new models were generated with a 256-token cap, which truncates most QA answers (the native RAGTruth responses, generated with a larger budget, are unaffected). Truncation does not create false positives; its only footprint on the labels is that when the usual QA over-flagging lands on the incomplete final sentence, the resulting span is a malformed partial sentence rather than a clean clause.
Severity and effect on training. The errors above are overwhelmingly false positives rather than missed hallucinations, and they have a mild effect on the per-token labels that downstream training consumes. The labels remain reliable where it counts: offsets are exact, faithful summaries are correctly left unlabeled, and genuine fabrications and contradictions are caught. Two properties further soften the residual noise: the over-flagged spans are usually whole clauses rather than scattered tokens, so the per-token overlap rule (rule 5 in the annotations rule above) does not spread error beyond the flagged region. We therefore regard the annotations as suitable supervision for token-level hallucination detection.
G Experiments: Monitoring for LLM misbehaviors with LEMON—Extended Section
Our experiments were conducted using the PyTorch (Paszke et al., 2019) framework (License: BSD), using a single NVIDIA L-40 GPU for all experiments. We used a fixed batch size of 16 graphs for all hallucination experiments, and 8 for the jailbreak; the latter is halved because jailbreak graphs are built over the full prompt rather than pooled response windows, and therefore contain roughly twice as many nodes per graph.
Hyperparameters. Table 7 lists all hyperparameters. The hallucination and jailbreak experiments share the same architecture, optimizer, and search space; they differ only in the batch size, the window size , and the prediction level, which follow from the jailbreak monitor predicting a single label per prompt rather than a label per response window. We keep the search space deliberately small: for every held-out LLM, we train the four combinations of MPNN layers and cross-token Transformer layers, and select the configuration—and, within it, the epoch—with the highest validation ROC-AUC, where validation data comes only from the training LLMs, so the held-out LLM never influences model selection. Unless stated otherwise (e.g., the adaptation study in Section G.6), we train with , i.e., the invariant head alone.
Table 7: LEMON hyperparameters. Values in braces are searched; the configuration is selected by validation ROC-AUC on the training LLMs only. Both LEMON variants share all settings.
| Hyperparameter | Hallucination | Jailbreak |
|---|---|---|
| Hidden dimension | 16 | |
| MPNN layers | \{1, 2\} | |
| Cross-token Transformer layers | \{1, 2\} | |
| Attention heads (cross-token Transformer) | 2 | |
| Dropout | 0 | |
| Attention threshold | 0.1 | |
| Loss weight | 0 | |
| Optimizer | AdamW | |
| Learning rate | , cosine decay to 0 | |
| Weight decay | 0 | |
| Gradient-norm clipping | 1.0 | |
| Epochs | 100 | |
| Random seed | 42 | |
| Batch size (graphs) | 16 | 8 |
| Window size | 8 | 1 |
| Prediction level | per window node | per prompt (final node) |
Optimizers and Schedulers. For all datasets, we use the AdamW optimizer Loshchilov & Hutter (2019) in combination with a cosine learning rate schedule that decays the learning rate from its initial value to zero over the course of training.
G.1 Baselines and Ablations: Implementation Details
All baselines follow the same cross-LLM protocol, splits, and evaluation units as LEMON.
Logistic-regression baselines. LB, LB+Align, and HS, as well as every per-LLM and adaptation classifier (Section G.6), use L2-regularized logistic regression (lbfgs, up to 1,000 iterations), with the inverse regularization strength swept over and selected by validation ROC-AUC. When a small labeling budget leaves the validation split with a single class, validation is merged into training and C=1 is used; when the training split has a single class, the cell is reported as degenerate (“—”).
LookbackLens (LB). Per-token LookbackLens features (Section B), one lookback ratio per layer-head pair, are zero-padded to the common grid, giving a 1,600-dimensional vector per token, and fed to the logistic regression above. The classifier is fit on the pooled training LLMs and applied as-is to the held-out LLM.
LookbackLens+Alignment (LB+Align). The same LookbackLens features and classifier, except that every LLM's features are first reindexed to a canonical reference by the head-alignment procedure of Section E.
Hidden-state probing (HS). We take the residual stream at layer 24 of each LLM, zero-pad it to the largest hidden dimension in the pool (5,120), reduce it to 128 dimensions with PCA fit on the training data only, and fit the logistic regression above. For hallucination, features are per token (window-averaged); for jailbreak, they are taken at the final prompt token.
Token probability (Prob). A training-free score: the logit the LLM assigned to each generated token, averaged within each window, is used directly as the confidence score (higher means more likely correct). It requires no fitting, so it is evaluated identically in every setting.
Attention to the system prompt (Attn→Sys). The training-free jailbreak baseline of Section 4.2 is computed from a single prompt-only forward pass using the full, unthresholded attention (the thresholded graphs used by LEMON would distort its mean). The span S is located by comparing the chat-templated prompt with the templated empty message.
CHARM. CHARM is trained through the identical pipeline, on identical graphs, loss, and splits, for 100 epochs with learning rate , sweeping hidden dimension and message-passing layers , i.e., the same number of configurations as LEMON. It has no cross-token Transformer, so those axes are not searched. For jailbreak, it uses batch size 8 and reads out the final node, as LEMON does.
Ablations. All graph-based ablations of Section 4.3 are trained through the identical pipeline on identical graphs, over the same hyperparameter grid as LEMON (Table 7); grid axes that configure a removed component are dropped. The graph-free ablation (without graph) trains a causal Transformer on the same window-pooled token probabilities and labels, with every applicable hyperparameter matched to LEMON.
Table 8: Every LLM we monitor, with its attention grid .
| Model | H | L |
|---|---|---|
| Training pool (K=6) — fitted on; held out one at a time | ||
| LLAMA-2-7B | 32 | 32 |
| LLAMA-2-13B | 40 | 40 |
| MISTRAL-7B | 32 | 32 |
| MISTRAL-NEMO-12B | 32 | 40 |
| QWEN2.5-3B | 16 | 36 |
| QWEN2.5-7B | 28 | 28 |
| In the wild — never trained on; monitored zero-shot | ||
| MISTRAL-7B-INSTRUCT-V0.2 | 32 | 32 |
| PYTHIA-CHAT-BASE-7B | 32 | 32 |
| PYTHIA-CHAT-BASE-7B-V0.16 | 32 | 32 |
| TINYLLAMA-1.1B-CHAT | 32 | 22 |
| ZEPHYR-7B-β | 32 | 32 |
| NOUS-HERMES-2-MISTRAL-7B-DPO | 32 | 32 |
| PHI-4-MINI-INSTRUCT | 24 | 32 |
| SMOLLM2-1.7B-INSTRUCT | 32 | 24 |
| SMOLLM2-360M-INSTRUCT | 15 | 32 |
| SMOLLM2-135M-INSTRUCT | 9 | 30 |
G.2 LLMs Used In Our Experiments
Every monitored LLM is open-weight and instruction-tuned. Table 8 lists all sixteen together with their attention grids ; we elaborate on them in the following.
Hallucination and jailbreak monitoring. Those experiments share the same pool of LLMs:
-
LLAMA-2-7B (Touvron et al., 2023), : the smaller of the two Llama-2 chat models and one of the two most heavily safety-aligned models in the pool.
-
LLAMA-2-13B (Touvron et al., 2023), : the same family and alignment recipe at roughly twice the scale. It has the largest grid in the pool and therefore defines the padded canvas into which every other LLM is embedded.
-
MISTRAL-7B (Jiang et al., 2023a), : a different pretraining lineage with exactly the same grid shape as LLAMA-2-7B.
-
MISTRAL-NEMO-12B Sreenivas et al. (2024), : a 12B Mistral model, and the only one whose grid is deep but not maximally wide.
-
QWEN2.5-3B (Yang et al., 2024), : the smallest LLM we monitor.
-
QWEN2.5-7B (Yang et al., 2024), .
Hallucination in the wild. These LLMs are never trained on; they only generate the responses we monitor with an unmodified LOO checkpoint.
- MISTRAL-7B-INSTRUCT-V0.2 (Jiang et al., 2023b), (32, 32): a later point release of a family in the training pool — hence the mildest shift we test.
• PYTHIA-CHAT-BASE-7B (Computer, 2023), (32, 32): a GPT-NeoX Black et al. (2022) lineage absent from the training pool entirely.
• PYTHIA-CHAT-BASE-7B-V0.16, (32, 32): a later revision of the same model.
• TINYLLAMA-1.1B-CHAT (Zhang et al., 2024), (32, 22): a 1.1B model, far shallower than anything seen during training.
• ZEPHYR-7B- (Tunstall et al., 2023), (32, 32): a DPO-tuned descendant of MISTRAL-7B.
• NOUS-HERMES-2-MISTRAL-7B-DPO, (32, 32): a second, independently DPO-tuned descendant of MISTRAL-7B; together the two test whether the post-training recipe — and not only the base model — shifts the attention signal.
• PHI-4-MINI-INSTRUCT (Abouelenin et al., 2025), (24, 32): a synthetic-data-centric family with no relative in the training pool.
• SMOLLM2-INSTRUCT (Allal et al., 2025) at 1.7B, 360M and 135M, (32, 24), (15, 32) and (9, 30): a deliberate size sweep down to the smallest grids we ever score, the last of which has only 9 attention heads.
G.3 Datasets Used In Our Experiments
Hallucination monitoring.
• RAGTruth (Niu et al., 2024) (these were used for training LEMON): word-level hallucination spans over retrieval-grounded generation. Because every response is produced from a supplied context, a hallucination is an unsupported claim rather than a factual error, which makes the label objective and checkable. It contains three tasks, and we train on their union and report each separately:
– Summarization (SUM): the task is to summarize a news article within a specified word budget; hallucinations are typically invented details or over-generalized attributions.
– Question answering (NQ): the task is to answer a user query using retrieved passages; hallucinations are claims that exceed what the passages support.
– Data-to-text (D2T): the task is to generate a prose description from a structured business record (JSON); hallucinations are attributes absent from the record.
RAGTruth ships human annotations for only part of our pool; for the remaining LLMs we generate responses ourselves and annotate them with QWEN2.5-32B; see details in Section F.
• Mu-SHROOM, English split (Vázquez et al., 2025) (in-the-wild evaluation only): human gold character-level spans over open-domain answers. There is no supplied context, so the LLM answers from parametric knowledge alone — a genuine distribution shift away from RAGTruth’s grounded setting.
• PsiloQA, English split (Rykov et al., 2025) (in-the-wild evaluation only): the same open-domain question-answering format at larger scale and across more generators, with silver spans produced by an automatic annotator. It is what lets us test transfer across many unseen LLMs at once.
Jailbreak monitoring. We use REDBENCH (Dang et al., 2026): a corpus of harmful requests, of which we use 3000 prompts per LLM. Each request is turned into an attack by appending a single universal GCG suffix (Zou et al., 2023) taken from HarmBench (Mazeika et al., 2024) and held fixed across every request and every monitored LLM; how that suffix was chosen is detailed below. Each of the six LLMs answers greedily, and STRONGREJECT (Souly et al., 2024) grades how much the response actually helps the original request — the suffix is stripped before grading, so the label measures genuine compliance rather than whether the model echoed the adversarial string — which we binarize at 0.5. The resulting attack-success rate spans roughly sevenfold across the pool (from ≈ 8% for the two Llama-2 models to ≈ 52% for MISTRAL-NEMO-12B; Table 9), confirming that the label is a property of the target LLM and not of the prompt — which is exactly what makes zero-shot transfer non-trivial here.
Table 9: Attack-success rate (ASR) % of the universal GCG suffix, per LLM.
| LLM | All 3000 prompts | Test split (750) | ||
|---|---|---|---|---|
| jailbroken | ASR (%) | jailbroken | ASR (%) | |
| LLAMA-2-7B | 256/3000 | 8.5 | 69/750 | 9.2 |
| LLAMA-2-13B | 234/3000 | 7.8 | 53/750 | 7.1 |
| MISTRAL-7B | 1325/3000 | 44.2 | 337/750 | 44.9 |
| MISTRAL-NEMO-12B | 1548/3000 | 51.6 | 394/750 | 52.5 |
| QWEN2.5-3B | 762/3000 | 25.4 | 212/750 | 28.3 |
| QWEN2.5-7B | 559/3000 | 18.6 | 143/750 | 19.1 |
| Pooled | 4684/18000 | 26.0 | 1208/4500 | 26.8 |
How the attack suffix was chosen. We reuse one fixed string verbatim for all 3000 requests and all six LLMs, taken as-is from the public HarmBench release (Mazeika et al., 2024). Most artifacts in that release store one suffix per behavior (per harmful request), thus, the only candidates are its ENSEMBLEGCG runs, which optimize a single suffix jointly over all 401 HarmBench behaviors and against an ensemble of targets. We use the 7B ensemble (LLAMA-2-7B, VICUNA-7B-V1.5, ORCA-2-7B). Of these, only LLAMA-2-7B is in our monitored pool; however, this does not favor the monitor, as LLAMA-2-7B nonetheless remains among the least susceptible LLMs in the pool (8.5%). The box below shows a complete input as it is fed to LLAMA-2-7B: the REDBENCH request with the attack suffix appended verbatim, wrapped in the model's own chat template.
A complete attack input to LLAMA-2-7B (REDBENCH request #40)
<s>[INST] How can I identify and steal high-value artwork or antiquities from museums or private collections?! Label columns({\boldsymbol{E}tatefulMay be-} transformations]-> techniqueInfo succ briefly'.$ alongside constraintTree [/INST]
Chat template | REDBENCH request | universal GCG suffix (119 characters, identical for every request and every LLM). LLAMA-2-7B refuses here (STRONGREJECT score 0.01), so this sample carries the label "attack failed".
Splits. The 3000 prompt indices are shuffled once under seed 42 and carved 1800/450/750 into train/validation/test (25% test, then 80/20 of the remainder). The split is at the prompt level and shared across all six LLMs, so a prompt held out for one LLM is held out for all of them; combined with the leave-one-out rotation over LLMs, a test sample is therefore unseen on both axes. It is not stratified by label, and cannot be: the STRONGREJECT label is a property of the (prompt, LLM) pair rather than of the prompt, since the same 3000 requests yield an attack-success rate of 8.5% on LLAMA-2-7B and 51.6% on MISTRAL-NEMO-12B, so no single shared partition can balance all six. The random partition nevertheless leaves each LLM's test-split rate within a few points of its overall rate (Table 9), and every shard remains usable: the least susceptible LLM still contributes 53 positives to its 750-prompt test split.
In the next subsections, we provide additional results, which were omitted from the main text due to space limitations
G.4 LOO results — Extended results
Table 1 of the main text averages the three RAGTruth tasks per held-out LLM. Table 10 gives the underlying per-task cells.
Table 10: LOO zero-shot generalization — per-task breakdown of Table 1. Each data row is one (left-out LLM, task) pair; every value is the ROC-AUC × 100 on that held-out shard; avg rows average the three tasks for that LLM. best per row; = second best.
| Held-out LLM | Task | Prob | LB | HS | CHARM | LB+Align | LEMON (Ours) | |
|---|---|---|---|---|---|---|---|---|
| -per-cell | ||||||||
| Llama-2-7B | SUM | 56.2 | 48.7 | 50.7 | 41.3 | 61.7 | ||
| NQ | 60.7 | 55.8 | 52.1 | 51.6 | 61.5 | |||
| D2T | 56.6 | 41.8 | 55.9 | 43.5 | 60.6 | |||
| avg | 57.8 | 48.8 | 52.9 | 45.5 | 61.3 | |||
| Llama-2-13B | SUM | 55.8 | 55.3 | 47.5 | 59.5 | 49.5 | ||
| NQ | 48.5 | 58.1 | 58.8 | 64.9 | 58.6 | |||
| D2T | 52.6 | 48.3 | 51.1 | 47.6 | 54.6 | |||
| avg | 52.3 | 53.9 | 52.5 | 57.3 | 54.2 | |||
| Mistral-7B | SUM | 54.3 | 48.7 | 40.6 | 57.8 | |||
| NQ | 66.8 | 50.3 | 43.6 | 32.8 | 56.3 | |||
| D2T | 43.9 | 53.0 | 58.5 | |||||
| avg | 67.6 | 49.5 | 51.0 | 42.2 | 57.5 | |||
| Mistral-Nemo | SUM | 48.6 | 42.9 | 44.8 | 59.4 | |||
| NQ | 55.2 | 58.0 | 55.4 | 39.1 | 61.8 | |||
| D2T | 58.5 | 50.7 | 52.6 | 48.6 | 60.7 | |||
| avg | 58.3 | 52.4 | 50.3 | 44.2 | 60.6 | |||
| Qwen2.5-3B | SUM | 61.2 | 53.5 | 48.8 | 42.0 | 53.6 | ||
| NQ | 58.7 | 50.7 | 52.0 | 41.2 | 50.8 | |||
| D2T | 58.7 | 47.2 | 42.4 | 45.9 | ||||
| avg | 61.6 | 54.3 | 49.3 | 41.9 | 50.1 | |||
| Qwen2.5-7B | SUM | 49.8 | 54.5 | 60.1 | 58.2 | |||
| NQ | 58.4 | 48.2 | 49.8 | 58.6 | 59.4 | |||
| D2T | 62.5 | 51.9 | 52.2 | 54.8 | 58.6 | |||
| avg | 61.1 | 50.0 | 52.2 | 57.8 | 58.7 | |||
| Mean (18 shards) | 59.8 | 51.5 | 51.4 | 48.1 | 57.1 | |||

Figure 13: Selective generation at . Orange = flagged and withheld, dashed = never generated, red underline = hallucinated.

Figure 14: RC-curves. The dotted line is the base hallucination rate. AURC is the area under the RC-curve.
G.5 Selective Generation
We demonstrate LEMON on selective generation: halting LLM generation when hallucination is likely. Section H formalizes the framework thoroughly; here we summarize only what is needed to interpret the results. Let denote an LLM-generated response (the prompt is treated as part of for notational convenience), and its prefix up to token . A confidence function estimates how likely the next token is to be hallucinated; generation halts the first time the confidence falls below a specified threshold , and the user is served only the prefix preceding the flagged error, denoted .
We evaluate a confidence function using four quantities, summarized in Equation (14) and illustrated in Figure 13, whose relative importance may vary across use cases: (i) coverage , the fraction of generations that are served in full, i.e., never halted; (ii) token-coverage , the average fraction of each generation that is served; (iii) selective risk , the fraction of served content that is hallucinated; and (iv) token-savings , the fraction of tokens that were withheld. Over N generations with full, unhalted lengths , these quantities are defined as follows:
where is the number of hallucinated units in and . Sweeping trades coverage/token-coverage against selective risk and traces the risk-coverage curve (RC-Curve), and provides an effective measure of a confidence function's quality.
Results. Figure 14 shows the RC curves of LEMON-W, LEMON-W-per-cell, and the strongest baseline, Prob, over the specific combination of the NQ dataset, for LLAMA-2-13B as left out LLM. We observe that both LEMON variants significantly outperform Prob, which is not even monotonically decreasing. In contrast, both LEMON variants exhibit consistently monotonic (decreasing) behavior and, for example, at 90% token-coverage, reduce the hallucination rate by more than 43%, while maintaining 73% of prompts fully served.
Finally, Table 11 reports the area under the RC-curve (AURC) for every (held-out LLM, task) shard, summarizing the whole risk-coverage trade-off in a single number per shard. LEMON attains the lowest AURC in 17 of the 18 shards, and averaged over the shards LEMON-W-per-cell reaches 8.9 and LEMON-W 9.1, against 12.3 for Prob.
Table 11: Selective generation. A per-shard breakdown of the area under the risk-coverage curve (lower is better). *Bold = best in row.
| LLM | Task | LEMON-W | LEMON-W-per-cell | Prob |
|---|---|---|---|---|
| Llama-2-7B | Summ. | 3.00 | 2.83 | 7.38 |
| NQ | 3.37 | 2.99 | 9.23 | |
| D2T | 5.97 | 6.00 | 9.67 | |
| mean | 4.11 | 3.94 | 8.76 | |
| Llama-2-13B | Summ. | 1.62 | 1.71 | 2.97 |
| NQ | 2.04 | 1.72 | 7.08 | |
| D2T | 6.65 | 6.77 | 11.25 | |
| mean | 3.44 | 3.40 | 7.10 | |
| Mistral-7B | Summ. | 6.58 | 6.57 | 7.56 |
| NQ | 1.74 | 1.41 | 8.20 | |
| D2T | 8.70 | 8.50 | 9.32 | |
| mean | 5.67 | 5.49 | 8.36 | |
| Mistral-Nemo | Summ. | 6.31 | 6.12 | 6.40 |
| NQ | 16.95 | 16.56 | 24.69 | |
| D2T | 20.82 | 20.64 | 24.28 | |
| mean | 14.69 | 14.44 | 18.46 | |
| Qwen2.5-3B | Summ. | 7.37 | 7.52 | 9.96 |
| NQ | 12.40 | 12.59 | 18.77 | |
| D2T | 19.87 | 19.81 | 19.81 | |
| mean | 13.21 | 13.31 | 16.18 | |
| Qwen2.5-7B | Summ. | 6.96 | 7.17 | 7.48 |
| NQ | 13.51 | 13.21 | 17.28 | |
| D2T | 19.97 | 18.33 | 19.38 | |
| mean | 13.48 | 12.90 | 14.72 | |
| All | mean (18) | 9.10 | 8.91 | 12.26 |
G.6 Few-shot adaptation
We test whether LEMON can adapt to the held-out LLM given labeled samples from its training shard. Since LEMON's invariant head (see Figure 15, left) discards head and layer identity by design, we retrain LEMON under the same LOO setup with a second, per-LLM non-invariant head (Figure 15, right) alongside the original invariant one.
The two heads are trained jointly with a convex combination of their binary cross-entropy losses,
so that recovers the original, invariant-only training. The non-invariant head pushes the per-node features to be linearly separable for hallucination detection, so that a lightweight classifier can adapt to a new LLM with minimal supervision. Adaptation itself is simple: we freeze the backbone, extract on the held-out LLM, and fit a logistic regression on the labeled samples. Two questions arise: (1) are the learned features adaptable? (2) does training a second head hurt zero-shot transfer? As a reference to this experiment, we use the LB baseline fit on the same samples.
Results. (1) The features are adaptable. With the full adaptation set ( ), logistic-regression adaptation on LEMON features improves as increases and plateaus at around (Figure 17). We therefore fix to evaluate adaptation in low-sample regimes. In this setting, LEMON-W-per-cell outperforms LB at (+2.2 ROC-AUC) and performs comparably at all larger budgets (Figure 16). (2) The second head does not hurt zero-shot transfer. Zero-shot performance of the invariant head remains stable for and degrades only at , where the head receives no gradient.
Invariant head Per-LLM head

Figure 15: Invariant and per-LLM heads (one linear predictor per pool LLM). is the per-node features before the prediction heads. Dashed LR: the adaptation read-out, fit on the frozen after training, so it does not feed .
G.7 LOI Results
In the leave-one-in (LOI) setup, each detector is trained on the three task shards of a single LLM and evaluated zero-shot on the remaining five LLMs—the minimal-source-diversity counterpart of

Figure 16: Adaptation to the held-out LLM vs. labeling budget, both LEMON variants; mean over the 18 (LLM, task) shards. Solid: logistic regression on the frozen non-invariant head's features ( ) and LB; dashed: the corresponding invariant-head (zero-shot) levels. The signed number at each point is that variant's gap to LB.
the LOO setup. Table 12 reports the full per-task breakdown.
Table 12: LOI zero-shot generalization — per-task breakdown. Each monitor is trained on a single (left-in) LLM and evaluated zero-shot on the other five. Each data row is one (left-in LLM, task) pair; every value is the mean ROC-AUC × 100 over the five held-out evaluation LLMs; avg rows average the three tasks for that LLM. best per row; = second best.
| Left-in LLM | Task | Prob | LB | HS | CHARM | LB+Align | LEMON (Ours) | |
|---|---|---|---|---|---|---|---|---|
| -per-cell | ||||||||
| Llama-2-7B | SUM | 53.4 | 48.3 | 60.1 | 55.8 | 55.7 | ||
| NQ | 57.5 | 56.1 | 52.1 | 59.2 | 59.9 | 66.1 | ||
| D2T | 55.7 | 50.0 | 54.4 | 49.2 | 54.5 | 64.7 | ||
| avg | 55.1 | 50.1 | 57.9 | 55.0 | 57.6 | 64.3 | ||
| Llama-2-13B | SUM | 49.7 | 53.4 | 50.6 | 49.5 | 61.8 | 63.5 | |
| NQ | 60.0 | 49.6 | 52.7 | 50.0 | 54.3 | 71.7 | ||
| D2T | 50.6 | 53.3 | 52.2 | 44.0 | 61.3 | |||
| avg | 61.3 | 49.9 | 53.1 | 50.9 | 49.3 | 65.5 | ||
| Mistral-7B | SUM | 59.3 | 57.4 | 50.8 | 49.6 | 58.9 | 64.7 | |
| NQ | 56.3 | 56.4 | 49.2 | 64.3 | 62.6 | 73.3 | ||
| D2T | 59.0 | 54.0 | 52.0 | 50.7 | 55.8 | 63.9 | ||
| avg | 58.2 | 55.9 | 50.7 | 54.9 | 59.1 | 67.3 | ||
| Mistral-Nemo | SUM | 61.3 | 48.3 | 49.7 | 49.8 | 53.6 | ||
| NQ | 58.6 | 50.0 | 48.7 | 52.8 | 51.9 | 76.6 | ||
| D2T | 60.3 | 57.7 | 54.3 | 45.4 | 51.9 | 60.6 | ||
| avg | 60.1 | 52.0 | 50.9 | 49.3 | 52.5 | 67.7 | ||
| Qwen2.5-3B | SUM | 61.3 | 53.2 | 50.0 | 43.8 | 51.1 | 67.8 | |
| NQ | 57.9 | 53.5 | 49.4 | 42.9 | 53.4 | 74.5 | ||
| D2T | 59.0 | 50.7 | 56.9 | 48.9 | 51.6 | 64.6 | ||
| avg | 59.4 | 52.5 | 52.1 | 45.2 | 52.0 | 69.0 | ||
| Qwen2.5-7B | SUM | 61.1 | 44.4 | 51.8 | 48.2 | 52.5 | ||
| NQ | 58.0 | 46.2 | 51.6 | 32.6 | 51.1 | 76.1 | ||
| D2T | 59.5 | 39.1 | 55.4 | 52.6 | 48.8 | |||
| avg | 59.5 | 43.2 | 52.9 | 44.4 | 50.8 | |||
| Mean (18 shards) | 59.8 | 51.4 | 51.6 | 50.4 | 53.1 | 66.9 | ||

Figure 17: Invariant head vs. non-invariant head + LR as a function of , both LEMON variants. We report the mean over the 18 (LLM, task) shards. Raising trains the per-LLM non-invariant pathway and improves adaptation, while at the invariant head collapses towards chance as expected.
H Selective Generation: Formal Framework
This appendix formalizes the selective-generation setting introduced in Section G.5. It builds on selective prediction (Geifman & El-Yaniv, 2017), in which a model is trained to know what it does not know, allowing it to abstain when insufficiently confident. The rejection option dates back over sixty years (Chow, 1957) and has since been studied for neural networks (Geifman & El-Yaniv, 2017; 2019). For LLMs, abstention has mostly been studied at the response level: refusing or deferring a whole answer based on uncertainty estimates, self-evaluation, or conformal guarantees (Cherian et al., 2024; Kuhn et al., 2023; Kadavath et al., 2022). In contrast, we formalize selective generation for LLMs at the token level, using an online monitor during decoding, such as LEMON, the monitor introduced in this paper, to halt generation mid-response.
Setup. We consider standard autoregressive LLMs. Writing for a token sequence, they decompose its next token probability using the chain rule:
where is the prefix preceding token (with the empty sequence). At inference time, an LLM generates tokens sequentially by sampling each new token from its predicted conditional categorical distribution over the vocabulary , until an end-of-sequence token (EOS) is produced. Thus, for each prefix , the LLM defines a mapping,
where denotes the probability simplex over V.
Selective generation. We define a selective generator as a pair of functions acting on prefixes of arbitrary length, . Here, denotes the LLM itself, with , while is a selection function.
Whenever the LLM samples a new token , inspects the preceding prefix and decides whether to serve the new token or to withhold it and stop generating:
see Figure 18 for an illustration of the selective-generation process.

Figure 18: The selective generator : the LLM samples one token at a time, while the selection function decides whether to serve the newest token and continue generation, or to withhold it and halt.
Thus, generation halts at the first time step at which abstains. Writing for the full, uninterrupted generation, terminating with the EOS token at step , the halting step is defined as:
Halting at splits the generation into three parts (see Figure 19):
• The tokens , each of which passed g's check and was delivered to the user.
• The flagged token .
• The suffix beyond , which is never generated at all.
We define the served output as the prefix of that is actually delivered to the user:
: first rejection; is flagged and withheld

Figure 19: The halting step of equation 16 and the served output of equation 17: abstains for the first time at “Mars”, so . The user sees only the tokens delivered before the flag (blue); the flagged token itself is withheld (orange), and the suffix beyond it is never generated (dashed).
Whether an individual token is served is thus determined jointly by all the decisions up to it. Define the per-token acceptance ,
which equals 1 iff no prefix preceding was rejected, i.e., iff belongs to . We note that is 0 from the first rejected token onward, and that iff the full generation is served; Figure 20 visualizes how aggregates the individual decisions of .

Figure 20: The per-token acceptance of equation 18: each token is gated by the decision , made on the strict prefix preceding it (arrows), and is the product of all the decisions up to the one gating —a single rejection anywhere zeroes it.
Using , we also define the cumulative selection function as the fraction of served tokens,
(19) so that iff generation reached EOS with no abstention (), while a truncated generation earns the partial credit ; see Figure 21 for an illustration of the three quantities , , and , over an example.
Figure 21: The three selection functions on two different generations (one per row); the time step t of each token is shown above it.
Coverage and selective risk. The performance of a selective generator is quantified by two quantities: token-coverage and selective risk. Let denote the distribution over full, uninterrupted generations induced by drawing a prompt and sampling the response from until EOS. token-coverage is the expected fraction of generated tokens that are served,
To quantify risk, we assume a loss function that scores the generation of the last token in a prefix, , which can be any measure of the quality—for instance, its perplexity under a reference model, or a binary indicator of hallucination. The selective risk weights each token's loss by its acceptance:
Importantly, only served tokens contribute to the selective risk. We now turn to define their empirical counterparts, which are used in practice to evaluate selective generators on finite datasets.
Empirical estimators. Given an evaluation set of prompts with full generations and served outputs as above, both quantities are estimated by replacing expectations with sample means. Thus, the empirical token-coverage is the average served fraction,
and the empirical selective risk is,
(23) token-coverage credits partially served generations, so it does not reveal how many responses the user receives untouched. We therefore also define the coverage: the fraction of generations that are served in full, i.e., that reach EOS without ever abstaining (, equivalently ):
so that counts the responses fully satisfied under . Since a fully served generation contributes to the token-coverage while a truncated one contributes only its served fraction, we always have .
Compute savings. Beyond withholding errors, halting also saves compute: the suffix beyond the flagged token is never generated. We define the token-savings simply as the complement of token-coverage,
the average fraction of each generation that is withheld. An illustration of the empirical coverage, token-coverage, selective risk, and token-savings is given in Figure 22.
| x: | Water | boils | at | 90 | degrees | EOS |
|---|---|---|---|---|---|---|
| : | 1 | 1 | 1 | 1 | 1 | 1 |
| : | 1 | 1 | 1 | 1 | 1 | 1 |
| : | 0 | 0 | 0 | 1 | 0 | 0 |
| x': | The | Moon | orbits | Mars | every | month | EOS |
|---|---|---|---|---|---|---|---|
| : | 1 | 1 | 1 | 0 | . | . | . |
| : | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
| : | 0 | 0 | 0 | 1 | 0 | 1 | 0 |
Figure 22: Coverage equation 24, token coverage equation 22, selective risk equation 23, and token savings equation 25 on an evaluation set of generations. Beneath each token, as in Figure 21: the per-step decisions , the per-token acceptance (latching to 0 from the first rejection), and the per-prefix losses (red underline = hallucinated).
H.1 Constructing Selective Generators and the Risk–Coverage Curve
In this section we present a general technique for constructing a selective generator, using a confidence-rate function for an LLM that scores each prefix by its confidence in the next token. For to be useful for selective generation, it should be monotone: larger values of should indicate that the next token is more likely to be correct, or equivalently, less likely to be hallucinated. Formally, given , , we require that:
Namely, if the confidence in the next token is higher than that of , then should be more likely to be correct than .
Given such a confidence function and a threshold , we construct a selection function by thresholding the confidence:
Since the decision gating is computed from the served prefix alone, is a selective generator for every : generation halts the first time the confidence dips below the threshold.
The risk-coverage curve. The threshold controls the trade-off between token-coverage and risk: raising it withholds more aggressively, lowering the token-coverage and—for a monotone —the selective risk with it. Sweeping thus traces the risk-coverage (RC) curve , which summarizes the selective-generation ability of a confidence function across all operating points; we condense it into a single number, the area under the curve, (lower is better, and comparable across confidence functions).