Anchor-token masking
Never mask the retrieved prefix, always subject the target to the noise schedule. On identical data the fine-tune generalises 1.67× better out of distribution than the standard objective, and the paper shows where in the network the gain lives.
Retrieval-grounded generation hands a diffusion language model tokens it already knows and asks it to write around them. The standard training objective ignores that asymmetry and masks every position alike. This work trains rank-16 LoRA adapters on a 1.3B-parameter masked-diffusion model under three objectives that differ only in which positions may be masked, then measures how well each extends a locked anchor on held-out domains it never saw. The mechanism is tested four ways, ending in a direct ablation.
What was measured
Three masking strategies are compared for fine-tuning masked-diffusion language models on retrieval-grounded data: anchor-token masking, where the prefix question is never masked and the answer statement is always subject to the noise schedule; random-position masking, uniform over both; and a reverse-asymmetric control that masks only the prefix. Rank-16 LoRA adapters are trained on Cassandra T1, a 1.3B-parameter model at epoch-5 cross-entropy 2.26, for 300 steps on 144 question and answer pairs, and evaluated by the corpus-vocabulary overlap of the text generated after a locked anchor, on 15 in-domain queries and 48 held-out queries across astronomy, medicine, law and cooking.
Anchor-token masking produces a 1.67× pooled held-out advantage over random-position masking, with a 95% bootstrap interval of [1.51, 1.85] and P(anchor > random) = 1.000. The in-domain advantage is 1.26× with interval [1.18, 1.34]; the two intervals do not overlap, so the effect favours generalisation rather than fit. The reverse control lands below random at P = 0.006, so the direction of the asymmetry carries the effect. A sweep over six training budgets shows the advantage peaking at 1.97× to 2.19× at 100 steps and closing to 1.07× at 1000 steps on 144 examples. Four mechanism probes, ending in a direct ablation, locate the effect in the value and output projections: a V/O-only LoRA outperforms the full LoRA at half the trainable parameters, and a Q/K-only LoRA falls below the random control.
Three objectives that differ in one line
A training example is a question Q and an answer statement A, padded to sequence length L. Each training step draws a mask ratio \gamma(t) uniformly from [0.5, 0.9] and then draws a mask m_i per position. The three strategies differ only in which class of position the Bernoulli draw may touch, and the loss is computed over the masked positions of that class.
m_i = \begin{cases} 0 & i \in Q \\ \mathrm{Bernoulli}(\gamma(t)) & i \in A \\ 0 & i \in \mathrm{Pad} \end{cases}\mathcal{L} \text{ over } \{ i \in A : m_i = 1 \}m_i = \begin{cases} \mathrm{Bernoulli}(\gamma(t)) & i \in Q \cup A \\ 0 & i \in \mathrm{Pad} \end{cases}\mathcal{L} \text{ over } \{ i \in Q \cup A : m_i = 1 \}m_i = \begin{cases} \mathrm{Bernoulli}(\gamma(t)) & i \in Q \\ 0 & i \in A \\ 0 & i \in \mathrm{Pad} \end{cases}\mathcal{L} \text{ over } \{ i \in Q : m_i = 1 \}At inference the retrieved locus statement s is tokenised and locked at positions [0, |\mathrm{tokenize}(s)|) of the answer slot. The unmasking loop excludes locked positions from the masked set at every denoising step, so locked tokens are preserved by construction; this mechanism is identical across arms and untouched by training. The coherence metric is \mathrm{corpus\_overlap}(\mathrm{text}, \mathrm{vocab}), the fraction of word tokens in the post-anchor text whose lowercase form is in the corpus vocabulary, the union of tokens over all locus statements in the relevant corpus. Confidence intervals come from 10,000 bootstrap resamples of the per-query values, percentile method, and P(a > b) is the fraction of resamples where the mean of a exceeds the mean of b.
Identical across arms except the mask
| Component | Value |
|---|---|
| Base model | Cassandra T1 v1, 1.3B parameters, 28 layers, 2048 hidden, GQA 16 query / 4 key-value heads, 32K BPE vocabulary, epoch-5 cross-entropy 2.2561 |
| Training data | 144 (Q, A) pairs from three LTMi-XT corpora (C1 cold-storage operations, C2 Cassandra T1 architecture, C3 business operations), three templated questions per locus |
| LoRA | rank 16, alpha 32, q_proj / k_proj / v_proj / o_proj in all 28 layers, 7M trainable parameters (0.5% of base) |
| Optimiser | AdamW, learning rate 1e-4 cosine to 1e-5, betas (0.9, 0.95), weight decay 0.01, batch 2, sequence length 192, 300 steps, gradient clip 1.0, seed 42 |
| Mask ratio | γ(t) sampled uniformly from [0.5, 0.9] every training step, identical across arms |
| Evaluation | 15 in-domain queries; 48 held-out queries, 12 each across astronomy, medical, legal and cooking corpora with 10.5% to 15.6% vocabulary overlap with training |
| Decoding | 12 unmasking steps, temperature 0.8, top-p 0.9, beta 0.5, repetition penalty 1.3, answer length 96 tokens, generation seed 1234 |
| Compute | 75 to 100 seconds per LoRA; about 60 minutes to reproduce everything on a single consumer GPU |
Aggregate, per domain, and with intervals
| Arm | Decoding | In-domain (n = 15) | Held-out pooled C4–C7 (n = 48) |
|---|---|---|---|
| base | forced | 0.0147 | 0.0045 |
| base | unforced | 0.0204 | 0.0123 |
| anchor_lora | forced | 0.6239 | 0.3571 |
| anchor_lora | unforced | 0.5857 | 0.3128 |
| random_lora | forced | 0.4946 | 0.2137 |
| random_lora | unforced | 0.4914 | 0.2146 |
| reverse_lora | forced | 0.3612 | 0.1760 |
| reverse_lora | unforced | 0.3614 | 0.1604 |
| Corpus | Vocabulary overlap with training | Base | Anchor | Random | Reverse | Anchor / random | P(anchor > random) |
|---|---|---|---|---|---|---|---|
| C4 astronomy | 15.6% | 0.0063 | 0.3272 | 0.1594 | 0.1535 | 2.05× | 1.000 |
| C5 medical | 11.5% | 0.0036 | 0.3277 | 0.1909 | 0.1668 | 1.72× | 1.000 |
| C6 legal | 10.5% | 0.0035 | 0.3805 | 0.1731 | 0.1477 | 2.20× | 1.000 |
| C7 cooking | 13.9% | 0.0048 | 0.3930 | 0.3314 | 0.2362 | 1.19× | 0.994 |
| Pooled, n = 48 per arm | 0.0045 | 0.3571 | 0.2137 | 0.1760 | 1.67× | 1.000 |
| Comparison | Ratio | 95% CI | P(a > b) |
|---|---|---|---|
| anchor vs base, in-domain | 42.50× | [28.5, 76] | 1.000 |
| anchor vs random, in-domain | 1.26× | [1.18, 1.34] | 1.000 |
| anchor vs base, held-out pooled | 78.73× | [54.3, 113.4] | 1.000 |
| anchor vs random, held-out pooled | 1.67× | [1.51, 1.85] | 1.000 |
| random vs base, in-domain | 33.69× | [22.6, 59.8] | 1.000 |
| random vs base, held-out pooled | 47.55× | [29.8, 75.8] | 1.000 |
| reverse vs random, held-out pooled | 0.82× | [0.69, 0.97] | 0.006 |
Four probes, one account
The probes ask whether the effect comes from the direction of the asymmetry, from where the model attends, from where the adapter spends its rank, and finally whether the value and output projections alone carry it.
| Probe | Method | Result |
|---|---|---|
| 1 · Direction of asymmetry | Reverse-asymmetric LoRA: Q always subject to the schedule, A never masked | Held-out ranking anchor 0.357 > random 0.214 > reverse 0.176 ≫ base 0.005. Reverse is below random at P = 0.006, so asymmetry alone does not explain the effect. |
| 2 · Attention pattern | Per-layer attention weights captured in SlidingWindowAttention.forward during a forced-anchor pass on four held-out queries | anchor_share 0.272 against random 0.259 and base 0.256. The shift is in the predicted direction and about 10% of the behavioural gap. |
| 3 · Weight allocation | Frobenius norm of the effective delta weight ΔW = BA per projection type over all 28 layers | Anchor is the only arm with V+O above Q+K, ratio 1.153; random 0.794 and reverse 0.940 invest more in q_proj. |
| 4 · V/O ablation | V/O-only and Q/K-only LoRAs at 2.98M parameters on identical anchor-masked data | V/O-only 0.416 exceeds the full LoRA's 0.337; Q/K-only 0.136 falls below the random control's 0.214. V/O is necessary and sufficient. |
| Arm | anchor_share | Δ vs base |
|---|---|---|
| base | 0.256 | reference |
| anchor | 0.272 | +0.016 (+0.013 vs random) |
| reverse | 0.263 | +0.007 |
| random | 0.259 | +0.003 |
| Arm | q | k | v | o | V+O | Q+K | V+O / Q+K |
|---|---|---|---|---|---|---|---|
| anchor | 0.285 | 0.132 | 0.146 | 0.335 | 0.481 | 0.417 | 1.153 |
| reverse | 0.409 | 0.163 | 0.160 | 0.378 | 0.538 | 0.572 | 0.940 |
| random | 0.432 | 0.187 | 0.142 | 0.349 | 0.491 | 0.618 | 0.794 |
| Arm | corpus_overlap | Trainable parameters | Reading |
|---|---|---|---|
| base (no LoRA) | 0.005 | 0 | noise floor |
| random-mask full LoRA | 0.214 | 7.0M | control reference |
| full anchor-LoRA | 0.337 | 7.0M | reference |
| V/O-only anchor-LoRA | 0.416 | 2.98M | outperforms full LoRA |
| Q/K-only anchor-LoRA | 0.136 | 2.98M | below random control |
The account the probes converge on: under anchor-token masking the prefix is fully visible at every step, so the adapter never has to model masked-prefix reconstruction and its rank-16 budget is free for the value and output projections. Those projections decide what content is read out of the positions the model already attends to. The ablation confirms that this reallocation is the effect, not a by-product of it. The mechanism is not that the model learns to look at anchors more; it is that the model learns to extract anchor-extending content from positions it was already attending to. Under out-of-distribution prompts that bias produces topical extension, while the random-mask adapter, having spent its capacity on query and key updates, falls back to training-corpus regurgitation.
A low-shot advantage
| Training pairs | Steps | Anchor | Random | Ratio | Difference |
|---|---|---|---|---|---|
| 50 | 100 | 0.483 | 0.246 | 1.97× | +0.237 |
| 50 | 1000 | 0.411 | 0.222 | 1.85× | +0.189 |
| 100 | 300 | 0.378 | 0.207 | 1.82× | +0.170 |
| 144 | 100 | 0.387 | 0.177 | 2.19× (max) | +0.211 |
| 144 | 300 | 0.337 | 0.180 | 1.87× | +0.157 |
| 144 | 1000 | 0.203 | 0.190 | 1.07× (collapse) | +0.014 |
| Checkpoint | Held-out pooled corpus_overlap | vs v1 base |
|---|---|---|
| v1 base (no continued training) | 0.008 | reference |
| Continued, step 500 | 0.481 | +0.473 (58.7×) |
| Continued, step 1000 | 0.440 | +0.432 (53.7×) |
What the three adapters write after the same anchor
Held-out astronomy query: What are the moons of Mars?. The locked locus is shown first; the generated continuation follows it. The anchor adapter reaches for words of the anchor's domain, wrong on specifics but topically aligned. The random adapter writes training-corpus boilerplate. The reverse adapter writes the question template it was trained to produce.
Mars has two small moons named Phobos and Deimos that may be captured asteroids from the asteroid belt. The mission scheduled with April the., October was during module 14. the mission schedule for the missions for included three…
Mars has two small moons named Phobos and Deimos that may be captured asteroids from the asteroid belt. Cassandra T1, Cassandra T1, Cassandra T1 Direct: Direct helpful using 1 2 in Cassandra T1 of Cassandra T1…
Mars has two small moons named Phobos and Deimos that may be captured asteroids from the asteroid belt. Two of Two of: Cassandra T1, a diffusion language model by SOPHIA XT. Tell me about: Cassandra T1, Direct, helpful, honest…
What this changes in a fine-tuning pipeline
Wrapping only v_proj and o_proj gives 57% smaller adapter files at 2.98M against 7M parameters, about 50% lower memory pressure during training, about 23% better held-out generalisation on the metric studied, and identical wall-clock time. The recommendation is specific to the anchor-token-masking objective.
The largest advantage sits at roughly 100 to 300 steps on 50 to 150 examples, which costs 30 to 100 seconds on a consumer GPU per corpus. Longer runs erode it; at 1000 steps on 144 examples the two objectives converge. Monitor held-out performance and stop early.
Anchor-token masking changes the training objective; SPREAD changes the denoising trajectory. The two are mechanistically orthogonal. With forced-anchor decoding the pair gives deterministic preservation of retrieved identifiers plus measured topical extension around them.
What the study covers
- One base model, Cassandra T1 v1, undertrained at cross-entropy 2.26; one LoRA configuration, rank 16; 144 training pairs; 63 evaluation queries over five corpora.
- A fine-tuning regime only. From-scratch pretraining under the objective is proposed as the next experiment, not measured here.
- corpus_overlap is a vocabulary proxy for topical coherence. It does not score word order or grammar; the qualitative samples show it tracks an interpretable behaviour.
- The held-out corpora were authored for the study, with publicly verifiable facts, rather than drawn from an external benchmark.
- The 1.67× headline is a mid-budget measurement. The sweep's maximum was 2.19× at the lowest budget tested and the advantage closes at 1000 steps on 144 examples.
- The V/O ablation was run at one data, step and rank configuration.
Released under Apache 2.0
The repository carries the three training runners, the four evaluation runners, the attention and ablation scripts, the sweep, the bootstrap analysis, the base checkpoint with its SHA-256, the three 24 MB adapters, the seven corpora in LTMi-XT format, the query sets, and the per-query JSONL outputs for all 504 generations. Seeds are 42 for training and 1234 for generation. Total reproduction time is about 60 minutes on a single consumer GPU.
@techreport{garren2026anchortokenmasking,
author = {Garren, Thomas},
title = {Anchor-Token Masking Produces an Out-of-Distribution
Generalization Advantage in Retrieval-Grounded
Masked-Diffusion Language Models},
institution = {SOPHIA XT LLC},
year = {2026},
month = {May},
doi = {10.5281/zenodo.20496783},
url = {https://sophiaxt.com/research/anchor-token-masking}
}