Teaching Layer-Contrastive Decoding When to Act, With a Plain Classifier

Language models sometimes state false things fluently, which is called hallucination. One family of fixes changes how each word is chosen. It compares the model's predictions at a deep internal layer against a shallow one and boosts words the deep layer prefers, on the theory that deep layers carry facts and shallow layers carry surface patterns. Applied to every word, this hurts: it "overthinks" punctuation and filler. The best recent system, Active Layer-Contrastive Decoding (ActLCD), therefore decides word by word whether to apply the contrast. It learns that on/off choice with reinforcement learning (imitation of good decisions plus a conservative offline Q-learning method) and a hand-designed reward. We ask whether that machinery is necessary.

Our proposal replaces the reinforcement-learning policy with an ordinary binary classifier trained with binary cross-entropy (the standard logistic loss for yes/no prediction). It reads the model's hidden state and predicts a directly measured quantity: if we apply the contrast at this word and decode normally afterward, does the final answer become correct when it otherwise would not, or the reverse? One observation makes this affordable. Under greedy decoding, the contrast can only matter at words where it changes the top choice, so counterfactual labels need extra rollouts only at those "flip" positions. If this simple classifier matches ActLCD, a sequential decision problem turns out to be a supervised one. If it falls short, we learn something specific: credit assignment across many interacting words genuinely matters for factual decoding.

Core Claim

The on/off decision for layer-contrastive decoding can be learned as two calibrated binary predictions at each flip position. The first is the probability that intervening here helps the final answer. The second is the probability that it hurts. The classifier is trained only on single-word counterfactuals, intervening at one position at a time. We claim that intervening whenever the predicted gain exceeds a threshold recovers most of ActLCD's improvement, with a simpler training procedure and an explicit setting for how often to intervene. A second claim matters as much. The label is what makes this work, not the classifier. A probe of the same shape trained to predict the model's uncertainty, as in Semantic Entropy Probes, should gate worse. Being unsure at a word does not mean the deep layer knows better at that word.

How the Gate Is Built

Let $h_t$ be the hidden state at a mid-to-late layer when the model is about to emit word $t$. Let $g$ denote plain greedy decoding and $c_t$ denote greedy decoding with the layer contrast applied at position $t$ only. Position $t$ is a flip position when the two methods choose different words there. At each flip position on training questions with checkable answers, we run both continuations to the end and record two labels. The first, $u_t$, equals 1 if $c_t$ ends correct while $g$ ends wrong. The second, $d_t$, equals 1 if the reverse happens. Two logistic heads $f_u$ and $f_d$ are trained on $h_t$ with binary cross-entropy:

$$ \mathcal{L} = -\sum_t \big[u_t \log \sigma(f_u(h_t)) + (1-u_t)\log(1-\sigma(f_u(h_t)))\big] + \big[\text{same for } d_t, f_d\big], $$

where $\sigma$ is the logistic sigmoid. At decoding time we intervene at a flip position when $\sigma(f_u(h_t)) - \sigma(f_d(h_t)) > \tau$. The threshold $\tau$ is set on a held-out calibration split, either to maximize accuracy or to meet a fixed intervention budget.

Helpful flips will be rare, which recreates the class-imbalance problem familiar from rare-event detection with binary cross-entropy (see BCE3S). We therefore compare unweighted and class-weighted versions, and report calibration error alongside accuracy.

We use the layer that Semantic Entropy Probes found most informative, in the middle-to-late range, and sweep neighboring layers. The probe is linear by default, with a small two-layer variant as a check. That paper is the main source of our method: it shows linear probes trained with binary cross-entropy on single-pass hidden states carry real signal about the model's own uncertainty. We differ from it by putting the probe in charge of an intervention rather than a report, and by changing its target.

Research Program

The work has three parts. The first is building the counterfactual label set. We do this on short-answer question answering and reasoning data with automatic correctness checks, and measure how many flip positions occur per answer and what fraction help or hurt. This analysis is informative by itself. If almost no flips help, layer contrast has little headroom on that task, regardless of who decides.

The second part trains the gate and compares it against ActLCD, static contrast on every word, and simpler gates. Every gate uses the same decoder and the same contrast operator, and only the gating rule differs.

The third part tests the single-word assumption directly. We take answers where the gate fires at several positions and compare the result of applying all chosen interventions together against the outcomes of the individual interventions. This measures how much the interactions that reinforcement learning is supposed to handle actually occur.

A fourth, cheaper analysis addresses a disagreement in the literature. SpikeScore reports that hidden-state probes trained to detect hallucination drop to roughly 0.50 to 0.60 AUROC (area under the ROC curve, where 0.5 is chance) out of domain. It fixes this by questioning the model over 20 dialogue turns. Semantic Entropy Probes argue instead that uncertainty probes transfer well. Our gate is trained on one domain and deployed on others, so it gives a test of transfer in a setting where the probe's decisions have consequences. We report both the gate's AUROC for predicting helpful flips and the resulting answer accuracy, across domains.

