Modern Large Language Model Architectures and Parameter Scale Explained
This article breaks down the two main axes for understanding modern large language models: network architecture and parameter budget. It covers dense feed-forward versus sparse Mixture-of-Experts (MoE) designs, efficiency改造 of attention such as GQA, MQA and KV cache reduction, positional encoding for long-context extrapolation, normalization and activation choices, layered parameter tiers, mixed-precision training memory budgets, and practical evaluation and selection guidance for deployment.
1. Why Architecture and Parameter Scale Are the Two Main Axes
The source material lists models generation by generation, but what is actually useful to developers is not a catalog of model names. It is the two recurring decisions behind that generational evolution: how the network is organized, and how the parameter budget is allocated. The first determines whether a model can be trained stably and how well it extrapolates to long text; the second directly determines memory footprint, throughput, and cost per unit of inference. Once these two threads are abstracted out, any new generation of models can be positioned quickly.
One common misconception needs to be cleared up front: total parameters are not the same as the activated parameters that actually participate in computation during each forward pass. Under sparse architectures the two can differ by several times, which makes this distinction essential when estimating cost.
2. Breakdown of Mainstream Modern Architectures
2.1 Dense Feed-Forward and Sparse Mixture-of-Experts
Early models generally used dense feed-forward networks, where every token passes through all parameters. To scale capacity under a controlled compute budget, the industry moved to sparse Mixture-of-Experts (MoE): a gating network selects a small number of experts for each token, decoupling “capacity” from “compute.”
# Illustrative pseudocode for token-level top-k routinglogits = gate(x) # [num_tokens, num_experts]topk = logits.topk(k=2, dim=-1) # pick 2 experts per tokenweights = softmax(topk.values, dim=-1)y = sum(weights[i] * experts[idx](x) for i, idx in enumerate(topk.indices))
The genuinely hard part in engineering is load balancing: routing skew overloads some experts while leaving others idle. Common approaches include an auxiliary balancing loss, capacity limits with dropping policies, and expert parallelism for sharding.
2.2 Efficiency Rework of the Attention Mechanism
Standard multi-head attention has complexity that grows quadratically with sequence length. To cut long-context cost, the industry commonly applies several modifications: grouped-query attention (GQA) and multi-query attention (MQA) compress the KV cache by sharing key/value heads; sliding-window and local attention restrict the receptive field; linear attention and state-space structures replace the full history cache with constant-size state. In practice, sparse or linear attention is often applied to only some layers, forming a hybrid stack.
The KV cache is the main source of memory consumption in long-context inference, and its magnitude can be approximated as:
KV_bytes ≈ 2 × layers × kv_heads × head_dim × seq_len × batch × bytes_per_elem
This formula explains why reducing the number of KV heads and using low-precision caches (such as 8-bit or 4-bit quantization) can significantly extend the servable context length.
2.3 Positional Encoding and Long-Text Extrapolation
Rotary position embedding (RoPE) has become the de facto baseline, and long-context extension is usually achieved by adjusting the base frequency, position interpolation, or frequency-band scaling. To judge a model’s long-text ability, do not look only at the nominal window; also look at its actual degradation curve on retrieval-style and multi-hop reasoning tasks.
2.4 Normalization, Activation Functions, and Stability
Pre-Norm combined with a simplified normalization such as RMSNorm and a gated activation such as SwiGLU is currently the more stable combination. Deep networks also need attention to residual scaling, initialization variance, and learning-rate warmup; otherwise loss spikes tend to appear early in training.
3. A Layered View of Parameter Scale
Modern models can be roughly tiered by activated parameters to help with capacity planning:
| Tier | Activated parameter range | Typical deployment form |
|---|---|---|
| On-device / lightweight | Below 1B up to a few B | Single card or even consumer devices |
| General-purpose mainstream | A few B to tens of B | Single machine, multiple cards |
| Large-scale sparse | Hundreds of B total, tens of B activated | Multi-machine, multi-card clusters |
| Ultra-large-scale | Trillion-level total parameters | Dedicated training clusters |
For sparse models, memory must be estimated from total parameters, while compute and throughput are estimated from activated parameters. This “dual-ledger” method is the key to cost estimation.
4. Training Precision and Memory Budget
Mainstream training uses mixed precision: forward and backward passes are mostly 16-bit floating point, while optimizer states and master weights are kept at higher precision. Memory consumption roughly breaks down into “parameters + gradients + optimizer states + activations,” where optimizer states are often the long-tail item. Mitigations include tensor/pipeline/sequence multi-dimensional parallelism, activation recomputation, sharded optimizer states, and offloading to host memory.
5. Practical Evaluation and Selection Advice
- Define constraints first: context length, concurrency, latency ceiling, and memory budget, then discuss architecture choices.
- Distinguish total from activated parameters to avoid misjudging inference cost by total parameters.
- Focus on real long-text performance rather than the nominal window, and validate with self-built retrieval and multi-hop samples as regression tests.
- Quantization schemes need end-to-end quality regression, and low-precision KV caches should be matched to the task type.
- On the deployment side, you can rely on general cloud capabilities: container platforms to host inference services, object storage for models and data, message queues for peak shaving, and logging plus monitoring and alerting for an observability loop, enabling elastic scaling and cost accounting on general infrastructure such as Baidu AI Cloud.
