Copying Under Repetition: From Prefix Matching to Position Hashing
Organizations: Northwestern University · Duke University∗ · Toyota Technological Institute at Chicago
Abstract
Frontier LLMs can copy random text almost flawlessly, yet they often overrun or truncate long blocks of repeated characters. In repeated strings, matching local content no longer reliably identifies where copying should continue or when it should stop. Nevertheless, we show that a two-layer transformer with -bit precision and width can copy every string up to a chosen design horizon and terminate correctly under arbitrary repetition. We use RoPE-style rotations of attention values and outputs (VO-rotations) with small prime periods to encode distances from delimiter anchors modulo those primes. By the Chinese Remainder Theorem, these periodic encodings jointly distinguish all required distances, allowing one retrieval rule to select either the next source token or the end marker. In contrast, we prove a width-independent impossibility result for copying under sequential finite-precision softmax accumulation. It applies to transformers whose only positional input is an additive attention bias that eventually becomes constant, including NoPE and a recursive implementation of ALiBi. Once an identical-token run exceeds the resulting saturation threshold, further repetitions leave the logits unchanged. If this threshold grows sublinearly with , these models cannot both complete a long all-identical copy and stop correctly, a pattern resembling the termination errors of frontier LLMs. In synthetic copying experiments, baseline transformer models fail on long repeated strings even within the training range. Trained VO models, by contrast, generalize beyond the training lengths with near-perfect accuracy up to length , the selected primes' period product.
Figures & tables
| Failure type | Target string (excerpt) | Model reply (excerpt) |
|---|---|---|
| Extended repetition | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb (Length: ) | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb (Length: 79,984 ) |
| Premature truncation | iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii (Length: ) | iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii (Length: 224 ) |
| Empty output | zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz (Length: ) | Empty response (Length: ) |
| Model | Layers | Width | |||
|---|---|---|---|---|---|
| NoPE | 6 | 512 | |||
| RoPE | 6 | 512 | |||
| ALiBi | 6 | 512 | |||
| Hard-ALiBi | 6 | 512 | |||
| Sinusoidal | 6 | 512 | |||
| VO-Rotation | 2 | 256 |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Model | Model ID | Reasoning/thinking |
|---|---|---|
| Qwen3.5 | qwen3.5:397b-cloud | thinking disabled |
| DeepSeek V4 Pro | deepseek-v4-pro | thinking disabled |
| Gemini 3.1 Pro | gemini-3.1-pro- preview | low thinking |
| Gemini 3.1 Pro | gemini-3.1-pro- preview | medium thinking |
| GPT-5.5 | gpt-5.5 | none |
| GPT-5.5 | gpt-5.5 | medium reasoning |
| Model | Layers | Width | Heads | Precision | Update budget |
|---|---|---|---|---|---|
| NoPE | 6 | 512 | 8 | bf16 | |
| RoPE | 6 | 512 | 8 | bf16 | |
| ALiBi | 6 | 512 | 8 | bf16 | |
| Hard-ALiBi | 6 | 512 | 8 | bf16 | |
| Sinusoidal | 6 | 512 | 8 | bf16 | |
| VO-Rotation | 2 | 256 | 4 | FP8 sim. |
| Model | Seed | Seed | Seed |
|---|---|---|---|
| NoPE | |||
| RoPE | |||
| ALiBi | |||
| Hard-ALiBi | |||
| Sinusoidal | |||
| VO-Rotation |
| Seed | Distribution | Mean | Minimum | |
|---|---|---|---|---|
| 42 | Uniform random | 0.9834 | 0.4375 | 0.9688 |
| 43 | Uniform random | 0.9591 | 0.4688 | 0.8854 |
| 44 | Uniform random | 0.9964 | 0.9583 | 1.0000 |
| 42 | 0.9993 | 0.9167 | 1.0000 | |
| 43 | 0.9896 | 0.7188 | 0.9896 | |
| 44 | 0.99997 | 0.9896 | 1.0000 |
Transformer
Transformers are neural architectures that use attention to model relationships among sequence elements in language, vision, and scientific data.
See all 528 papers