The building-block architectures behind modern models — attention, MoE, state-space, positional, diffusion — each rated on how interesting and how unique it is, and many drawn as detailed distill-style diagrams.
A hybrid block — KDA (gated delta-rule linear attention) interleaved with Gated MLA (full attention) and Stable LatentMoE — plus Block Attention Residuals: each residual add reads a gated mix of every earlier block.
Read bottom‑to‑top. Kimi K3 stacks a hybrid block — KDA (linear‑time attention), Gated MLA (full attention for exact recall) and Stable LatentMoE (shared + routed experts) — into the residual stream. The twist is Block Attention Residuals: every residual add pulls a gated read (α) off a bus carrying every earlier block’s output, not just the layer below — a learnable skip across the whole depth.
A selective state-space model: a fixed-size state carried by a linear-time recurrence whose transition parameters depend on the input, giving content-based routing of information — a leading attention-free alternative.
Instead of attending over the whole sequence, Mamba scans it: a single fixed-size state is carried step to step by a linear recurrence, and the transition parameters (Δ, B, C) are computed from the input — so the model can selectively remember or forget while staying linear in length.
The self-attention block that replaced recurrence: pre-norm → multi-head self-attention → residual, then pre-norm → MLP → residual, stacked N deep with a causal mask. Every architecture below is a variation on it.
Each block refines the token stream twice — self-attention lets positions mix, the MLP thinks per-token — and both sub-layers are wrapped in a normalize → transform → add residual, so the original signal (and its gradient) flows straight up through all N stacked layers.
Hash the last few tokens, reduce the hash modulo a different prime per head, and fetch one row per head from a table of hundreds of millions of rows; the rows are gated into the residual stream. Parameters that cost a lookup, not a matmul, and can live on the CPU or an SSD.
The last few token ids are hashed, and each head reduces the hash modulo its own prime to pick one row of a very large table. Two n-grams that collide under one prime almost never collide under another, so the concatenated rows still identify the phrase. A gate computed from the hidden state decides how much of that memory enters the residual stream, at one layer or a few.
How the Key/Value side collapses to shrink the KV cache: MHA (one KV per query head) → MQA (one shared) → GQA (a few groups) → MLA (a single compressed latent up-projected on the fly), at near-equal quality.
The queries never change — only the Key/Value side collapses. Going MHA → MQA → GQA → MLA folds many KV heads into few, or into a single compressed latent, shrinking the per-token KV cache that dominates memory at long context while keeping quality nearly intact.
Three layers in four swap attention for Gated DeltaNet: a fixed-size matrix memory per head that decays, erases what it held for the current key and writes the new value. Every fourth layer keeps full attention for exact recall. The 3:1 shape of Qwen3.8 and of small models like KLM.
A Gated DeltaNet layer keeps a matrix of fixed size per head instead of a cache. Each token first shrinks it by a decay α, then reads what the matrix already stores for its key and replaces it with the new value, at a strength β the token picks. Three such layers share each block with one full-attention layer, whose cache still grows and does the exact retrieval a summary cannot.
A small, low-precision indexer scores every cached token for each query, and the real attention reads only the top k, 2,048 in DeepSeek-V3.2. The cache keeps everything; what shrinks is what each query reads. Most open models without full attention are this.
The indexer is a second, much smaller attention: a few heads in low precision whose ReLU scores rank every cached position. The top k positions are the only ones the main attention gathers and reads. Nothing is evicted, so the cache is as large as a dense layer’s; what shrinks is how much of it each query reads.
Replace the dense FFN with many expert FFNs and a router that sends each token to only a few (plus an optional always-on shared expert). Parameters scale up while per-token compute stays flat.
Only the top-2 routed experts (plus an always-on shared expert) fire for any given token, so a layer can hold a huge pile of parameters while each token pays the compute of just a few small FFNs.
A diffusion denoiser that is a Transformer over image latent patches, conditioned on the timestep and text through adaptive LayerNorm; MMDiT carries text and image tokens in separate streams that attend jointly.
A Diffusion Transformer denoises image latents by treating patches as tokens: a stack of blocks predicts the noise ε, while the timestep and caption are pooled through a small MLP that adaptively modulates each block’s norm (adaLN). In the MMDiT variant, image and text tokens keep separate projections but mix through one joint self-attention.
Hyper-connections (HC / mHC)
2024Widen the residual stream into N parallel streams with three small learned maps around each sublayer: a weighted read, a weighted write and a stream mixer. DeepSeek's mHC keeps the mixer doubly stochastic so its product over depth cannot blow up.
The residual stream becomes N streams, but each sublayer still runs once on one vector, so its cost does not change. What is new is three tiny maps around it: a weighted read, a weighted write, and a stream mixer. mHC constrains the mixer so that rows and columns sum to one, which restores the stability the identity path of a plain residual gave for free.
Reuse the same block for several passes to buy effective depth (and latent reasoning) without adding parameters — depth paid in FLOPs, not weights.
A looped Transformer runs one shared block over and over — the output of a pass is fed back as the next pass’s input — so it gets the effective depth of a much taller model while storing the parameters of just a single layer. The extra reasoning is paid for in compute, not weights.
A non-autoregressive language model that generates by iteratively unmasking tokens under bidirectional attention — denoising a fully masked sequence over several steps instead of left-to-right.
Unlike a left-to-right autoregressive model that commits one token at a time, a masked-diffusion LM starts from an all-[M] sequence and, under bidirectional attention, unmasks a few tokens each step and re-predicts the rest — refining the whole sentence in parallel over T steps.
Encode position by rotating each query/key vector by an angle proportional to its index, so the attention score depends only on the relative offset. The de-facto positional scheme in modern LLMs.
RoPE encodes a position by rotating each pair of feature dimensions by an angle proportional to that position. Because a dot product only cares about the angle between two vectors, attention ends up reading the relative distance (m − n) for free.
A per-layer router lets each token either pass through the block or skip it via the residual, so compute is spent only where needed and effective depth becomes token-dependent under a fixed budget.
A router at every layer keeps only a fixed fraction of tokens for the block; the rest skip it through the residual connection. Because the selected set changes layer to layer, each token gets a different effective depth — and the network spends compute only where it helps.
An encoder-only stack with full (non-causal) attention, pretrained by masking tokens and predicting them — so every position sees the whole sequence. Still the default for embeddings and classification.
BERT is a Transformer encoder: with no causal mask, every position attends to the whole sequence at once, so the hidden state for [MASK] is built from context on both sides. The MLM head then reads that position and predicts the missing word.
Two stacks: an encoder that reads the source bidirectionally, and a decoder that generates while cross-attending into the encoder's representations. The seq2seq form behind translation, T5 and BART.
The encoder reads the whole source at once and produces a set of vectors; the decoder generates the target left-to-right, and at each step its cross-attention queries that encoder output — the one wire that turns two stacks into a translator.
Multi-token prediction modules
2024Extra modules that predict tokens further ahead: DeepSeek-V3's each take the previous depth's hidden state and the next token's embedding, run one block and share the output head. They add training signal, then draft tokens for self-speculative decoding.
Each module sees the hidden state of the depth before it and the real next token, so its guess one step further is conditioned on everything to its left. That keeps the causal chain that independent parallel heads give up. During training each depth adds a loss; at inference the modules either go away or propose tokens the main model checks in one pass.
Most layers attend only to the last W tokens, so their cache stops growing; a global layer every few layers reads the whole past. Stacked windows reach further than one, and many models keep an attention sink. The pattern in Gemma, gpt-oss and MiMo.
A local layer attends over a fixed window of recent keys, so its cache stops growing once the context passes W tokens. Stacking windows widens what the top of the stack can reach, and a global layer every few layers reads the whole past. Some models also keep the first tokens visible to every query as an attention sink.
Latent mixture-of-experts
2026The router reads the full-width token, but routed experts work in a narrower latent: one shared down-projection before them, one up-projection after. Each expert gets smaller, so a layer can hold and route to more of them, at the price of two dense projections every token pays for.
The router still sees the whole token, but the routed experts never do: one down-projection, shared by all of them, maps the token into a narrower latent of width ℓ, and one up-projection maps the weighted sum back. A routed expert shrinks from 3·d·f weights to 3·ℓ·f, so a layer can hold and route to more of them. The price is the two projections, which are dense and run for every token.