Manuscript Offprint

arXiv:2609.09902

Contrastive Projection: Reading Transformer Internals by Differencing Logit Lenses

Olli Tuomi

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Reading a transformer’s internal states in token space is easy to do and hard to trust: a logit lens on a single hidden state is dominated, at intermediate layers, by the generic tokens the model would predict for almost any input. We read the difference instead. Subtracting two closely matched prompts’ hidden states and projecting through the unembedding cancels the shared component and surfaces what separates them, an operation equivalent to reading a RepE/ActAdd steering vector through a logit lens. Built into a training-free tracer that reads at every position, sub-layer, and head and averages over designed baselines, it traces a compound-noun MLP→attention chain in Phi-2, confirmed there by activation patching, with the same distinction recovered across three architectures by readout and probe rather than by patching; it reads what retrieval surfaces for real versus fictional entities, and reads metaphor as a set of domain-to-domain mappings rather than a single figurativity feature. A cross-seed control marks the boundary: across five networks differing only in initialization, the same distinction surfaces as almost entirely different tokens (top-10 overlap 0.08). What a computation looks like in token space is network-specific; the distinction it draws is not.

1 Introduction

A transformer processing “The hot dog was” predicts continuations about food. The same model given “The cold dog was” predicts continuations about an animal. The logit lens (nostalgebraist, 2020) projects each hidden state through WUW_U. But the single-input projection is dominated by strong shared signals. At intermediate layers it reads the same high-frequency function words for both inputs (“not, no, made, more”), not the food or animal content (Table 1, first column).

Subtracting one hidden state from the other before projecting through WUW_U cancels the shared signals and reads what differs. The hot dog–cold dog difference reads food vocabulary from layer 8 on (“fried, crispy, delicious, flavor”), absent from either constituent’s logit-lens top-20 (0–1/5 overlap through L24). The same contrast read the other way, cold–hot, surfaces animal vocabulary (“grooming, Paw, Bark, breeds”), the pet reading that the food direction cancels. The difference is signed: each direction reports what one side carries that the other does not.

Two closely matched inputs share most of their computation, so what survives the subtraction is the component where the model treats them differently.

LRaw (both)hot – coldcold – hot
8nt, no, partyfried, hors, crispyvet, Pent, ogie
22not, made, moretast, delicious, flavorgrooming, euth, Paw
24not, more, sodelicious, tast, flavorgrooming, Paw, Bark

Table 1: The opening contrast, read at the final token of “The hot dog was” versus “The cold dog was” (Phi-2). The raw logit lens of either input reads high-frequency function words at every layer; the hot–cold difference reads food vocabulary (legible from L8), the cold–hot difference reads animal vocabulary (sharpening by L20). Verbatim top-3; some entries are sub-word fragments (“nt,” “hors,” “euth”) or noise (“Pent, ogie”).

Every contrastive reading is pair-specific. It reports what separates one particular pair of prompts. A tight pair that varies one thing reads more cleanly than a loose pair that varies several. Contrast design steers the reading: what it surfaces is chosen, not discovered. This is a mechanistic form of contrastive explanation, where one explains why one case rather than a chosen foil, and the foil fixes the answer (van Fraassen, 1980; Lipton, 1990).

The primitive is not new. Differencing two prompts’ hidden states and projecting through WUW_U is the arithmetic of a Representation Engineering (RepE) or Activation Addition (ActAdd) steering vector (Zou et al., 2023; Turner et al., 2023) read through a logit lens (nostalgebraist, 2020). Du et al. (2026) already used this exact operation. They decoded an activation difference through the logit lens to trace control signals for reflection in R1-style reasoning models. Our contribution is what this readout becomes as a systematic tracer. Read at every position and sub-layer, and averaged over designed baselines, it locates where an axis of variation first becomes legible in token space, which sub-layer writes it, and which head carries it. We add three techniques and a set of applications:

  1. Systematic trajectory reading. Per-position tracing locates where a distinction first appears and how it flows between positions. Per-head decomposition identifies which attention heads carry it. Layer-by-layer readout tracks how the content changes from early detection to final prediction.

  2. Multi-contrast triangulation. A single pair reports every way the two prompts differ, not only the intended axis, so its readout can be hard to read. Contrast the target against several baselines that share the intended axis but differ on the incidental ones, then average. The incidental axes cancel and the shared one remains (§2.7).

  3. Contrast design. What the readout surfaces depends on how the pair is built. We give rules for matched contrasts: a shared preamble to avoid the massive-activation first token, a matched current token at the read position so the difference is content and not token identity, and a matched predicted next token to expose mid- and late-layer computation (§2.5).

We apply the method to Phi-2 (2.7B). We re-run the compound-noun circuit across three architectures (Phi-2, Pythia-1.4B, and Qwen2.5-1.5B) to separate what generalizes from what is model-specific (§3.2). The cases shown are selected from several hundred readings. We report the most illustrative.

One caveat frames everything that follows. The specific tokens we read out (“fried,” “Nepal,

Tibet," "delicious") are illustrative, not a stable code. A cross-seed control (§6) shows that five networks differing only in initialization surface the same distinction as almost entirely different tokens (top-10 overlap 0.08), while the distinction itself holds in every seed. Throughout, read a token as evidence of what a contrast separates in one network, not as a canonical vocabulary.

References (20)