Manuscript Offprint

arXiv:2609.07314

Content-Based Addressing for Long Context

Mahesh Godavarti

Abstract

Rotary position embedding (RoPE) uses each token's integer position to determine the rotation applied inside attention. This works well for local token order, but increasing context length creates a positional train-test mismatch: RoPE produces relative rotations at offsets not seen during training. Methods that rescale, interpolate, randomize, or bias positions specify how attention handles those offsets, but still derive positional information from a growing token counter. We instead divide a token stream into units, retain ordinary RoPE positions within each unit, and assign every completed unit an address computed from its content. Adding units then applies the same learned map to new content rather than extending a positional range or an identifier table. We prove that this construction preserves local RoPE exactly, leaves the attention comparison between two fixed tokens unchanged when other units are inserted or reordered, and does not create new relative rotations merely because more units are added. In a character-level Tiny Shakespeare diagnostic, a model trained on 256-character contexts has validation perplexity 4.04 at 256 characters and 3.82 at 4096, while continuous RoPE changes from 4.71 to 12.09. A second diagnostic shows that content-based addressing can retrieve and use information from multiple serialized facts. These are controlled shallow experiments, not scale benchmarks, but they support a direct prescription: use position to address locally and content to address across units.

Keywords: long context, content-based addressing, positional encoding, rotary position embedding, distribution shift, attention

1 Introduction

Long-context Transformers usually assign every token one global position. At evaluation lengths beyond those used in training, this creates a positional train-test mismatch. RoPE turns a position difference into a relative rotation (Su et al., 2021). Attention with Linear Biases (ALiBi) downweights tokens according to distance (Press et al., 2022). Position interpolation and YaRN rescale RoPE coordinates or frequencies (Chen et al., 2023; Peng et al., 2023). Randomized positions expose training to a broader offset distribution (Ruoss et al., 2023). These methods can improve behavior beyond the training length, but they still derive each token's rotation from its location in one serialized sequence.

We separate two jobs that global position currently performs. Within a local text unit, position is the correct address: characters and tokens have an order, and nearby offsets recur across examples. Across completed units, the unit's integer position in the serialized sequence need not determine its attention rotation. Using that position makes the rotation between two fixed units depend on how many unrelated tokens were serialized between them. It also creates new relative rotations solely because more units were placed in context.

We propose content-based addressing. Each token has a bounded position within a unit, such as a line, sentence, paragraph, chunk, or record. Each completed unit receives an address ReR_e, an

Preprint.

orthogonal matrix computed by a shared neural map from its content. Attention combines the local position and unit address in the same query/key rotation used by RoPE. The resulting token address is A(i,e)=ReRiA(i,e) = R_e R_i: RiR_i captures local order within the unit, and ReR_e is the content-based address of unit ee. There is no global distance penalty or global unit counter. The causal mask still determines which units are available, while the attention score determines which available content is relevant.

The paper makes three contributions. First, it gives a small modification of rotary attention that computes unit addresses from content and can be added to an existing RoPE model. Second, Theorem 1 proves that adding units does not create new relative rotations solely because the context is longer. Third, two controlled diagnostics test complementary properties: stable language-model behavior as more text units are added, and retrieval from content-addressed units when the prediction depends on one of several serialized facts.

Content-based addressing prevents context growth from creating relative rotations unseen during training. It does not reduce attention cost or softmax competition, and the shared content map must still generalize to new unit contents.

References (14)