↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Loading recorded inference…

What linear attention is

Softmax attention keeps every past key and value. A decoder's KV cache grows by one entry per token, and each new query is compared with all of them. Linear attention drops the softmax so that the sum over the past folds into one matrix. If a token's output is , then can be updated one token at a time and read with the query:

The model becomes a recurrent network whose state has a fixed size, whatever the length of the prompt. RWKV-7 is such a network. This page records RWKV-7 0.1B (g1) on The capital of France is: five tokens through all 12 blocks of width 768, each with 12 heads of 64. The most likely next token is Paris, with probability 0.3204. Each head carries one 64 × 64 state from token to token, and there is no KV cache.

Token shift and the six projections

RWKV-7 has no position input. The order of the tokens reaches the model through the recurrence and through token shift: before projecting, each block mixes every token's input with the previous token's, with a learned per-channel weight for each projection :

The bank then makes six vectors per token, each 768 wide (12 heads of 64): the receptance , which reads the state as a query reads keys; the key and value ; the decay ; the in-context learning rate ; and the output gate . , and are full 768 × 768 projections. , and are low-rank, passing through 64, 64 and 128 dimensions. Block 1 also applies an extra LayerNorm, ln0, to the embedding.

The state update

Each head keeps a state , a 64 × 64 matrix whose rows index value channels and whose columns index key channels. Every token changes it in three steps, which the WKV state update popup names decay, delta rule and write:

  • Decay. Column of is multiplied by , where . It lies between 0.545 and 1 and depends on the token, so the model chooses per channel how quickly to forget.
  • Delta rule. is what the state returns for the unit key . The update removes a share of it set by , between 0 and 1, so a new value can replace an old one instead of piling on top of it.
  • Write. The value is added along the key , rescaled per channel by .

Without the decay and the delta rule this would be plain linear attention. The State S card draws the chosen head's state after each token, and it stays 64 × 64: 4,096 numbers per head and 49,152 for all 12 heads, whatever the prompt length. Besides the state, the model carries only the two token-shift vectors from one token to the next.

The recurrence as a mixing matrix

Unrolling the recurrence writes each output as a weighted sum of earlier values, the same shape as attention. With ,

The Token mixing A panel builds this matrix in three stages. The first, , ignores decay and the delta rule; the second applies the decay only; the third is the actual . The first two are comparisons that the model never computes. Unlike a softmax attention matrix, is not normalised and its entries can be negative (drawn orange), and no token reads a later one. Multiplying by the values reproduces the recurrence's output to within .

Normalisation, bonus, gate and channel mix

Each head's output goes through a GroupNorm with . A bonus term then adds the current token's own value directly, skipping the state. The sum is multiplied by the gate and projected back to 768 by . In blocks 2 to 12 the value is first pulled towards block 1's value, ; the page marks this v-first.

Each block ends with a channel mix, RWKV's feed-forward layer. It has its own token shift and a squared ReLU, , from 768 to 3072 and back. The output matrix that scores the 65,536 vocabulary entries is separate from the embedding.

Where RWKV-7 came from

Katharopoulos et al. (2020) showed that attention with a kernel feature map in place of the softmax is a recurrent network with a matrix state. Schlag, Irie and Schmidhuber (2021) read that state as fast weights written by the network, and replaced its purely additive write with the delta rule, which corrects what the memory returns for a key. RWKV (Peng et al., 2023) built large recurrent language models around a per-channel time decay; Eagle and Finch (RWKV-5 and RWKV-6) gave it matrix-valued states and a decay that depends on the token. Yang et al. trained delta-rule linear attention in parallel over the sequence (DeltaNet) and later added a decay gate to it (Gated DeltaNet).

RWKV-7 (2025) generalises both lines: its decay and its in-context learning rate are vectors, and the key it removes along differs from the key it writes. The DeltaA tab continues with Kimi Delta Attention, and the Mamba hybrid tab draws a state-space recurrence as a mixing matrix in the same way.

Papers

  1. RWKV-7 "Goose" with Expressive Dynamic State Evolution Bo Peng et al. · arXiv 2025 The model this page records: the generalised delta-rule state update with vector-valued decay and in-context learning rate, token shift, v-first and the channel mix.
  2. Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, François Fleuret · ICML 2020 Linear attention: a feature map in place of the softmax turns attention into a recurrence over a fixed-size matrix state.
  3. Linear Transformers Are Secretly Fast Weight Programmers Imanol Schlag, Kazuki Irie, Jürgen Schmidhuber · ICML 2021 Reads the linear-attention state as fast weights and introduces the delta-rule update that RWKV-7's in-context learning rate generalises.
  4. RWKV: Reinventing RNNs for the Transformer Era Bo Peng et al. · Findings of EMNLP 2023 The first RWKV: token shift, a per-channel time decay and the channel mix, trained in parallel and run as a recurrent network.
  5. Eagle and Finch: RWKV with Matrix-Valued States and Dynamic Recurrence Bo Peng et al. · COLM 2024 RWKV-5 and RWKV-6: a matrix-valued state per head and a decay that depends on the token.
  6. Parallelizing Linear Transformers with the Delta Rule over Sequence Length Songlin Yang, Bailin Wang, Yu Zhang, Yikang Shen, Yoon Kim · NeurIPS 2024 DeltaNet: a chunked algorithm that trains delta-rule linear attention in parallel over the sequence.
  7. Gated Delta Networks: Improving Mamba2 with Delta Rule Songlin Yang, Jan Kautz, Ali Hatamizadeh · ICLR 2025 Combines a decay gate with the delta rule, the family that RWKV-7 and the DeltaA tab's Kimi Delta Attention belong to.

See also