Understanding Large Language Model Architecture and Parameter Scale: A Practical Framework
This article breaks down large language model architecture into six standard layers and explains how structure, rather than parameter count alone, determines capability, inference cost, and deployment shape. It covers common parameter ranges for dense models, the distinction between total and activated parameters in Mixture of Experts (MoE), the evolution of attention and feed-forward designs, how long context is actually achieved, and simplified formulas for estimating memory and compute. Readers will learn a transferable method for classifying any new model and estimating resource needs before running benchmarks.
1. Why You Need a “Structure–Scale” Framework First
When discussing specific models, many people focus on a single number: how many parameters it has. But parameter count is only a result. What actually determines capability, inference cost, and deployment shape is structure. At the same parameter count, dense and sparse Mixture of Experts (MoE) architectures differ completely in memory footprint, throughput, and latency characteristics. Under the same architecture, the attention implementation and positional encoding scheme can significantly affect long-context performance.
So this article does not revolve around any specific vendor’s model lineup. Instead, it abstracts the general dimensions widely accepted in the industry into a transferable evaluation method. The serialized version catalogs that appear in source material (for example, lists organized by major version, minor version, and lightweight Flash-style editions) essentially reflect the industry’s common release cadence: one flagship main version, several capability-enhanced versions, and lightweight versions aimed at low-latency scenarios. Understanding this cadence is more valuable than memorizing a particular model name.
2. The Standard Layered Structure of Modern LLMs
A typical decoder-only large language model can be broken into six layers. Understanding them layer by layer covers most structural analysis needs.
- Tokenizer: Splits text into subword units, with vocabulary sizes typically ranging from tens of thousands to just over two hundred thousand. Vocabulary size directly affects the parameter count of the embedding matrix and the efficiency of multilingual and code scenarios.
- Embedding: Maps tokens to vectors of hidden dimension
d_model. Parameter count is roughly vocabulary size multiplied by hidden dimension, and in mid-to-large models this term often accounts for a few percent of total parameters. - Transformer Block (backbone repetition): Composed of normalization, an attention sub-layer, and a feed-forward sub-layer, repeated N times. This is the main source of parameters and compute.
- LM Head: Projects hidden states back to vocabulary space, usually sharing weights with the embedding matrix to save parameters.
- Positional information mechanism: Modern designs mostly use Rotary Position Embedding (RoPE) and its interpolation/extrapolation variants, replacing earlier absolute positional embeddings to obtain longer context through length extrapolation from the training length.
- Training and alignment shell: Includes stages such as supervised fine-tuning and preference optimization. This part does not change the backbone structure but determines the model’s behavioral characteristics.
A schematic structural description (pseudocode, expressing only dimensional relationships):
class Block(nn.Module):def __init__(self, d_model, n_heads, d_ff, n_experts=None):self.norm1 = RMSNorm(d_model)self.attn = Attention(d_model, n_heads) # MHA / GQA / MLA variantsself.norm2 = RMSNorm(d_model)self.ffn = DenseFFN(d_model, d_ff) if n_experts is None \else MoEFFN(d_model, d_ff, n_experts)# Rough parameter estimate: N * (attention params + FFN params) + vocab-related params
3. Common Parameter Ranges and What They Mean
The industry usually divides dense models into several empirical ranges. These ranges have no strict standard but are practical for resource estimation:
- Below the billion mark (roughly 0.1B–2B): Suitable for on-device or high-concurrency lightweight scenarios; low latency, limited capability.
- Mid-billion range (roughly 3B–8B): Can be hosted on a single or dual GPU; the cost-performance sweet spot with a mature fine-tuning ecosystem.
- Ten-billion to hundred-billion (roughly 10B–100B): Requires multi-GPU tensor parallelism; a significant capability jump and the mainstream choice for self-hosted services.
- Above a hundred billion (roughly 100B–1T+): Training requires large-scale clusters and pipeline parallelism; inference typically relies on quantization and expert parallelism.
For sparse MoE models, you must distinguish two numbers: total parameters and activated parameters. Total parameters determine memory and storage cost; activated parameters determine per-step compute. For example, a model with tens of billions of total parameters that activates only a small subset of experts per token may have inference compute overhead close to a much smaller dense model, while its memory requirement is still counted by total parameters. This is where MoE structures are most easily misread.
4. Key Trends in Attention and Expert Structures
On the attention side, the general trend is to reduce key-value cache overhead: from multi-head attention to grouped-query attention (GQA), which lets multiple query heads share one set of key-value heads; then to various low-rank compressed attention variants that squeeze the key-value cache into a smaller latent space. The longer the context, the greater the payoff, because this directly determines the slope of memory growth during inference.
On the feed-forward side, the mainstream approach is a gated linear unit structure (such as the SwiGLU family), with the intermediate dimension typically a multiple of the hidden dimension. Sparsification replaces a single feed-forward layer with multiple experts plus a routing network. Routing generally uses top-k selection combined with a load-balancing loss to avoid overloading a few experts. In engineering, you also have to handle the communication overhead introduced by expert parallelism, which is why MoE models are more sensitive to interconnect bandwidth.
5. Context Length and How Long-Text Capability Is Achieved
Long context is not a single switch but a combination of three things: whether the training phase included long-sequence samples, whether the positional encoding was adapted for extrapolation, and whether the inference side uses cache compression or sparse attention. To judge a model’s long-text capability, look at its actual evaluation performance at the target length, not the advertised maximum window size.
6. How to Estimate Resource Overhead
You can use the following simplified relationships to judge orders of magnitude (where d is the hidden dimension, L is the number of layers, and V is the vocabulary):
Backbone params ≈ L * (4 * d^2 + 3 * d * d_ff) # attention ~4d^2, SwiGLU-style FFN ~3d*d_ffEmbedding params ≈ 2 * V * d (or ~V * d if weights are shared)Inference memory ≈ params * bytes per param + KV cacheKV cache ≈ 2 * L * d_kv * sequence length * batch size * bytes
In real deployment, quantization (such as 8-bit or 4-bit weights) can reduce weight memory roughly linearly, but the key-value cache and activation overhead do not shrink proportionally. This is often the real bottleneck for long-context serving.
7. General Patterns of Version Iteration and Selection Advice
Looking at how the industry commonly organizes versions, iteration usually advances along three lines: the flagship version improves overall capability and reasoning performance; enhanced versions fill in engineering capabilities such as tool calling, structured output, and long context; lightweight versions compress latency and cost for high-concurrency online business. When selecting, work backward from the scenario: offline batch processing prioritizes capability and throughput, online conversation prioritizes time-to-first-token and concurrency, and on-device prioritizes memory and power consumption.
For cloud deployment, you can combine a container platform to host inference services, object storage to hold models and data, a message queue to smooth request spikes, and logging plus monitoring and alerting for observability. Baidu AI Cloud offers standard infrastructure categories for these general capabilities; refer to the official documentation for specific specifications and pricing.
8. Common Misconceptions
- Looking only at total parameters and not activated parameters, leading to skewed compute estimates.
- Treating the maximum context window as effective context capability.
- Ignoring the contribution of vocabulary and the embedding matrix to memory.
- Assuming quantization reduces all memory overhead proportionally.
- Inferring extrapolation length directly from training length without considering the positional encoding adaptation scheme.
Once you master this framework, when facing any newly released model you can first complete structural classification, parameter-range judgment, and resource estimation on paper, then decide whether real testing is needed. This is closer to the engineering essence than chasing model-name lists.
