Large Language Model Architecture and Parameter Count: A Practical Guide
This guide breaks down how large language models are structured and how to read their parameter counts. It covers the standard Transformer skeleton, the difference between dense and sparse (MoE) designs, the main lines of attention optimization, a step-by-step method for interpreting headline parameter figures, and how parameter counts translate into inference and training memory. Readers will get a reusable checklist for comparing any new model and planning deployment capacity.
1. Why Structure and Parameter Count Are the Two Anchors
When discussing a language model, only two questions really carry information: which computational components it is stacked from (structure), and how many learnable values those components contain in total (parameter count). Structure determines how computation flows; parameter count determines how much knowledge the model can hold and how much GPU memory inference will consume. Listing models one by one by vendor and model number, as raw source material often does, has limited value for most readers, because model versions iterate far faster than architectural paradigms change. The more durable approach is to abstract a general paradigm and then apply it to any new model.
One common misconception needs clearing up first: more parameters does not mean more capability. Parameter count is only an upper bound on capacity; actual performance also depends on data quality and mixture, the training compute budget, post-training alignment strategy, and the decoding configuration used at inference time. So this article treats parameter count as a coordinate system for cost, not as a leaderboard of capability.
2. The Standard Skeleton of Modern LLMs
The vast majority of contemporary models can be abstracted into the following stacked structure:
Token Embedding → [ Transformer Block ] × N → Final Norm → LM Head├─ Normalization (Pre-Norm)├─ Attention sublayer (Self-Attention / GQA / MLA, etc.)└─ Feed-forward sublayer (FFN, dense or sparse MoE)
A few key design points:
- Normalization placement. The mainstream modern choice is Pre-Norm (normalization applied before each sublayer), often paired with a simplified implementation such as RMSNorm. This is more stable to train, and dropping mean centering saves a bit of compute.
- Positional encoding. From absolute positional encoding to rotary position embeddings (RoPE), which have become the de facto standard, context length is then extended through techniques such as frequency scaling and position interpolation. Differences in long-context ability mostly come from this component rather than from total parameter count.
- FFN width. The intermediate dimension of the FFN is usually 2.7 to 4 times the hidden dimension. It is the largest share of parameters and the main target for sparsification.
- Output head. The LM Head maps hidden states back to vocabulary dimensions. Vocabulary size directly inflates the parameter count of the output layer, and weight tying (sharing the input embedding with the output head) is a common parameter-saving trick for small models.
3. Dense vs. Sparse: Two Ways of Accounting for Parameters
In a dense model, every parameter takes part in computation on every forward pass, so parameter count and compute roughly correspond linearly, which makes analysis easy.
A sparse model uses a mixture-of-experts (MoE) structure, replacing the FFN with multiple parallel expert networks and using a router to activate only a few experts per token. Here three numbers must be distinguished:
- Total parameter count: the sum of all experts and shared components; determines memory and storage footprint.
- Activated parameter count: the parameters actually involved in computing a single token; determines compute and latency.
- Expert granularity and number of activated experts: affects load-balancing difficulty and training stability.
This explains a common puzzle: why some models advertise a very large total parameter count yet run at speeds close to a small model. Their activated parameters are only a small fraction of the total. When evaluating deployment cost, memory depends on the total while throughput depends on the activated count, and the two cannot be used interchangeably.
4. The Main Line of Attention Evolution
Attention is the main source of cost in long-sequence scenarios, and a standard implementation grows quadratically in memory and compute with sequence length. The optimization directions recognized across the industry fall into four categories:
- Multi-query / grouped-query attention: multiple query heads share one set of key and value heads, compressing the KV cache.
- Low-rank key-value compression: project keys and values into a lower-dimensional latent space, cache only the compressed representation, and reconstruct it at inference.
- Sparse and sliding-window attention: compute only a local window or select by block, trading some globality for linear complexity.
- Linear attention and hybrid architectures: replace explicit softmax attention with state updates, using linear form in some layers and full attention in others.
In engineering practice, these approaches are often combined with KV cache quantization and paged cache management, and the actual gains frequently turn out to be more noticeable than switching the attention formula itself.
5. How to Read a Parameter Count
When you see a statement like “671B total parameters, 37B activated,” it helps to break it down in this order:
- Strip out the embeddings first. Subtract the token embedding and output head from the total; what remains is the backbone capacity.
- Compute per-layer parameters. The attention part is roughly
4 × d_model²(grouped-query attention is significantly smaller), and a dense FFN is roughly2 × d_model × d_ffn. - Cross-check with layer count. Backbone parameters ÷ per-layer parameters ≈ number of layers; if the result is far off, there is likely MoE or shared-layer structure.
- Look at the activation ratio last. The activated share usually lands between 5% and 20% of the total; the lower the ratio, the higher the sparsity.
A rough estimation function:
def estimate_params(d_model, n_layers, vocab, d_ffn, kv_heads_ratio=1.0):embed = vocab * d_model # input and output embeddings (double if not tied)attn = 4 * d_model * d_model * kv_heads_ratioffn = 2 * d_model * d_ffntotal = embed + n_layers * (attn + ffn)return total
6. From Parameter Count to GPU Memory: Order-of-Magnitude Judgment for Deployment
Inference memory splits roughly into three parts: weights, KV cache, and runtime overhead. In half precision, weights take about parameter count × 2 bytes; for a hundred-billion-scale dense model, the weights alone approach hundreds of GB, so a single machine with multiple GPUs is already the bare minimum. The KV cache is roughly 2 × n_layers × n_kv_heads × head_dim × sequence_length × batch × bytes, and under long-context, high-concurrency conditions it often exceeds the weights themselves. That is the fundamental reason the various cache compression schemes exist.
On the training side you must add optimizer states, gradients, and activations, so memory demand is typically several times that of inference. This requires a combination of data parallelism, tensor parallelism, pipeline parallelism, and recomputation. With cloud resources, GPU instances are generally scheduled through a container platform, with object storage holding datasets and checkpoints, and log and monitoring services tracking throughput, memory watermarks, and loss curves; in scenarios like this Baidu AI Cloud also provides general-purpose capabilities of these categories, and specific specifications should be confirmed against the official documentation.
7. A Reusable Analysis Checklist
For any new model, asking the following in order is enough to locate it quickly:
- Dense or sparse? What are the total and activated parameter counts?
- Which KV compression strategy does the attention use, and what extends the context length?
- How large is the vocabulary, and is the token embedding shared with the output head?
- Choices of normalization and activation function, and do they affect inference precision?
- Is the officially stated parameter count a backbone-only figure or does it include embeddings?
- Is the target scenario latency-sensitive or throughput-sensitive, and is the bottleneck the weights or the KV cache?
8. Conclusion
Model names will keep changing, but architectural paradigms and accounting rules stay relatively stable. Master the main line of skeleton, sparsification, attention optimization, parameter accounting conventions, and memory estimation, and you can place any new model in the same coordinate system for comparison and make rational selection and capacity-planning decisions, instead of being pulled along by a single number.
