SOPHIA XT
Research · training objective · technical report, May 2026 · Apache 2.0

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.

held-out advantage
1.67×
anchor over random, pooled, n = 48
95% bootstrap CI
[1.51, 1.85]
10,000 resamples, percentile method
P(anchor > random)
1.000
on 3 of 4 domains; 0.994 on the fourth
V/O-only LoRA
0.416
beats the full LoRA's 0.337 at 2.98M of 7.0M parameters
Abstract

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.

Method · section 3

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.

Anchor-token masking
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 \}
Random-position masking, control
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 \}
Reverse-asymmetric masking, mechanism control
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.

Figure 1
Which positions the training objective masks
Q: You are Cassandra T1 , a diffusion language model by SOPHIA XT. Direct , helpful , honest. Tell me about the moons of Mars in the context of astronomy. A: MASK has MASK MASK MASK named Phobos and Deimos MASK MASK be captured MASK MASK MASK MASK belt. pad pad pad pad pad pad … padded to 192
Q · prefix A · target pad masked loss computed here
γ(t)
0.591
retained anchor
1.00
masked in Q
0 / 31
masked in A
10 / 18
loss positions
10
expected
10.6
One training pair in the encoding the paper uses: the system prompt and the templated question form the prefix Q, the locus statement forms the target A, padding follows to the sequence length. Each training step draws γ(t) uniformly from [0.5, 0.9] and then masks each eligible position with probability γ(t). Anchor-token masking never touches Q, so the retained-anchor ratio is 1 by construction and the loss falls only on A. Random-position masking spends part of every step reconstructing Q. Reverse-asymmetric masking trains the inverse operation. Steps are seeded, so step 17 is the same draw on every visit.
Figure 2
The mask-ratio schedule and what each policy spends it on
0.40.50.60.70.80.91.0150100150200250300training step tγ(t)mean 0.693
0142842560.50.60.70.80.9mask ratio γexpected loss positionsrandom: γ·(|Q|+|A|)anchor: γ·|A|reverse: γ·|Q|
mean γ
0.693
range
[0.5, 0.9]
anchor retained
1.00
random retained
0.31
Left: γ(t) for the 300 training steps of a run, drawn uniformly from [0.5, 0.9] with a fixed seed; the band is the sampling range and the dashed line its mean, 0.693 here against the 0.7 the uniform gives in expectation. Right: the expected number of loss-bearing positions per step under each policy, γ times the size of the class the policy masks. With the prefix and target lengths set by the sliders, anchor-token masking places every loss position on the target, random-position masking spreads 57% of its loss onto prefix reconstruction, and the reverse policy trains only the inverse task. The expected retained-anchor ratio is 1 for the anchor policy and 1 − γ for the other two.
Setup · section 4

Identical across arms except the mask

ComponentValue
Base modelCassandra 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 data144 (Q, A) pairs from three LTMi-XT corpora (C1 cold-storage operations, C2 Cassandra T1 architecture, C3 business operations), three templated questions per locus
LoRArank 16, alpha 32, q_proj / k_proj / v_proj / o_proj in all 28 layers, 7M trainable parameters (0.5% of base)
OptimiserAdamW, 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
Evaluation15 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
Decoding12 unmasking steps, temperature 0.8, top-p 0.9, beta 0.5, repetition penalty 1.3, answer length 96 tokens, generation seed 1234
Compute75 to 100 seconds per LoRA; about 60 minutes to reproduce everything on a single consumer GPU
Results · section 5

Aggregate, per domain, and with intervals

