Retention — recurrence with exponential decay
RetNet (Sun et al., July 2023, arXiv:2307.08621, Microsoft Research Asia) introduced the retention mechanism as a unifying primitive that can be viewed as either recurrence or as a constrained kind of attention. The core update is delightfully simple: s_n = γ · s_{n-1} + K_n^T · V_n, with output o_n = Q_n · s_n. The state s is exactly like the SSM hidden state — fixed size, summarizing all past tokens.
The decay γ is the design choice. RetNet sets γ to be fixed per attention head, with different heads getting different γ values. Heads with γ ≈ 1 maintain long memory (slow decay). Heads with γ ≈ 0 maintain short memory (fast decay). This naturally creates a multi-scale memory hierarchy: some heads pay attention to the recent past, others to the deep past, all in parallel.
Positional encoding: xPos
RetNet uses xPos for positional encoding — a complex-exponential rotation closely related to RoPE but designed for the retention mechanism's recurrent form. xPos buys translation invariance (the model doesn't care about absolute positions, only relative offsets) while remaining compatible with the recurrent computation. This is the kind of detail that doesn't matter much at the conceptual level but matters a lot at the implementation level.
Why this is interesting
The mathematical neatness is the headline. Retention is recurrence (you can write it as a per-token state update) and it is also attention (the recurrent form unrolls into a particular kind of attention matrix with exponential decay). This unification — that recurrence and attention aren't fundamentally different, but points on a continuum — is RetNet's lasting intellectual contribution. Every architecture that came after on the linear-attention/SSM side absorbed some version of this insight.