Understanding the Architecture and Parameter Scale of Mainstream Large Language Models
This article breaks down the core components of modern decoder-only LLM architecture—RMSNorm, grouped-query attention, SwiGLU feed-forward layers, rotary position embeddings, and mixture-of-experts routing—and explains how total parameters, activated parameters per token, and context length shape capacity and cost. Readers will find a practical scale-tier table, rough memory estimation formulas, three main lines of architectural evolution, and general guidance for training, inference, and evaluation on the cloud.
1. Why Architecture and Parameter Scale Are the Two Core Coordinates
When developers discuss a specific model, two questions come up most often: what architecture does it use, and how many parameters does it have. The first determines what family of functions the model can express and how well it handles long-range dependencies; the second determines the capacity ceiling and the compute cost. It is worth stressing that there is no single “modern architecture” in the industry. Instead, multiple engineering routes have evolved around the Transformer as a base paradigm. This article therefore does not benchmark any specific product. It abstracts a general technical framework so readers can build reusable criteria for model selection, deployment, and tuning.
Parameter scale usually needs to be split into three concepts: total parameters, activated parameters per token, and effective context length. Under a dense architecture the relationship is simple—activated parameters equal total parameters. Under a sparse (mixture-of-experts) architecture, the total parameter count can be very large, yet each token activates only a small subset of experts, keeping training and inference cost within an acceptable range. This is also why “very large” and “expensive to run inference on” are not equivalent in modern architectures.
2. Anatomy of a General Architecture: The Standard Composition of a Modern Decoder Layer
The vast majority of mainstream models use a decoder-only autoregressive architecture. A single layer can be abstracted as the following pseudocode:
class DecoderLayer(nn.Module):def __init__(self, d_model, n_heads, d_ff, norm_eps=1e-5):super().__init__()self.attn_norm = RMSNorm(d_model, norm_eps)self.attn = GroupedQueryAttention(d_model, n_heads)self.ffn_norm = RMSNorm(d_model, norm_eps)self.ffn = SwiGLU(d_model, d_ff)def forward(self, x, kv_cache=None):h = x + self.attn(self.attn_norm(x), kv_cache)return h + self.ffn(self.ffn_norm(h))
The key components and the reasoning behind their selection are as follows:
- Normalization: modern implementations generally replace layer normalization with bias terms by root mean square normalization, eliminating one mean-statistics computation. It is numerically more stable and cheaper in compute. Placing it at the input of each sublayer (Pre-Norm) also helps gradient propagation when stacking many layers.
- Attention: grouped-query attention (GQA) is a compromise between multi-head and multi-query attention. It compresses the number of key-value heads into a few groups, significantly reducing the memory footprint of the KV cache, and is the standard practice for long-context inference.
- Feed-forward network: the gated linear unit family (such as SwiGLU) has become mainstream. Combined with the empirical ratio of setting the intermediate dimension to 8/3 of the hidden dimension, it balances expressiveness and parameter count.
- Positional encoding: rotary position embedding injects relative position through rotation in the complex plane. Combined with interpolation or frequency-band scaling strategies to extend the context window, it is currently the most common approach for long text.
- Sparsification: a mixture-of-experts layer replaces the feed-forward part with multiple experts plus a routing network. Each token computes with only the top-k experts, achieving “more parameters, less compute.”
3. Scale Tiers and What They Mean for Cost
By common industry convention, scale can be roughly divided into four tiers to ease communication and capacity planning:
| Tier | Total parameter magnitude | Typical use cases | Deployment notes |
|---|---|---|---|
| Lightweight | Below one billion to around ten billion | On-device, classification and extraction, low latency | Can be hosted on a single card after quantization |
| Mid-tier | Ten billion to several tens of billions | General conversation, coding assistance | Multi-card tensor parallelism |
| Large | Around one hundred billion (dense) | Complex reasoning, long-form writing | Multi-machine, multi-card with pipeline parallelism |
| Very large sparse | Several hundred billion to trillion-scale total | Hard reasoning, unified multi-task | Expert parallelism plus high-bandwidth interconnect |
A reminder is in order: the “trillion parameters” of a sparse model refers to the total. The actual per-token compute is often comparable to a mid-tier dense model, so cost evaluation must look at activated parameters rather than the total. Memory requirements can be roughly estimated with the formulas below:
Weight memory ≈ total parameters × bytes per parameterKV cache ≈ 2 × num_layers × num_kv_heads × head_dim × sequence_length × batch × bytes
Quantization (such as 8-bit or 4-bit) mainly compresses the first term, while GQA and paged cache management mainly compress the second. Together they determine the concurrency a single card can serve.
4. Three Main Lines of Architectural Evolution
- The attention-efficiency line: from full multi-head to grouped-query, then to multi-query and explorations of linear or hybrid attention. The goal is consistent—reduce cache and bandwidth overhead while preserving long-range modeling ability.
- The sparse-capacity line: fine-grained expert splitting, shared experts combined with routed experts, and auxiliary load-balancing losses for routing are all ways to let capacity expand without linearly increasing compute.
- The context-and-position line: position interpolation, frequency scaling, and progressive strategies that gradually lengthen sequences during training allow the same set of weights to support longer inputs at inference time.
5. General Practices for Running on the Cloud
- Training side: prefer container platforms to orchestrate distributed jobs, sharding parameters, gradients, and optimizer states across multiple machines and cards. Use message queues to decouple the data pipeline, object storage to hold corpora and checkpoints, and logging plus monitoring with alerting to track loss curves, throughput, and hardware health.
- Inference side: use continuous batching and paged caching to raise concurrency, and route traffic by tiering models into lightweight and heavy classes according to business needs. Reserve always-on resources for stable traffic and absorb peak traffic with elastic scaling.
- Evaluation side: do not look at parameter count alone. Build a three-dimensional baseline of “quality–latency–cost per token,” fix the prompt set and decoding parameters for regression testing, and avoid hidden regressions introduced by architecture upgrades.
6. Common Misconceptions
- Treating total parameter count as the sole indicator of capability while ignoring the impact of data quality and the training recipe.
- Assuming sparse models are always cheap to run inference on, when the real bottleneck is often network bandwidth and routing imbalance.
- Blindly extending the context window while ignoring the cost increase from attention overhead growing with sequence length.
- Deploying only at 16-bit precision without evaluating how sensitive quantization is for specific tasks.
7. Conclusion
Understanding modern large language models is essentially understanding how architectural choices constrain capacity and cost. Once you see through the five components—normalization, attention, feed-forward, positional encoding, and sparse routing—and pair them with the three rulers of total parameters, activated parameters, and context length, you can make explainable and reproducible decisions in architecture selection, resource planning, and performance tuning.
