| Scores and positions | |
|---|---|
| query position and key position, | |
| distance from the query back to the key, in tokens | |
| residual stream entering the layer at position | |
| a head's query and key maps | |
| query and key | |
| head dimension, 128 in Inkling 2 Mini | |
| score of key from query , the input to the softmax | |
| attention weight, | |
| position term added to the score at distance , in logits | |
| value at and the head's output at | |
| Position schemes | |
| token embedding and absolute position vector at | |
| , the head's bilinear form | |
| Shaw et al.'s learned key offset for distance , and the clip distance | |
| T5's learned scalar for the bucket of , one per head | |
| an ALiBi head's slope, and the number of heads | |
| rotation of the plane by the given angle | |
| RoPE frequency of coordinate pair , | |
| pair of the query and the key | |
| angle from to | |
| a distance at which all of RoPE's cosines can peak together | |
| FIRE's MLP, log transform , its scale and threshold | |
| Canon layer weight vector for the predecessor at offset | |
| Inkling's bias | |
| one head's projection and its 16 learned scales | |
| the query's 16 weights in one head, before and after the cap | |
| the 16 shared profiles at distance | |
| sink logit, an extra score with a zero value | |
| share of attention on the sink | |
| Readout | |
| a query token; is its bias in one head of layer 0 | |
| bias-only attention, the softmax of over | |
| median distance of | |
| a constant added to the whole bias | |
| Paper symbols | |
| Su et al. write and for the positions and | |
| Shaw et al. write for | |
| Li et al. write for and for | |
| Allen-Zhu writes for the position | |
Context. An attention head scores each earlier key by its content, and nothing in that score says where the key sits. Language models supply position explicitly. That choice sets which order patterns a head can express with few parameters, and how the model behaves past its training length. Inkling 2 Minian open-weights looped mixture-of-experts language model released by Thinking Machines Lab in 2026. Reading note: Inkling 2 Mini lets each query token pick its own position term. In layer 0 that term depends on the token alone, so the released weights give it for the whole vocabulary.
Position bias as a prior over distance. Most schemes add a position bias the position term added to the score of a key at distance , in logits to the content score, where the distance in tokens from the query position back to the key position ; is the query's own token is the distance back to the key. The softmax input is for query a head's query vector at the query position , , with the residual stream entering the layer at and the head's query map and key the head's key vector at a key position , , with the head's key map of width the head dimension, the width of and . Exponentiating turns the sum into a product, so the attention weight the share of query 's attention on key , ; the weights over sum to 1 is a distance prior reweighted by content:ALiBiattention with linear biases: no position parameters; each head subtracts a fixed slope times the distance from every score (Press et al., 2021) fixes to a line, T5the text-to-text transformer of Raffel et al., 2020, whose position term is one learned scalar per head for each of 32 distance buckets, shared by all layers learns a bucket table per head, and Inkling lets each query choose a profile. RoPErotary position embedding: each pair of query and key coordinates is rotated by an angle proportional to the token's position (Su et al., 2021) adds no separate term and instead makes the content score depend on distance.
When is known, its softmax gives the head's distance prior. That prior is the attention each distance gets when every key has the same content score. In Inkling's layer 0, six heads look one or two tokens back for nearly every token, five look hundreds of tokens back, and five change reach with the query token. On text, the bias raises layer-0 attention within 8 tokens from 1% to 28%.
Without position, attention sees a set; the causal mask leaks order. Drop both the position signal and the mask, and a head outputs the head's output at position , the attention-weighted average of the value vectors the head computes at each position, the weighted sum over value vectors with . That sum treats the keys and values as an unordered set. Permuting the input tokens permutes the outputs the same way, and tokenwise MLPs keep that symmetry, so "dog" gets the same representation in "dog bites man" and "man bites dog". A causal mask breaks the symmetry because position averages exactly values. Set the query map so all scores tie, and give a fixed start token a value with first coordinate 1 while every other token has 0 there. ThenThe output encodes , and a later MLP can read it off.
Language models exploit this leak in practice. Haviv et al. (2022) trained 1.3B-parameter decoders without position signals to 13.10 perplexity on the Pile, against 13.05 with learned absolute embeddings. By the middle layers, probes read absolute position from those hidden states about as well as from the learned-embedding model. Masked language models have no causal mask and failed to train without position, stuck at perplexity 147 against about 4. Kazemnejad et al. (2023) proved that a first layer using the construction recovers absolute position, and that later layers can build relative attention on top of it. In their reasoning and arithmetic tests on about 107M-parameter decoders, NoPEno positional encoding: a decoder with no explicit position signal, which gets order only from the causal mask; the term is Kazemnejad et al., 2023's, and Haviv et al., 2022 write NoPos extrapolated better than sinusoidal embeddingsfixed position vectors added to the token embeddings, and for model width , chosen because is a linear function of for each fixed (Vaswani et al., 2017), ALiBi, and RoPE. Its attention patterns were closest to T5's relative bias.
Absolute embeddings make the score depend on both positions. The original transformer adds a position vector to each token embedding before layer 0. That vector is either learned per position or fixed to the sinusoids of Vaswani et al. (2017). Writing the head's bilinear form, so that , the layer-0 score splits into four terms:Only the first term is pure content. The middle two let tokens favor specific absolute indices. The last depends on and separately, so a previous-token head must make large at every . Learned embeddings stop at the training length. Sinusoids remain defined past it, yet Press et al. (2021) found that sinusoidal language models failed to extrapolate more than a few dozen tokens beyond training length.
Relative terms tie the score to distance alone. When the position term depends only on , absolute indices drop out of the score. Shaw et al. (2018) introduce relative position representationsa learned vector added to the key for each clipped distance, so that the score of key from query depends on the positions only through (Shaw et al., 2018), adding a learned vector to each key up to a clip distance :Distances past (16 in their base model) share one vector, and the cross-term gives each query its own distance profile. T5 (Raffel et al., 2020) drops that query dependence and stores one learned scalar per head in 32 distance buckets, . In its decoder, buckets cover single distances up to 15 and then widen logarithmically, with every distance from 113 on sharing the last bucket. Each head gets one fixed distance profile, and a single layer cannot separate distances past 113. Because unseen distances land in that last bucket, the bias stays defined on longer inputs. Press et al. found T5-bias models still improving 600 to 800 tokens past training length, though at twice the training time of sinusoidal models or more.
ALiBi fixes each head's profile to a line. ALiBi (Press et al., 2021) keeps T5's length stability without learned tables or extra runtime cost by subtracting a linear penalty . Each head gets a fixed slope before training, forming a geometric sequence across heads:Each head's distance prior is geometric, , with mean distance about . That reach runs from one or two tokens in the steepest head to about 256 in the flattest. Tested on 2,048 tokens, a 1.3B-parameter ALiBi model trained on 1,024 tokens matched the perplexity of a sinusoidal model trained on 2,048 while training 11% faster. Past training length, ALiBi's perplexity stays stable while the sinusoidal model's explodes. Under standard nonoverlapping evaluation, ALiBi's perplexity even improves on longer windows. Press et al. trace that gain to the early token cursethe higher perplexity of predictions made early in each evaluation window, which see little context. Longer windows contain a smaller share of early low-context predictions. Under sliding-window evaluation, where every prediction already has long context, ALiBi's perplexity stays flat as inputs grow, so it may not use history past its training length.
RoPE turns the content score itself into a function of distance. RoPE (Su et al., 2021) builds position directly into the dot product with no additive bias. It splits each query and key into coordinate pairs and . Pair rotates by at the query and at the key, with frequencies , the rotation frequency of pair , from 1 radian per token down to about running from fast to slow. Writing for plane rotation, transposing negates the angle and rotations add, so pair contributeswhere is the angle from to . Positions enter only through , so RoPE is relative. The score becomes a sum of cosines in whose amplitudes and phases come from content. When contents set in every pair, all cosines peak together at . In slow pairs, stays small across the context, so those coordinates match on content regardless of distance. Past training length, Press et al. found rotary models improving for only 100 to 200 tokens. In Kazemnejad et al.'s 1B-parameter code models, RoPE's perplexity exploded beyond training length.
FIRE learns the profile on a normalized distance. Fixed-window biases flatten past their last bucket, and unnormalized schemes meet unseen angles or distances on longer inputs. FIREfunctional interpolation for relative positions: a bias given by a small MLP of the distance divided by the query position, both log-transformed (Li et al., 2023) (Li et al., 2023) passes a log-normalized distance into a small MLP with one output per head:Here is a learned scale and is a learned threshold. The input always stays in , so longer sequences sample the same function more finely while the log stretches nearby distances. Li et al. prove this form can represent both T5 and ALiBi biases. A 125M-parameter FIRE model trained on 2,048 tokens reached 21.24 perplexity on C4 when tested zero-shot on 8,192 tokens, against 23.52 for the best other scheme.
Canon layers supply local order outside attention. Short-range order need not sit inside attention scores. Canon layersa causal convolution of width 4 with learned per-coordinate weights and a residual connection, inserted before attention, after the query, key and value projections, before the MLP or inside it (Allen-Zhu, 2025) (Allen-Zhu, 2025) add a width-4 causal convolution over each position and its three predecessors:with learned per-coordinate weights . With Canon layers, NoPE often matched or beat RoPE on Allen-Zhu's synthetic tasks. At 1.3B parameters trained on 100B tokens, NoPE with Canon layers matched RoPE.
Inkling 2 Mini lets each query choose its own distance profile. Citing Shaw et al., Inkling keeps query-dependent profiles cheap by giving each query 16 weights over a bank of 16 profiles shared across the layer's heads. In one head, the query's weights and score at distance areHere a matrix, the head's rows of the projection that sets the 16 weights, with the model width; the code's wr_du is the head's projection, a vector of 16 learned scales, one per weight, separate for each head holds its 16 learned scales, , which shrinks a vector longer than 8 to length 8 and leaves shorter ones unchanged caps the vector norm at 8, and the 16 learned profiles' values at distance , one column of a bank shared by the heads of the layer holds the 16 shared profiles at distance . Beyond 1,024 tokens the bias is zero. Because changes with the query, one token can look a token back while another in the same head looks hundreds back. Thinking Machines report that this relative embedding performs better and extrapolates better to longer sequences than RoPE in Inkling.
Inkling also mixes local order into keys and values with a width-4 causal convolution like Canon layers. In sliding-window layers, including layer 0, each key becomes itself plus a learned weighted sum of keys at , divided by . In global layers those convolution weights also depend on the input. In layer 0, is the normalized embedding of the token at , so and its profile depend on that token alone and can be computed oncefrom the weights alone, with no forward pass; how to find and check such readouts in a released model. Reading note: Reading a model's weights for all 200,058 vocabulary tokens.
The softmax of the bias isolates a head's distance prior. When a head's profile depends only on query token , as in Inkling's layer 0, write for its bias. Its bias-only attentionthe softmax over distances of one head's bias for a query token , for ; the attention the head would give if every key in a full window had the same content score isthe distance prior before any key's content enters the score. Its median distance the smallest with , the distance within which half of the bias-only attention lies tracks reach better than the peak . A steep profile and a flat one can share a peak while differing by hundreds of tokens in reach. In head 19 of Inkling's layer 0, "the" and "model" (each with a leading space) both peak at , yet their medians are 1 and 199 tokens. The head-medianthe median over a layer's 24 heads of each head's median distance for the token summarizes a token's reach across all 24 heads in one number.
Sorting layer-0 heads by across tokens separates them into three classes. A head with a median of one or two tokens for nearly every token is a previous-token heada head that attends from each position to the one before it and copies information about that token into the current position; with an induction head it forms the circuit for completing [A][B] … [A] with [B] (Olsson et al., 2022), the component Olsson et al. (2022) found feeding induction heads. In Inkling, the key convolution already folds keys through into key , doing part of that job without a head. A head whose median stays in the hundreds for nearly every token is broad. A head whose median ranges from a few tokens to hundreds depending on the token is token-dependent.
Four checks govern how to read a profile, starting with the attention sink. Xiao et al. (2023) found that because softmax weights must sum to 1, language models dump unneeded mass onto the first tokens, forming an attention sinka token that receives a large share of attention regardless of its content, typically the first token, because the softmax weights must sum to 1 (Xiao et al., 2023). One fix they test adds a fixed zero logit paired with a zero value vector. Inkling instead gives each head a learned, query-dependent sink logit the sink logit, one extra score per query and head whose value vector is zero, so the attention it receives is removed from the output; a learned linear function of the query's input. Adding a constant to the whole bias leaves unchanged, yet shifts the sink's share of bias-only attention:A profile's overall level drops out of . It moves attention into or out of the sink and says nothing about distance.
Three further checks limit what a layer-0 profile shows. First, the key convolution folds keys through into key , so a peak at draws on information up to 4 tokens back. Second, only layer 0 assigns a fixed profile to each token. From layer 1 on, carries context, so the same token gets a different profile in each context and any readout must average over a corpus. Third, every linguistic peak needs a control. A peak matching a plausible distance, such as back to an opening bracket, counts as evidence only if a token with a different linguistic distance peaks elsewhere.
Inkling's layer 0 separates into local, broad and token-dependent heads. The figures below are computed here from the released weights, with heads numbered from 0. They cover the 8,035 tokens appearing at least 30 times in a 5.3M-token sample of English text and Python code. Heads 1, 6, 9, 10, 12 and 17 are previous-token heads, with median distance at most 4 for at least 98% of those tokens. Heads 2, 3, 13, 21 and 23 are broad, with medians of at least 100 for at least 99.6%. Heads 0, 7, 15, 16 and 19 are token-dependent, acting local for some frequent tokens and broad for others. The remaining eight heads have medians from one token to a few dozen for most tokens. All eleven local and broad heads keep their classes jointly for 95% of frequent token types. Because those exceptions include common tokens such as newlines, indentation, quotes, and punctuation, all eleven keep their class at just over half of sample positions. A newline turns heads 1 and 6 broad, with medians 586 and 945, and turns head 21 local, with median 2.
Averaged across the 24 heads, the bias sits near logits at , peaks at for all but one frequent token, and decays with distance. Its first principal component across frequent tokens carries 91.5% of variance, yet correlates with each profile's mean. By the sink check, that level shift moves attention only into or out of the sink. Once each profile's mean is removed, the first two components carry 53% and 29%, so profiles vary in shape along at least two directions.
Reach varies by word class and tokenization. Nine common prepositions with a leading space have a mean head-median of 4.3 tokens, against 19 for ten common nouns and 31 for five common adjectives. Tokenization splits reach even more sharply across thousands of tokens. The 2,494 frequent lowercase tokens without a leading space, mostly word continuations, have a median head-median of 3 tokens. The 3,073 with a leading space, which begin words, have a median of 27.
Head 16 illustrates both a real lexical split and the need for controls. Under its bias alone, the median distance is 1 to 4 tokens for "of", "to" and "by", against about 190 to 420 for "in", "on", "at", "for" and "with". Both groups leave the head comparably active, with sink shares of 42% to 64% for the first group and 60% to 76% for the second. In the same head, " )" with a leading space peaks at exactly 40 tokens, close to the median 41 tokens back to its matching opener. Yet ")" without a space also peaks at 40, even though its opener sits a median 6 tokens back. The period, comma, and other closing brackets peak at 40 too, so the peak does not track the opener.
On running text, the bias pulls layer-0 attention toward recent tokens. On 2,048-token English and Python samples, queries with a full 1,024-token window average about 500 tokens of attention distance over keys without the bias, near the 512 of uniform attention. Adding the bias cuts that mean distance to about 160 tokens. Across a query's keys, the bias varies roughly as much as the content score, with a median standard deviation of 1.2 logits against 1.0 to 1.1 for content. The bias also lowers scores overall, lifting the sink's share from 17% to 25% on English and from 11% to 18% on Python.
Full-model runs confirm the head classes on real text. A quantized copy of the modelInkling 2 Mini's Q4_K_XL GGUF file run in llama.cpp, with layer 0's attention recorded after the softmax; that attention is within a mean total variation distance of 0.003 per row of a reimplementation run on the BF16 weights, far below the gaps between the model and the bias reported here. Reading note: Reading a model's weights confirms all three classes on three passages of English prose, Python, and nested brackets, each at most 485 tokens long (computed here with the local quantized model). Previous-token heads keep medians of 1 to 3 tokens, broad heads sit at 56 to 127, and token-dependent heads rank queries like their bias-only medians, with rank correlations of 0.86 to 0.96. On these passages, heads 14 and 18, along with the token-dependent head 19, are as local as the previous-token heads. Heads 8, 11, and 20 vary across queries as much as the token-dependent heads, both in the model and under the bias alone. Only the type-based lists above keep those six heads out of the corresponding groups. Compared with the bias alone, the model puts less mass at , dropping head 1's share of key attention there from 65% to 48%. It also sends less attention to the sink in 21 of 24 heads, most sharply in head 13, where the sink share falls from 85% to 23%.
Specific bias predictions also carry over, subject to passage length. Head 16's preposition split holds on English text, with medians of 2 tokens for "of", "to" and "by" against 26 for "in", "on", "at", "for" and "with" (2 and 32 under the bias alone). A newline turns head 1 broad, with median 163, and sends 99% of head 6's key attention to the newline itself, matching the bias alone over those keys. Passages this short cap the broad heads' medians, so the full-window 1,024-distance figures above are not directly comparable. Head 6's full-window median of 945 tokens after a newline puts half of its bias-only attention past the end of these passages.
Terms
- Permutation equivariance
- with no position signal and no mask, permuting the tokens permutes the outputs, so order is invisible
- Causal-mask leak
- position averages exactly values, so uniform attention on a start token's value gives
- Position term as prior
- : the bias is a log-prior over distance
- T5 bias
- one scalar per head per distance bucket, 32 buckets; in the decoder every distance from 113 on shares the last
- ALiBi
- with fixed geometric slopes; stable on long inputs, and its gain from longer windows comes from the early token curse
- RoPE
- score : relative, with a content-set profile
- FIRE
- bias , an MLP on a distance normalized into
- Canon layer
- , local order outside attention
- Inkling bias
- with : the query picks its profile
- Bias-only attention
- , the attention under equal content scores
- Head-median
- median over heads of each head's median distance under bias-only attention
- Sink check
- a constant shift of the bias leaves unchanged but moves attention into or out of the sink
- Peak control
- a peak at a plausible distance needs a token whose plausible distance differs and that peaks elsewhere
Sources
- Peter Shaw, Jakob Uszkoreit, and Ashish Vaswani. Self-Attention with Relative Position Representations. NAACL, 2018.
- Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer. Journal of Machine Learning Research, 2020.
- Ofir Press, Noah A. Smith, and Mike Lewis. Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation. ICLR 2022 (arXiv 2021), 2021.
- Jianlin Su, Yu Lu, Shengfeng Pan, Ahmed Murtadha, Bo Wen, and Yunfeng Liu. RoFormer: Enhanced Transformer with Rotary Position Embedding. Neurocomputing 2024 (arXiv 2021), 2021.
- Adi Haviv, Ori Ram, Ofir Press, Peter Izsak, and Omer Levy. Transformer Language Models without Positional Encodings Still Learn Positional Information. Findings of EMNLP, 2022.
- Amirhossein Kazemnejad, Inkit Padhi, Karthikeyan Natesan Ramamurthy, Payel Das, and Siva Reddy. The Impact of Positional Encoding on Length Generalization in Transformers. NeurIPS, 2023.
- Shanda Li, Chong You, Guru Guruganesh, Joshua Ainslie, Santiago Ontanon, Manzil Zaheer, Sumit Sanghai, Yiming Yang, Sanjiv Kumar, and Srinadh Bhojanapalli. Functional Interpolation for Relative Positions Improves Long Context Transformers. ICLR 2024 (arXiv 2023), 2023.
- Zeyuan Allen-Zhu. Physics of Language Models: Part 4.1, Architecture Design and the Magic of Canon Layers. NeurIPS 2025 (arXiv 2025), 2025.
- Thinking Machines Lab. thinkingmachines/Inkling-2-Mini (weights and configuration). Hugging Face, 2026.
- Thinking Machines Lab. Introducing Inkling. Thinking Machines Lab (blog post), 2026.
- Hugging Face Transformers contributors. Inkling2Loop model implementation (modeling_inkling2_loop.py and configuration_inkling2_loop.py). Hugging Face Transformers pull request #51050 (open), read at commit 6173a2f679ff4ed393afc499aefc569da7e68bc1, 2026.
- Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention Is All You Need. NeurIPS, 2017.
- Catherine Olsson, Nelson Elhage, Neel Nanda, et al. In-context Learning and Induction Heads. Transformer Circuits Thread, 2022.
- Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient Streaming Language Models with Attention Sinks. ICLR 2024 (arXiv 2023), 2023.
Connected notes
- Direct preference optimizationLearning from human preferences · Exponential tilting
Without the KL term the best policy puts all its mass on one sequence; with it the target is , which puts mass on exactly the sequences the reference model gives mass to and moves toward the best sequences as falls.
- Nonvacuous PAC-Bayes boundsGeneralization bounds · Exponential tilting
In a PAC-Bayes bound the KL from posterior to prior is the complexity term, and a Gaussian prior centered at the initialization makes it grow with how precisely the weights are specified and how far they move in training.
- Mean-field limits of two-layer networksLazy training and feature learning · Exponential tilting
Noisy training minimizes a free energy, half the risk plus weight decay minus the entropy over , and its unique minimizer is the Gibbs fixed point, proportional to for a potential that itself depends on the minimizer.
- PPO and RLOO for language modelsReinforcement learning for reasoning · Exponential tilting
In Ziegler et al.'s mock task, where the reward is known, the best policy at each KL is the reference reweighted by and renormalized; PPO trained on 2M episodes, the number used in the main experiments, earns clearly less reward than this optimum at the same KL, and more training mostly closes the gap.