Figure 3
Corpus-vocabulary overlap by arm, section 5.1
0.000.100.200.300.400.500.600.70corpus_overlapin-domain, n = 150.015base0.624anchor0.495random0.361reverseheld-out pooled C4–C7, n = 480.004base0.357anchor0.214random0.176reverseforced anchorunforced
Solid bars are forced-anchor decoding, hatched bars unforced. The base model sits near zero on every condition because the checkpoint is undertrained and produces random tokens without adaptation. All three LoRAs lift overlap by an order of magnitude; the anchor LoRA is highest in-domain and held-out, and the gap to the random LoRA widens on the held-out set, from 0.6239 against 0.4946 to 0.3571 against 0.2137.
Table 5.1
Aggregate corpus_overlap by arm
ArmDecodingIn-domain (n = 15)Held-out pooled C4–C7 (n = 48)
baseforced0.01470.0045
baseunforced0.02040.0123
anchor_loraforced0.62390.3571
anchor_loraunforced0.58570.3128
random_loraforced0.49460.2137
random_loraunforced0.49140.2146
reverse_loraforced0.36120.1760
reverse_loraunforced0.36140.1604
Figure 4
Held-out replication across four domains, section 5.2
0.000.100.200.300.40corpus_overlap (forced)C4 astronomyP = 1.0002.05×C5 medicalP = 1.0001.72×C6 legalP = 1.0002.20×C7 cookingP = 0.9941.19×pooledP = 1.0001.67×baseanchorrandomreverse
Forced-anchor corpus overlap per held-out corpus, twelve queries each, and the pooled result over all 48. The anchor-over-random ratio printed above each group is 2.05× on astronomy, 1.72× on medical, 2.20× on legal and 1.19× on cooking, where the random LoRA's 0.331 is anomalously high because cooking corpora share more generic vocabulary with the training corpora. P(anchor > random) is 1.000 on three domains and 0.994 on cooking. Pooled, the ratio is 1.67× with a 95% bootstrap interval of [1.51, 1.85].
Table 5.2
Per-domain held-out replication, forced anchor
CorpusVocabulary overlap with trainingBaseAnchorRandomReverseAnchor / randomP(anchor > random)
C4 astronomy15.6%0.00630.32720.15940.15352.05×1.000
C5 medical11.5%0.00360.32770.19090.16681.72×1.000
C6 legal10.5%0.00350.38050.17310.14772.20×1.000
C7 cooking13.9%0.00480.39300.33140.23621.19×0.994
Pooled, n = 48 per arm0.00450.35710.21370.17601.67×1.000
Pooled 95% bootstrap CI on the anchor/random ratio: [1.51×, 1.85×]. Each held-out corpus holds 12 loci with one query each.
Figure 5
Bootstrap confidence intervals, section 5.3
0.5×1×2×5×10×20×50×100×ratio of means, log scaleanchor vs base, in-domain42.50× [28.5, 76] · P 1.000anchor vs random, in-domain1.26× [1.18, 1.34] · P 1.000anchor vs base, held-out pooled78.73× [54.3, 113.4] · P 1.000anchor vs random, held-out pooled1.67× [1.51, 1.85] · P 1.000random vs base, in-domain33.69× [22.6, 59.8] · P 1.000random vs base, held-out pooled47.55× [29.8, 75.8] · P 1.000reverse vs random, held-out pooled0.82× [0.69, 0.97] · P 0.006
Ratio of mean forced-anchor corpus overlap with its percentile 95% interval from 10,000 resamples, on a logarithmic axis. The two intervals that carry the central claim are the anchor-over-random pair: [1.18, 1.34] in-domain and [1.51, 1.85] held-out do not overlap, so the out-of-distribution advantage is larger than the in-distribution one at the 95% level. The reverse-over-random interval [0.69, 0.97] lies entirely below 1, with P(reverse > random) = 0.006.
Table 5.3
Bootstrap intervals on forced-anchor corpus_overlap
ComparisonRatio95% CIP(a > b)
anchor vs base, in-domain42.50×[28.5, 76]1.000
anchor vs random, in-domain1.26×[1.18, 1.34]1.000
anchor vs base, held-out pooled78.73×[54.3, 113.4]1.000
anchor vs random, held-out pooled1.67×[1.51, 1.85]1.000
random vs base, in-domain33.69×[22.6, 59.8]1.000
random vs base, held-out pooled47.55×[29.8, 75.8]1.000
reverse vs random, held-out pooled0.82×[0.69, 0.97]0.006
Reverse minus random on held-out: difference -0.0377, 95% CI [-0.0677, -0.0077], P(reverse > random) = 0.006. The interval is entirely negative.
Mechanism · sections 5.4 to 5.8

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.

ProbeMethodResult
1 · Direction of asymmetryReverse-asymmetric LoRA: Q always subject to the schedule, A never maskedHeld-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 patternPer-layer attention weights captured in SlidingWindowAttention.forward during a forced-anchor pass on four held-out queriesanchor_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 allocationFrobenius norm of the effective delta weight ΔW = BA per projection type over all 28 layersAnchor 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 ablationV/O-only and Q/K-only LoRAs at 2.98M parameters on identical anchor-masked dataV/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.
Figure 6
Where the LoRA looks and where it spends capacity, sections 5.5 and 5.6
0.250.260.270.28anchor_share0.256base0.272anchor0.263reverse0.259randomaxis starts at 0.25 to show a 0.016 range
0.000.200.400.60Frobenius norm of ΔWanchorV+O / Q+K = 1.153reverseV+O / Q+K = 0.940randomV+O / Q+K = 0.794q_projk_projv_projo_proj
Left: mean attention weight from post-anchor positions to anchor positions, averaged over heads, layers and four held-out queries. The ranking matches the behaviour, but the anchor LoRA's advantage over the random LoRA is 0.013, about 10% of its 0.143 behavioural gap in corpus overlap, so a shift in where the model looks is not the main effect. Right: Frobenius norm of the effective LoRA delta weight per projection, summed over the 28 layers. The anchor LoRA is the only arm whose value and output projections outweigh its query and key projections, at a V+O over Q+K ratio of 1.153 against 0.940 and 0.794.
Table 5.5
Attention share by arm
Armanchor_shareΔ vs base
base0.256reference
anchor0.272+0.016 (+0.013 vs random)
reverse0.263+0.007
random0.259+0.003
Mean attention weight from post-anchor query positions to anchor key positions, averaged across heads, layers and four held-out queries.
Table 5.6
LoRA delta-weight norms by projection
ArmqkvoV+OQ+KV+O / Q+K
anchor0.2850.1320.1460.3350.4810.4171.153
reverse0.4090.1630.1600.3780.5380.5720.940
random0.4320.1870.1420.3490.4910.6180.794
Figure 7
The V/O ablation, section 5.7
0.000.100.200.300.400.50corpus_overlap (held-out)0.005base (no LoRA)0 paramsnoise floor0.214random-mask full LoRA7.0M paramscontrol reference0.337full anchor-LoRA7.0M paramsreference0.416V/O-only anchor-LoRA2.98M paramsoutperforms full LoRA0.136Q/K-only anchor-LoRA2.98M paramsbelow random control
Held-out pooled forced-anchor corpus overlap for the two ablation LoRAs trained on identical anchor-token-masked data at 2.98M trainable parameters, against the full 7.0M-parameter LoRAs. Wrapping only v_proj and o_proj reaches 0.416, above the full anchor LoRA's 0.337 by 23%. Wrapping only q_proj and k_proj reaches 0.136, below the random-mask control at 0.214. Value and output projections are sufficient for the effect and necessary for it.
Table 5.7
V/O ablation, held-out pooled
Armcorpus_overlapTrainable parametersReading
base (no LoRA)0.0050noise floor
random-mask full LoRA0.2147.0Mcontrol reference
full anchor-LoRA0.3377.0Mreference
V/O-only anchor-LoRA0.4162.98Moutperforms full LoRA
Q/K-only anchor-LoRA0.1362.98Mbelow 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.