Baselines

The naive reference point is plain greedy decoding with no contrast. The second reference is static layer contrast applied at every word, in the style of DoLa as described in ActLCD. That paper reports static contrast degrades simple words, so a gate has to beat it to be worth anything.

The strongest competitor is ActLCD itself. It is the only method in the file that learns when to apply layer contrast, and it reports the gains we must match. These are a maximum gain of +19.81% on TruthfulQA's combined truthful-and-informative score, +7.21% accuracy on GSM8k, +7.51% on StrategyQA, and reductions in invented-package rates of 6.5% for Python and 5.6% for JavaScript relative to greedy decoding. All of these are gains over the paper's own baselines. The file gives no absolute scores, so we will rerun ActLCD rather than copy numbers. ActLCD and our gate will use the same base model, the same contrast layers, and the same training questions. They will also get matched compute for producing training signal, counted as total forward passes for rollouts. Each receives an equal hyperparameter search budget, tuned on the same calibration split.

Beating ActLCD means matching its accuracy within run-to-run noise at no more decoding latency, or exceeding it on a majority of benchmarks. Falling clearly below it on the tasks with long, multi-step answers, GSM8k and LongFact, would mean sequential credit assignment matters there.

The key ablation keeps the classifier and decoding rule fixed and changes only the label. We compare our counterfactual help/hurt labels against binarized semantic-entropy labels, following Semantic Entropy Probes, and against final-answer correctness labels. A second ablation drops the hurt head and gates on predicted help alone. This tests whether modeling harm is what prevents the overthinking failure.

For context on TruthfulQA's multiple-choice scores, Faithful Finetuning combined with an inference-time editing method reports 51.41 MC1 and 74.00 MC2. That method changes model weights, so it is a reference rather than a like-for-like competitor. The two approaches could be combined, as that paper did with TruthX. We found no reported result on Lacuna for DoLa alone on these benchmarks, so we will measure it ourselves.

Why not just…?

Why not just gate on the model's own uncertainty, such as the entropy of the next-word distribution, with no training at all? This is the most serious threat, and we treat it as a co-equal hypothesis rather than a strawman. Our reason to expect it to fall short comes from Semantic Energy. That paper shows models are often "confidently wrong", putting most probability on one incorrect answer, and that probability-based uncertainty misses these cases; its logit-based alternative gains over 13 AUROC points in exactly these cases. An entropy gate would stay silent there, and those may be the cases where the deep layer disagrees usefully. The experiment decides it: we run entropy-threshold gating and raw-logit-energy gating at matched intervention rates. If either matches the trained gate, we will report that the counterfactual labels are unnecessary.

Why not just apply contrast at every word, or lower the sampling temperature? ActLCD reports that selective intervention beats static contrast across benchmarks and that greedy decoding still invents software packages, so neither fixes the problem. Temperature changes only how sharp the distribution is. It cannot change which word ranks first, so it leaves the facts in the greedy answer unchanged. Both are included as baselines.

Why not just use multi-sample semantic entropy, or ask the model to check its own answer? Semantic Entropy Probes note that semantic entropy multiplies inference cost roughly tenfold, and it detects errors without correcting them. On self-checking, HaluEval reports ChatGPT detects hallucinations at only 62.59% accuracy in question answering and 58.53% in summarization, with many open models near or below 50%. We still include semantic entropy as an upper-reference detector for the gate's helpful-flip prediction, but not as a decoding baseline.

Proposed Experiments

We train gates on TriviaQA questions and evaluate them in two settings. In-domain evaluation uses held-out TriviaQA. Cross-domain evaluation uses TruthfulQA, reporting TruthfulQA's truthful-and-informative score and MC1/MC2, plus StrategyQA, GSM8k, and the software-package hallucination benchmark used by ActLCD. We use Llama-2-7B, the base model in Faithful Finetuning, and Mistral-7B, used in Semantic Entropy Probes.

We report answer accuracy, the fraction of words where the gate intervenes, added latency against ActLCD's stated 3–5%, and the gate's AUROC and calibration error for predicting helpful flips. For long-form output we score LongFact claim support, following the claim-level specificity work. That work reports a utility of 0.913 with its post-hoc calibrated method, against 0.846 without it. Their method edits finished drafts, so the two could be stacked; we report ours alone and stacked.

Three checks decide the outcome. The first is whether the trained gate matches ActLCD within noise on TruthfulQA and StrategyQA, where answers are short and single-word counterfactuals should approximate the full effect well. The second is whether the counterfactual-label gate beats the uncertainty-label and entropy gates at equal intervention rates. If it does not, the core claim fails. The third is whether, on GSM8k and LongFact, the combined effect of several interventions departs from the individual effects, and whether the gate's shortfall against ActLCD there is explained by that departure. Together these tell us where supervised gating is enough and where sequential learning is needed.