Modern Large Language Model Architecture and Parameter Scale Explained
This article breaks down the architecture and parameter scale of modern large language models. It covers the core components of decoder-only Transformers—including attention variants, gated FFNs, normalization, positional encoding, and MoE layers—explains the differences between dense and MoE parameter organization, clarifies how to count total, active, and non-embedding parameters, and provides estimation formulas for memory and compute. It also offers practical guidance on model selection and evaluation beyond raw parameter counts.
Modern Large Language Model Architecture and Parameter Scale Explained
1. Defining the Scope: Architecture and Scale Are Not Single Numbers
When asking “what architecture do modern large language models use and how many parameters do they have,” it is not enough to answer “Transformer” or “hundreds of billions of parameters.” More precisely, a modern general-purpose LLM is defined by four elements: the model backbone, how parameters are organized, the training objective, and inference engineering. The backbone determines how information flows, parameter organization determines how capacity and compute are decoupled, the training objective defines the capability boundary, and inference engineering determines real-world usability.
In current industry practice, mainstream general-purpose LLMs adopt a decoder-only Transformer: input tokens pass through embedding and positional encoding, then through stacked attention sub-layers and feed-forward sub-layers, and finally produce a probability distribution over the next token. Parameter scale should be understood from three perspectives: total parameters, active parameters, and non-embedding parameters. Comparing only total parameters can be misleading, while comparing only active parameters ignores storage and communication costs. Architecture and scale must therefore be considered together.
2. The Mainstream Backbone: Core Components of the Decoder-Only Transformer
2.1 Token Embedding and Output Layer
The token embedding maps discrete tokens to continuous vectors, and the output layer maps hidden states back to vocabulary logits. If weight tying is used, the embedding and output matrices share parameters; otherwise, the output layer adds an extra “vocabulary size × hidden dimension” parameters. The larger the vocabulary and hidden dimension, the more significant the embedding-related parameters become. For models covering multiple languages, code, and mathematical symbols, vocabulary design directly affects both parameter distribution and inference efficiency.
2.2 Attention: From Multi-Head to Grouped-Query and Sparse Variants
The attention sub-layer models dependencies between tokens. Common forms include multi-head attention, multi-query attention, grouped-query attention, and long-context optimizations such as sliding-window and block-sparse attention. Multi-head attention is expressive but requires a large KV cache; grouped-query attention reduces the number of key-value heads to lower inference memory and bandwidth pressure; sparse attention controls the compute cost of long sequences by restricting the visible range or connection patterns.
It is worth emphasizing that attention variants are not “newer is better”—they should match the context length, throughput targets, and memory budget. Short-context, high-concurrency scenarios care more about KV cache and batching efficiency; long-document understanding scenarios care more about position extrapolation, sparse attention patterns, and integration with retrieval augmentation.
2.3 Feed-Forward Networks and Activation Functions
Each Transformer layer typically contains a feed-forward network (FFN). Modern models commonly use gated linear unit structures such as SwiGLU and GeGLU, where a gating branch improves representational efficiency. The FFN intermediate dimension is usually several times the hidden dimension, making it one of the main sources of parameters and compute in dense models. If the hidden dimension is d and the FFN intermediate dimension is h, a single FFN sub-layer contains several d×h matrices. Gated structures typically include multiple projection matrices, so parameter estimates should not be based on the traditional two-layer MLP alone.
2.4 Normalization and Residual Connections
Modern models generally use Pre-Norm: normalization is applied before each sub-layer, together with residual connections to stabilize deep training. RMSNorm is widely adopted because it is computationally simple and requires no mean centering. Normalization placement, residual scaling, and initialization strategies all affect convergence in deep models. The larger the parameter scale, the more training stability depends on these seemingly minor architectural choices.
2.5 Positional Encoding and Long Context
Positional encoding determines how the model distinguishes order and distance. Rotary position embeddings, relative position biases, and linear biases each involve trade-offs. Long-context capability cannot be solved by positional encoding alone—it also depends on the length distribution of training data, the attention implementation, KV cache management, extrapolation strategies, and evaluation methodology. A common engineering recipe is “short-sequence pretraining + long-sequence continued training + inference-time cache optimization.”
2.6 MoE Layers: Decoupling Capacity from Compute via Routing
Mixture-of-Experts (MoE) layers typically split the FFN into multiple experts, with a router selecting the Top-k experts for each token. Key parameters include the number of experts, the intermediate dimension per expert, Top-k, the number of shared experts, the capacity factor, and the load-balancing auxiliary loss. The value of MoE is that total parameters can be very large while per-token active parameters remain small, striking a compromise between training capacity and inference compute. The costs are routing instability, uneven expert loads, expert-parallel communication, and increased deployment complexity.
An illustrative structural configuration follows. It shows generic fields only and does not represent any specific product interface:
{"arch": "decoder_only_transformer","layers": "N","hidden_size": "d","attention": "grouped_query","ffn": "gated_linear_unit","norm": "pre_rmsnorm","position": "rotary","moe": {"enabled": true,"num_experts": "E","top_k": "k","shared_experts": "S","capacity_factor": "c"}}
3. Dense vs. MoE: Two Ways of Organizing Parameters
Dense models use all parameters in every layer’s computation. They are structurally simple with stable inference paths, making them suitable for low-latency scenarios and deployments requiring determinism. Their parameter counts typically fall in the billions to tens-of-billions range; at larger scales, training and inference costs rise significantly.
MoE models turn FFN layers into experts. Total parameters can reach tens or hundreds of billions or more, but each token activates only a subset of experts. In this case, “total parameters” and “active parameters” must be distinguished: total parameters determine storage, loading, and parallelism difficulty, while active parameters more closely approximate per-token compute. MoE is not simply “more parameters is better”—routing quality, expert specialization, load balancing, and communication overhead determine the actual benefit.
4. Parameter Counting: Total, Active, and Non-Embedding Parameters
Parameter estimation should report at least three figures:
- Total parameters: the sum of all trainable weights, determining weight storage requirements.
- Active parameters: the weights actually involved in a single token’s forward pass, approximately determining compute.
- Non-embedding parameters: parameters excluding the token embedding and output layers, useful for comparing the core model capacity.
For a dense Transformer, the per-layer parameter count can be roughly written as the sum of attention projection parameters and FFN parameters. With hidden dimension d and FFN intermediate dimension h, the attention part contains roughly four projections (Q, K, V, O), and the FFN part contains multiple d×h matrices in a gated structure. The overall count must also include the embedding layer, output layer, and normalization parameters. For an MoE layer, total parameters approximate shared-expert parameters plus “number of experts × per-expert parameters” plus router parameters; active parameters approximate shared-expert parameters plus “Top-k × per-expert parameters” plus router parameters.
Generic estimation pseudocode:
def dense_params(layers, d, h, vocab, tied=True):attn = 4 * d * dffn = 3 * d * h # illustrative estimate for gated FFNper_layer = attn + ffnemb = vocab * dout = 0 if tied else vocab * dreturn layers * per_layer + 2 * emb + outdef moe_params(layers, d, h, experts, top_k, shared, vocab):router = d * expertsexpert = 3 * d * hper_layer_total = 4*d*d + shared*expert + experts*expert + routerper_layer_active = 4*d*d + shared*expert + top_k*expert + routerreturn layers*per_layer_total + 2*vocab*d, layers*per_layer_active + 2*vocab*d
The code above is a teaching illustration of the difference between total and active parameters and is not tied to any specific model configuration.
5. Memory and Compute Estimation: Key Constraints When Scaling to Production
Inference weight memory is approximately “parameter count × bytes per parameter.” FP16/BF16 is about 2 bytes, INT8 about 1 byte, and INT4 about 0.5 bytes, though quantization involves accuracy and engineering trade-offs. KV cache memory depends on the number of layers, key-value heads, head dimension, sequence length, batch size, and bytes per element. In long-context scenarios, the KV cache can become the primary bottleneck, so grouped-query attention, paged caching, prefix caching, and batch scheduling are important.
Training memory includes not only weights but also gradients, optimizer states, activations, communication buffers, and temporary tensors. Data parallelism, tensor parallelism, pipeline parallelism, expert parallelism, and sequence parallelism must be combined. MoE training additionally has to handle expert load balancing, capacity-factor overflow, router collapse, and cross-device communication. The larger the parameter scale, the more critical the communication topology and parallelism strategy become.
On general-purpose cloud platforms such as Baidu AI Cloud, training and inference pipelines can be built using generic service categories like object storage, container platforms, logging services, and monitoring/alerting. The specific resource allocation should still be determined through load testing based on the model architecture, sequence length, throughput targets, and cost constraints.
6. Selection and Evaluation: Don’t Look at Parameter Count Alone
Model selection should be based on a multi-dimensional evaluation: task performance, long-context stability, throughput and latency, memory footprint, quantization loss, tool-calling and structured output capability, safety and compliance, and operational complexity. Dense models have simpler deployment paths and suit latency-deterministic scenarios; MoE models offer large capacity but greater engineering complexity, suiting scenarios with high total-capacity requirements that can accommodate expert parallelism. Parameter count is only a proxy for capacity, not a guarantee of capability.
A recommended decision package consists of three artifacts: an architecture configuration table, a parameter-counting table, and a load-testing report. The configuration table records layers, hidden dimension, attention type, FFN type, and expert settings; the parameter table records total, active, and non-embedding parameters; the load-testing report records latency, throughput, memory, and cost under different sequence lengths and batch sizes. Only then can you properly answer “what is the architecture, how large is it, and does it fit the business?”
7. Conclusion
The mainstream architecture of modern LLMs is the decoder-only Transformer, adapted to different scales and scenarios through grouped-query attention, gated FFNs, Pre-Norm, rotary position embeddings, and MoE routing. Parameter scale should be broken down into total, active, and non-embedding parameters. MoE trades total parameters for capacity and uses active parameters to control compute, at the cost of routing and parallelism complexity. For production deployment, decisions should combine memory formulas, KV cache analysis, parallelism strategies, and load-test data—avoiding the mistake of equating parameter count with actual capability.
