Retokenization Reveals the Gap Between Semantics and Behavior

Sami Wolf, Sergei Kudriashov, Dmitry VaintrobarXiv 2026

TL;DR

Large language models read text as chunks called tokens, and while they normally see only one "canonical" chunking per string, slicing the exact same harmful text into non-standard tokens can trick a safety-aligned model into complying. This paper uncovers why this happens inside the model's activations and introduces a self-distillation "consistency training" method that teaches models to behave identically regardless of how an input prompt is sliced—slashing attack success rates by an order of magnitude without teaching the model to output gibberish.

What Problem Does This Paper Address?

When you type "Hotwire a car", a deterministic tokenizer converts those bytes into a single, standard sequence of subword tokens (say, Hot wire _a _car). Yet every byte string admits exponentially many valid, non-canonical tokenizations (like H ot w ire _a _c ar) that decode back to the exact same text.

Surprisingly, LLMs understand fragmented text reasonably well, even though they never see it during standard training. However, understanding a prompt isn't the same as behaving consistently on it. Recent work showed that adversarial tokenization (AdvTok) can bypass safety guardrails without changing a single byte of the underlying text. Unlike classic jailbreaks that append weird suffixes or role-play scenarios, retokenization keeps the semantic ground truth untouched while shifting the surface form out-of-distribution. This creates a clean mathematical laboratory to ask: why does safety alignment decouple from meaning, and how do we bolt them back together?

Figure 1: An illustration of a gap between tokenization and semantics. Inputs to an LLM are pairs (x, t) with Pθ(x, t) = Pθ(x) Pθ(t | x), where Pθ(t | x) concentrates on the canonical tokenization τ(x). Most attacks are semantic, so they move x off the support of Pθ(x) while t = τ(x) remains canonical. Contrary to that, adversarial tokenization (Geh et al., 2025) keeps x in-distribution and moves t off the support of Pθ(t | x).

Methods

Prior attempts at stochastic tokenization usually scramble both the prompt and the target response during training. Here, the authors prove mathematically that retokenizing the target response inflates the minimum attainable loss by adding the tokenizer's entropy—forcing the model to emit non-canonical tokens at generation time. Retokenizing only the prompt, however, is a strict label-preserving augmentation that leaves the theoretical training optimum unchanged.

Building on this, the authors introduce unsupervised consistency training (a form of self-distillation requiring no external safety labels):

  • Frozen Reference vs. Student: A frozen copy of the model reads the canonically tokenized prompt, while the student model reads deeply retokenized versions sampled uniformly from a multi-valued decision diagram (MDD).
  • Two Supervision Sites: They test output-based consistency (matching next-token probability distributions via KL divergence or cross-entropy along a generated continuation) and representation-based consistency (aligning internal residual-stream vectors, such as repr-next, which matches activations across all layers at just the final prompt token).
  • CVaR Filtering: To save compute, they sample 8 retokenizations per prompt, rank their losses without gradients, and backpropagate only the worst-performing subset (empirical Conditional Value at Risk) alongside the canonical prompt.

Datasets

No new benchmarks are introduced; the authors combine established safety and capability suites:

  • Training: A mix of benign instructions from Alpaca and 320 harmful requests from AdvBench.
  • Safety & Over-refusal Evaluation: 200 held-out AdvBench prompts, 200 out-of-distribution WildJailbreak prompts, and 250 safe prompts from XSTest (plus held-out Alpaca) to check for false refusals.
  • Capabilities: GSM8K, MMLU, and IFEval across OLMo-2-7B-Instruct, Llama-3.2-3B-Instruct, and Gemma-3-4B-it.

Key Insights and Ideas

  • Refusal is suppressed, not broken: Using linear probes on the residual stream, the authors show that adversarial tokenizations leave the model's grasp of the prompt's topic intact (above chance, matching random splits of the same depth), but selectively crush the linearly decodable refusal signal. Adding the refusal vector back in mid-generation restores refusal 78.7% of the time—proving the downstream refusal machinery works fine, the attack just fails to trigger it.
  • Freezing the subspace: After consistency training, a frozen linear probe trained only on the original base model still detects harmfulness on attacked prompts with up to 98.4% accuracy. Consistency training keeps the refusal signal anchored in its original geometric subspace.
  • Token diversity cannot replace semantic diversity: Can you make up for a small dataset just by slicing each prompt ten different ways? For output-based KL training, no—shrinking distinct prompts hurts generalization and math accuracy, even if total token sequences stay constant. Intriguingly, representation matching is far less sensitive to prompt count.
  • Benign data isn't enough: Training on benign prompts alone pulls internal representations of retokenized harmful prompts 75% closer to their canonical versions, yet barely dents attack success. Brittle safety features need actual harmful examples in the training mix to become robust.

Key Results

On OLMo-2-7B-Instruct, greedy AdvTok attack success drops by an order of magnitude across all consistency variants—falling from 0.400 on the base model to 0.020 with KL consistency and 0.038 with repr-next. Unlike supervised fine-tuning on perturbed contexts (which spikes false refusals on safe XSTest prompts from 0.065 to 0.235 and degrades IFEval scores), consistency training keeps false refusals right near baseline (0.064–0.068).

Table 1: Training on retokenized prompts lowers AdvTok success on OLMo-2-7B under every objective. The consistency objectives keep refusal of safe prompts near the untrained level. AdvTok columns give attack success on 200 held-out AdvBench prompts at greedy (T=0) and sampled (T=1) decoding, and the last column gives refusal on the 250 safe XSTest prompts. Values are means over training seeds (three for Consistency, KL and repr-next, one otherwise) ± half the width of a 95% bootstrap interval over prompts.

Furthermore, robustness transfers zero-shot to character-level spelling noise: 8 random character substitutions push the base model's unsafe compliance rate from 0.000 to 0.195, whereas KL and repr-next models stay at or below 0.010. Meanwhile, full-sequence stochastic tokenization (StochasTok at high noise) matches AdvTok defense but causes 42% of generated tokens to be non-canonical; prompt-only consistency keeps that under 0.1%.

Limitations and Future Work

Consistency training is not a free lunch:

  • Ingredients matter: Defending against AdvTok requires deep token splits (shallow BPE-dropout-style splits leave attack success high at 0.165) and requires harmful prompts in the training mixture.
  • Trade-offs in transfer and capabilities: Only all-layer, last-position representation matching (repr-next) consistently transfers defense to suffix-based jailbreaks (BEAST) across all three model families—but it also suffers the steepest benchmark accuracy drops on smaller models, and results against character-level adversarial search (Charmer) remain mixed.
  • Over-refusal variance: False-refusal rates can vary by 2–3x across random training seeds, and on Llama-3.2-3B, every fine-tuned variant exhibited elevated XSTest refusals compared to the base model. Future directions are not explicitly outlined beyond these empirical boundaries.

Summary updated

BibTeX
@misc{wolf2026retokenization,
  author = {Sami Wolf and Sergei Kudriashov and Dmitry Vaintrob},
  title = {{Retokenization Reveals the Gap Between Semantics and Behavior}},
  year = {2026},
  eprint = {2611.39274},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.39274},
}
Figure