Expand description
A decoder-only language model’s architecture, as data.
ModelSpec says what a checkpoint computes — the width, the vocabulary, and for every layer its token mixer
(attention or a gated-delta recurrence), its feed-forward block (dense or a mixture of experts) and how its
norms are arranged. It is read from the checkpoint’s own metadata (ModelSpec::from_gguf), so bringing up a
model is reading its file: the per-architecture knowledge lives in one match over general.architecture, and
everything downstream (the authored .lg, the reference forward, the weight binding) is generic over the spec.
The meaning of each field follows llama.cpp’s graph for that architecture (src/models/<arch>.cpp at the pinned
commit), which is the reference the conformance locks hold the model to.
Re-exports§
pub use crate::tensor_recognize::qwen::Window;
Structs§
- Attention
- Grouped-query attention, with the variants checkpoints use.
- Gated
Delta - The Gated DeltaNet recurrence (Qwen3.5/3.8 linear-attention layers).
- Hyper
Connections - Hyper-connections: the residual is
lanescopies of the hidden state. Before each sublayer the lanes are normed each on its own (one weight across all of them), weighted byσ(up·silu(down·x̂ / lanes))through a bottleneck ofrankand averaged into the sublayer’s input; the sublayer’s output joins every lane scaled by2σ(inject·x̂ / lanes). A last mix with no injection feeds the head in place of an output norm. - Indexer
- Qwen’s sparse attention selection:
headsindex queries ofhead_dimover one index key a position, the keys of each complete block ofblockpositions averaged, normed and rotated at the block’s first position, each block scored byΣ_h relu(q_h·k̄)/√head_dim; a query attends the bestbudget / blockblocks and the positions after the last complete block, every visible position while the complete blocks are no more than that. The attention layers inlayersselect; any other attends every position. - Layer
- One block: its token mixer, its feed-forward block, and its norms.
- Mla
- Multi-head latent attention (DeepSeek V2/V3): the keys and values of every head are expanded from one shared
low-rank latent per position (
kv_lora_rankwide, RMS-normed), and each head’s query and key carry a furtherqk_ropedimensions that rotate — the key’s shared by every head. The query is a full projection, or itself low-rank (q_lora_rank, normed between its two halves). - Model
Spec - What a checkpoint computes.
- Moe
- A mixture of experts.
- Ple
- The per-layer n-gram embedding: each position’s n-grams of 2 to
ngramtokens, read back no further than the last end of document, are hashedheads_per_ngramways each (t₀·m₀ ⊕ t₁·m₁ ⊕ …modulo a head’s prime, from the head’s offset in one table); the heads’ rows, side by side, project to a value and to a key for each hyper-connection lane, the lane’s normed state gating the value byσ(sign(g)·√|g|)of its agreementgwith the key, and a dilated depthwise convolution over the normed gated values adds local context. Its sum joins the layer’s residual input. - Rope
- The rotary position embedding.
- Temperature
- Llama 4’s attention temperature: the query at position
p(0-based) scaled by1 + scale·ln(⌊(p + 1)/floor⌋ + 1), so short contexts are untouched and long ones sharpen (attn_temperature_tuning).
Enums§
- Act
- A gated activation
act(gate) · up. - Ffn
- A block’s feed-forward network.
- Gate
Activation - A gate’s activation: SiLU (Qwen3.5’s and Qwen3-Next’s Gated DeltaNet) or the sigmoid (Qwen3.8-Flash-Next’s).
- Gating
- How a router turns logits into expert weights, and where a weight applies: to its expert’s output, unless the gating says otherwise.
- Mixer
- How a block mixes information across positions.
- Rope
Scaling - Context extension applied to the rotary frequencies.
- Spec
Error - Why a checkpoint is not a model this crate describes.
Traits§
- Spec
Source - What a checkpoint’s architecture is read from: its architecture’s name, its keys and its tensor directory — a GGUF checkpoint, or anything describing one.