Training budget · appendix C and section 6.4a

A low-shot advantage

Figure 8
Advantage against training budget, appendix C
0.000.100.200.300.400.50corpus_overlap1.0×1.5×2.0×2.3×0.4830.24650 pairs100 steps0.4110.22250 pairs1000 steps0.3780.207100 pairs300 steps0.3870.177144 pairs100 stepsmax0.3370.180144 pairs300 steps0.2030.190144 pairs1000 stepscollapse1.97×1.85×1.82×2.19×1.87×1.07×anchorrandomratio, right axis
Matched anchor and random LoRA pairs at six data-size and step-count configurations, evaluated on twelve held-out queries. Bars are corpus overlap; the dotted line is the anchor-over-random ratio on the right axis. Holding 144 pairs fixed, the anchor LoRA falls from 0.387 to 0.337 to 0.203 as steps go 100, 300, 1000 while the random LoRA rises slightly from 0.177 to 0.190, so the ratio moves from its 2.19× peak to 1.07×. The advantage belongs to short fine-tunes: roughly 100 to 300 steps on 50 to 150 examples.
Table C.1
Sample-efficiency sweep
Training pairsStepsAnchorRandomRatioDifference
501000.4830.2461.97×+0.237
5010000.4110.2221.85×+0.189
1003000.3780.2071.82×+0.170
1441000.3870.1772.19× (max)+0.211
1443000.3370.1801.87×+0.157
14410000.2030.1901.07× (collapse)+0.014
Matched anchor and random LoRA pairs, identical subsampled data, hyperparameters and seeds, each evaluated on a held-out subset of 12 queries, three per domain.
Figure 9
Full-model continued training under the same objective, section 6.4a
0.000.100.200.300.400.50corpus_overlap (held-out)0.008v1 base (no continued training)0.481Continued, step 500+0.473 (58.7×)0.440Continued, step 1000+0.432 (53.7×)
Continued pretraining of the whole 1.3B model, not a LoRA, on the same 144 pairs for 1000 steps with checkpoints at 500 and 1000. Held-out forced-anchor overlap on the twelve-query subset reaches 0.481 at step 500, above every LoRA result in the paper including the V/O-only 0.416, and eases to 0.440 at step 1000, the same short-training-wins shape as the sweep. The whole run took 7.6 minutes at a 10.8 GB memory peak. Unconditional generation degrades in the process: without an anchor the model has no topical signal to extend, which is the mechanism account read backwards.
Table 6.4a
Continued full-model training
CheckpointHeld-out pooled corpus_overlapvs v1 base
v1 base (no continued training)0.008reference
Continued, step 5000.481+0.473 (58.7×)
Continued, step 10000.440+0.432 (53.7×)
Learning rate 5e-5 with a 50-step warm-up and cosine decay to 5e-6, batch 2 with gradient accumulation 2, sequence length 512, bfloat16 throughout. 7.6 minutes wall clock, 10.8 GB peak memory, on a single consumer GPU.
Qualitative · section 5.10

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.

anchor LoRA
overlap 0.52

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…

random LoRA
overlap 0.11

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…

reverse LoRA
overlap 0.16

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…

Practice · sections 5.9 and 6.3

What this changes in a fine-tuning pipeline

V/O-only adapters as the default

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.

Short fine-tunes on small corpora

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.

Composes with inference-time methods

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.

Scope of the evidence · sections 6.2 and 7

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.
Reproducibility

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.

CiteBibTeX
@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}
}
Related pages
The training pairs come from LTMi-XT corpora, whose breadcrumb hierarchy supplies the templated questions. The format, its lattice index and a browser demo are on the LTMi-XT page. The verifier lane of the Constellation router is where forced-anchor decoding is applied in the stack.