Triadic Linear Attention: Three-Dimensional Recurrent States for Long-Context Sequence Modeling
Organizations: Massachusetts Institute of Technology · MIT-IBM Computing Research Lab
Abstract
Recurrent neural networks (RNNs) compress the historical context into a memory state of fixed size, thus allowing for constant-time inference. The memory state size is a crucial factor in their performance, as exemplified by the strong performance and resurgence of linear attention, which extends the vector-valued hidden states of ordinary RNNs to matrix-valued hidden states. Crucially, linear attention does so in a parameter-efficient way, in particular by using an outer product of the key and value vectors to write to the matrix-valued hidden state. We generalize this construction and propose triadic linear attention, which writes the triadic outer product of a key, a second key, and a value, into a third-order (i.e., 3D) tensor state, and reads from it by contracting both key axes with two queries. An -dimensional second key thus yields an -fold increase in state size while adding only two projections. Triadic linear attention is compatible with data-dependent forgetting, the delta rule, and chunkwise-parallel training. Applied to Gated DeltaNet and scalar-gated linear attention, triadic linear attention substantially improves long-context language modeling and recall, outperforming alternatives that enlarge the state.
Figures & tables
| Model | State | Params | 0-shot | Wiki. | PG19 4k | PG19 4k–16k | PG19 16k–64k | Recall |
|---|---|---|---|---|---|---|---|---|
| Transformer | 12.6/1k tok | 377.0 | 52.6 | 11.11 | 15.39 | 14.41 | 13.92 | 41.6 |
| GDN (base) | 6.3 | 380.9 | 53.1 | 11.25 | 15.03 | 14.38 | 14.15 | 26.2 |
| Larger heads ( ) | 12.6 | 380.7 | 52.6 | 11.22 | 15.10 | 14.42 | 14.17 | 26.6 |
| Grouped values (2 per key) | 12.6 | 378.2 | 52.9 | 11.18 | 15.05 | 14.37 | 14.12 | 27.1 |
| Wider values ( ) | 12.6 | 377.9 | 53.2 | 11.20 | 15.07 | 14.39 | 14.14 | 27.4 |
| More heads (16) | 12.6 | 381.6 | 53.3 | 11.32 | 15.25 | 14.54 | 14.28 | 27.5 |
| Model | State | Params | 0-shot | Wiki. | PG19 4k | PG19 4k–16k | PG19 16k–64k | Recall |
|---|---|---|---|---|---|---|---|---|
| GDN (base) | 6.3 | 380.9 | 53.1 | 11.25 | 15.03 | 14.38 | 14.15 | 26.2 |
| Triadic ( ), from scratch | 50.3 | 385.4 | 53.4 | 10.87 | 14.79 | 14.04 | 13.74 | 33.1 |
| Triadic ( ), upcycled | 50.3 | 385.4 | 53.2 | 11.04 | 14.91 | 14.18 | 13.86 | 29.7 |
| sGLA (base) | 6.3 | 380.9 | 53.5 | 11.41 | 15.19 | 14.55 | 14.32 | 26.4 |
| Triadic ( ), from scratch | 50.3 | 385.4 | 53.4 | 11.03 | 14.96 | 14.23 | 13.95 | 32.1 |
| Triadic ( ), upcycled | 50.3 | 385.4 | 53.3 | 11.16 | 15.04 | 14.32 | 14.03 | 30.0 |
| Model | State @ 4k | State @ 64k | 0-shot | Wiki. | PG19 4k | PG19 4k–64k | Recall | NIAH Avg. |
| Transformer | 50 | 805 | 52.6 | 11.11 | 15.39 | 14.02 | 41.6 | 48.2 |
| GDN | 6 | 6 | 53.1 | 11.25 | 15.03 | 14.19 | 26.2 | 21.7 |
| 3:1 GDN/GQA-8 (base) | 17 | 206 | 53.0 | 10.69 | 14.86 | 13.50 | 43.7 | 51.5 |
| Larger KV cache (GQA-4) | 30 | 407 | 53.5 | 10.67 | 14.83 | 13.47 | 45.3 | 53.0 |
| Triadic state ( ) | 31 | 220 | 53.8 | 10.63 | 14.76 | 13.39 | 44.5 | 56.3 |
| Model | State | Params | 0-shot | Wiki. | PG19 4k | PG19 4k–16k | PG19 16k–64k | Recall |
|---|---|---|---|---|---|---|---|---|
| Triadic GDN (scalar gate), , | 50.3 | 384.0 | 53.7 | 10.80 | 14.77 | 14.01 | 13.70 | 33.4 |
| , | 50.3 | 380.8 | 52.9 | 10.84 | 14.79 | 14.04 | 13.73 | 32.5 |
| , | 50.3 | 383.9 | 53.3 | 10.90 | 14.82 | 14.08 | 13.78 | 32.5 |
| , , tied keys | 50.3 | 380.7 | 52.1 | 10.89 | 14.81 | 14.09 | 13.79 | 31.9 |
| Triadic GDN ( ), Softplus activation | 50.3 | 385.4 | 53.5 | 10.86 | 14.81 | 14.07 | 13.77 | 32.2 |
| Sigmoid activation | 50.3 | 385.4 | 53.7 | 10.86 | 14.82 | 14.07 | 13.77 | 33.3 |
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.