Understanding Modern LLM Architecture and Parameter Scale: A Practical Guide

    This article breaks down the two core dimensions used to evaluate large language models: architecture and parameter scale. It explains major structural paradigms—dense feed-forward, sparse mixture-of-experts, attention optimizations, positional encoding, and activation design—and shows how total parameters differ from activated parameters. You will also find practical methods for estimating GPU memory and compute requirements, along with selection advice and common pitfalls for deployment and capacity planning.

    1. Why Architecture and Parameter Scale Are the Two Core Dimensions

    When engineers discuss a model, the first two questions are usually: what architecture does it use, and how large is it in terms of parameters. The reason is straightforward. Architecture determines the computational complexity of inference and training, the shape of GPU memory usage, and how the model can be partitioned for parallelism. Parameter scale roughly determines the capability ceiling, the compute required for a single forward pass, and the service cost range. Together, they form the baseline for model selection, deployment, and capacity planning.

    It is important to note that total parameter count is not the same as the compute actually activated during each inference. In recent years, the industry has widely adopted sparse designs that decouple “total parameters” from “activated parameters.” As a result, models with the same nominal scale can differ severalfold in actual compute cost. Both dimensions are therefore covered below.

    2. Breaking Down Mainstream Architecture Paradigms

    2.1 Dense Feed-Forward Architecture

    The most classic form is a stack of Transformer decoder layers. Each layer contains a self-attention sublayer and a feed-forward sublayer, combined with residual connections and normalization. The feed-forward layer typically projects up and then down, with an intermediate dimension that is a multiple of the hidden dimension. This ratio directly affects the parameter share and nonlinear expressive capacity.

    2.2 Sparse Mixture-of-Experts Architecture

    Sparse mixture-of-experts replaces the feed-forward sublayer with multiple parallel “expert” networks. A gating network selects a few experts to participate in computation for each token. The benefit is that total parameters can be made very large while activated parameters per token remain controlled. The engineering cost is that all expert weights must stay resident in memory, and load imbalance and cross-device communication overhead must be handled. Common mitigations include capacity factor limits, auxiliary load-balancing loss, expert parallelism, and overlapping communication with computation.

    The routing logic can be abstracted schematically as:

    1. # Pseudocode: illustrates sparse routing and weighted aggregation only
    2. logits = gate(hidden) # gating scores
    3. topk_idx, topk_val = top_k(logits, k=2)
    4. topk_val = softmax(topk_val)
    5. out = 0
    6. for idx, weight in zip(topk_idx, topk_val):
    7. out = out + weight * experts[idx](hidden)

    2.3 Engineering Evolution of the Attention Mechanism

    The biggest bottleneck during inference is often the memory and bandwidth of the key-value cache. Widely accepted directions in the industry include grouped-query attention (multiple query heads share one group of key-value heads), multi-query attention (all query heads share one group of key-value heads), and various low-rank cache compression schemes. Their shared goal is to shrink the cache size with almost no loss in quality, thereby improving concurrent throughput.

    2.4 Positional Encoding and Normalization

    Long-context capability depends heavily on the positional encoding scheme. Rotary positional encoding and its various extrapolation/interpolation extensions are the current mainstream choice. The core idea is to adjust the frequency distribution so the model preserves continuity of relative positions even beyond the training length. For normalization, pre-normalization combined with a bias-free design has become a common configuration, and some schemes remove the mean-centering term in normalization to simplify computation.

    2.5 Activation Functions and Stability Design

    Gated activation functions are widely used in feed-forward layers, with a three-way projection structure rather than two-way. For training stability, scaled initialization of the attention output projection and the residual path, as well as lower-precision computation in the routing layer, are common robustness practices in the industry.

    3. A Layered Understanding of Parameter Scale

    From an engineering perspective, scale can be divided into four ranges to aid capacity planning:

    • Below one billion: suitable for on-device or high-concurrency, low-latency scenarios, usually with a dense architecture.
    • One billion to ten billion: the main range for general tasks, mostly dense, with inference servable on a single machine with multiple GPUs.
    • Ten billion to one hundred billion: a clear capability jump, with both dense and sparse routes coexisting, requiring multi-machine, multi-GPU setups with tensor/pipeline parallelism.
    • Above one hundred billion: almost certainly sparse, otherwise training and inference costs are hard to bear.

    A practical estimation method: for a dense model, parameter count is roughly the number of layers multiplied by the parameters per layer, where the per-layer parameters mainly come from the four projection groups in attention and the up/down projection matrices in the feed-forward layer. For a sparse model, total parameters are “shared parameters + per-expert parameters × number of experts,” and activated parameters are “shared parameters + per-expert parameters × number of activated experts.”

    4. Quick Estimation of Memory and Compute

    Inference memory can be roughly split into three parts: weights, key-value cache, and runtime activations plus framework overhead. Weights are estimated as “parameter count × bytes per parameter,” with half precision at about two bytes per parameter. The key-value cache is roughly “layers × 2 × sequence length × batch size × number of key-value heads × head dimension × bytes.” Adding these three items and leaving some headroom gives a judgment on whether a single GPU can host the model.

    1. Weight memory ≈ parameter count × bytes
    2. Cache memory ≈ layers × 2 × sequence length × batch size × kv heads × head dimension × bytes
    3. Total usage ≈ weights + cache + runtime overhead (reserve 15%~25% recommended)

    On the training side, optimizer states and gradients must be added, and memory pressure is usually several times that of inference, so mixed precision, activation recomputation, and sharded optimizer states are needed.

    5. Selection and Practical Recommendations

    1. Define constraints before choosing a model: clarify latency targets, concurrency, context length, and budget, then work backward to the acceptable activated parameters and cache size.
    2. Distinguish total from activated parameters: sparse architectures are more cost-effective in cost-sensitive, high-concurrency scenarios; dense architectures are simpler in latency-sensitive, easy-to-deploy scenarios.
    3. Pay attention to long-text cost: context length scales cache memory linearly, so long-text services should prioritize attention schemes with more efficient cache compression.
    4. Validate at small scale with an evaluation set: small-sample comparisons on your own data reflect real gains better than public leaderboards alone.
    5. Combine general capabilities for cloud deployment: a container platform can host inference services, object storage can hold models and data, a message queue can smooth request peaks, and logging plus monitoring and alerting can handle observability. This combination is vendor-neutral and can be implemented smoothly in environments such as Baidu AI Cloud.

    6. Common Pitfalls

    • Treating total parameters as compute consumption while ignoring activated parameters, leading to capacity planning errors.
    • Looking only at weight memory while ignoring the key-value cache, which tends to surface problems during stress testing in long-context scenarios.
    • Assuming more layers is always better, when the balance of width, number of attention heads, and data quality is equally critical.
    • Ignoring routing load imbalance, where sparse models may overload individual devices under real traffic.

    Mastering the three perspectives of “architecture paradigm + total/activated parameters + cache and parallelism strategy” is enough to accurately assess the architecture and scale of most modern large language models and to complete actionable deployment and cost estimation.