Understanding LLM Architectures and Parameter Sizes: A Technical Guide to Model Selection
This article breaks down the core design patterns of mainstream large language models, focusing on how architecture and parameter scale shape performance, memory usage, and inference cost. It covers decoder-only structures, dense versus MoE designs, attention optimizations, and long-context techniques, then outlines a practical framework for choosing model sizes based on latency and memory budgets. Readers will also find key training and serving considerations, common misconceptions, and evaluation practices for robust capacity planning.
1. Introduction: Why Architecture and Parameter Count Are the Two Anchors
When engineers discuss a model’s capability boundaries, two questions come up most often: “What is its architecture?” and “How many parameters does it have?” The architecture determines how the model organizes information, parallelizes computation, and extrapolates to longer contexts. The parameter count determines the capacity ceiling, memory footprint, and inference cost.
It is important to note that parameter count does not equal actual computation. Especially with the rise of sparse architectures, the two have become clearly decoupled. This article takes a general technical perspective, abstracts the common design patterns of mainstream large language models (LLMs), and provides practical evaluation methods.
2. A General Abstraction of Mainstream Architectural Paradigms
2.1 Decoder-Only and Autoregressive Modeling
Most general-purpose LLMs today use a stacked Decoder-only structure, trained with the objective of “predicting the next token.” Compared with encoder-decoder structures, it is easier to reuse KV cache during inference, and the engineering implementation is simpler.
A minimal forward pass can be illustrated as follows:
# Pseudocode: for illustrating the data flow only, not a concrete implementationh = embed(tokens) # token embeddingfor layer in range(num_layers):h = h + attn(norm(h), kv_cache) # self-attention sublayer + residualh = h + ffn(norm(h)) # feed-forward sublayer + residuallogits = lm_head(norm(h)) # output vocabulary distribution
2.2 Dense vs. Sparse Mixture-of-Experts (MoE)
In a dense structure, every parameter is activated on every forward pass. A Mixture-of-Experts structure introduces a routing network that activates only a subset of experts, resulting in a “large total parameter count, small activated parameter count” characteristic.
In engineering, three numbers must be distinguished: total parameters, activated parameters, and effective computation per token. When evaluating deployment cost, memory is mainly affected by total parameters and cache, while throughput is closer to the activated parameters.
2.3 Common Attention Optimizations
- Multi-head and grouped-query attention: compress the KV cache by reducing the number of key-value heads;
- Sliding window and local attention: reduce complexity from global quadratic to near-linear;
- Sparse or linear attention variants: trade for a more stable memory curve under extremely long contexts.
2.4 Positional Encoding and Long-Context Extrapolation
Rotary positional encoding combined with frequency scaling, interpolation, or segmented strategies is the mainstream approach for extending context windows today. When judging long-text capability, you should not look only at the nominal window, but also at the “effective context length,” meaning recall stability on mid-context information retrieval tasks.
2.5 Normalization and Activation Functions
Pre-Norm combined with root mean square normalization has become a common pairing. Feed-forward layers mostly use gated linear unit-type activations to achieve better convergence at the same parameter count.
3. Common Parameter Scale Ranges and Selection Criteria
The industry typically divides models into several magnitude ranges: below the billion-parameter level suits on-device and high-frequency lightweight tasks; the billion-to-ten-billion level suits most mainstream business workloads; the ten-billion-to-hundred-billion level is used for complex reasoning; and above a hundred billion is mostly seen in sparse structures labeled by total parameters.
For selection, a three-step approach of “task complexity — latency budget — memory budget” is recommended:
- First determine the acceptable per-request latency and concurrency;
- Then convert to memory requirements (weights + KV cache + framework overhead);
- Finally validate effectiveness with a business evaluation set, rather than looking only at the parameter number.
4. Key Points for Coordinating Training and Inference
- Parallelism strategy: data parallelism, tensor parallelism, and pipeline parallelism are usually combined;
- Precision strategy: mixed-precision training and low-precision inference need calibration to avoid precision collapse;
- Serving side: continuous batching, paged cache management, quantization, and distillation can significantly reduce costs;
- Observability: track first-token latency, throughput, and error rates through logging services and monitoring alerts.
5. Common Misconceptions
First, treating total parameters as activated parameters; second, treating the nominal context as the effective context; third, ignoring the impact of vocabulary size on memory and embedding layer cost; fourth, looking only at offline evaluation without considering performance under real traffic distributions.
6. Conclusion
Understanding LLMs is essentially understanding that “architecture determines how information flows, and parameters determine how capacity and cost are allocated.” On platforms such as Baidu AI Cloud, teams can build evaluation and inference pipelines based on general capabilities like container platforms, object storage, and monitoring alerts, turning architectural understanding into measurable engineering metrics for more robust model selection and capacity planning.
