Understanding Modern LLM Architectures and Parameter Scale
This article breaks down the two core dimensions for understanding large language models: network architecture and parameter scale. It explains dense and sparse Mixture-of-Experts (MoE) structures, the evolution of attention mechanisms, positional encoding and context extension, and how activated parameter counts map to deployment tiers. It also outlines a four-step selection process and common engineering pitfalls around memory estimation, long context, quantization, and observability.
1. Why Architecture and Parameter Scale Are the Two Core Dimensions
In engineering practice, describing a model only as “very capable” provides almost no guidance for architecture selection or capacity planning. Only two types of descriptions carry real information: the network architecture (how information flows and how parameters are organized) and the parameter and activation scale (the order of magnitude of compute and memory cost). The former determines training stability and inference parallelism strategy; the latter directly determines whether a single GPU can host the model, how many machines and GPUs are needed, and the upper limits on batch size and throughput.
A common misconception needs clarification: total parameter count does not equal the actual compute of a single forward pass. In dense structures the two are roughly proportional; in sparse Mixture-of-Experts (MoE) structures, the total parameter count can be very large, but each token activates only a small subset of experts. Therefore “total parameters” and “activated parameters” must be stated separately, or capacity estimates can be off by several times.
2. Breaking Down the Dominant LLM Architecture Paradigms
2.1 Dense Feed-Forward Structure
The most classic implementation is “embedding layer + N Transformer blocks + output head,” where each block contains normalization, self-attention, and a feed-forward network, with residual connections running throughout. Its strengths are simple implementation, mature parallelism strategies, and stable latency at small batch sizes; its weakness is that parameters and compute are tightly coupled, so stronger representational power requires a proportional increase in compute.
Illustrative structure:
tokens -> embeddingfor i in range(N):h = h + Attn_i(Norm(h))h = h + FFN_i(Norm(h))logits = Head(Norm(h))
2.2 Sparse Mixture-of-Experts (MoE) Structure
MoE replaces the feed-forward layer with “a router + multiple experts,” where each token selects Top-K experts to participate in computation based on routing results. Its engineering value lies in decoupling “model capacity” from “per-token compute”: total parameters can be very large while activated parameters stay within a controllable range. The cost is high memory usage, uneven routing load, and heavy distributed communication (All-to-All) pressure, requiring auxiliary losses, capacity factors, and expert parallelism to work together.
# Pseudocode: core logic of Top-2 routinglogits = router(hidden) # [batch, seq, num_experts]topk_val, topk_idx = logits.topk(2) # select two expertsweights = softmax(topk_val, dim=-1)out = sum(weights[k] * experts[topk_idx[k]](hidden) for k in range(2))
2.3 Evolution of Attention Mechanisms
Common directions in the industry include: grouped-query attention (GQA) and multi-query attention (MQA), which reduce memory bandwidth pressure by sharing key-value heads; sliding-window and local attention, which reduce complexity from quadratic to near-linear; and various linear attention and hybrid attention layer stacks, which use a few global layers to preserve long-range modeling ability. The most common engineering combination is “mostly local/linear layers + a few global layers.”
2.4 Positional Encoding and Context Extension
Rotary position encoding combined with frequency scaling (ideas such as NTK-aware and position interpolation) is the current mainstream approach. It is important to emphasize that training length determines the “reliable working range,” and performance degradation beyond it is a common phenomenon; extrapolating via inference parameters can only mitigate, not eliminate, this. The real cost of long context is memory: the key-value cache grows linearly with length, so paged cache, quantized cache, and prefix reuse are essential techniques.
3. Parameter Scale Tiers and Selection Logic
By activated parameter count, models can be roughly divided into four tiers, each corresponding to a different deployment form:
- Small tier (billions of activated parameters): can be hosted on a single GPU or even consumer devices, suitable for high-concurrency, low-latency scenarios like classification, extraction, and routing/dispatch.
- Medium tier (tens of billions of activated parameters): inference can run on a single high-performance GPU, the main range for general dialogue and code assistance.
- Large tier (hundreds of billions of activated parameters, mostly MoE): requires multi-machine, multi-GPU setups with tensor/expert parallelism, suitable for complex reasoning and long-document processing.
- Extra-large tier (trillions of total parameters, hundreds of billions of activated parameters): both training and inference require mature cluster scheduling, usually offered only as a service.
For selection, a four-step approach is recommended: first determine the hard constraints on latency and throughput, then determine the context length requirement, then estimate memory using activated parameters rather than total parameters, and finally validate whether quality meets requirements with a small-scale evaluation set. Memory can be roughly estimated by summing three items: “weights + key-value cache + activations and temporary buffers.” The key-value cache size is proportional to the number of layers, number of key-value heads, head dimension, sequence length, and batch size.
4. Common Pitfalls and Engineering Recommendations
First, do not use total parameters to compare models with different structures side by side; second, do not assume long context is free, as cache and bandwidth are the real bottlenecks; third, quantization can significantly reduce cost, but you must evaluate precision loss and keep high precision for sensitive layers; fourth, when deploying as a service, general cloud capabilities such as logging services, monitoring and alerting, container platforms, and object storage should be incorporated into the design early, to track first-token latency, throughput, error rate, and cost. If using the relevant general capabilities of Baidu AI Cloud, it is likewise recommended to organize around three main threads: “observability + elastic scaling + cost attribution,” rather than tuning parameters against a single metric.
Overall, understanding LLMs comes down to two main threads: architecture determines how information is organized and how parallelism is partitioned, while scale determines the order of magnitude of cost and the deployment form. Quantifying these two points clearly turns selection and capacity planning from experience-based judgment into a reproducible engineering problem.
