Large Language Model Architecture and Parameter Scale: A Practical Guide

    This article breaks down modern large language model design into four stable dimensions—attention variants, positional encoding, dense versus sparse feed-forward layers, and parameter scale tiers. It explains how to reason about compute, memory, and KV cache budgets, then covers common deployment and cost optimizations such as quantization, continuous batching, and observability. Readers will gain a model-agnostic framework for evaluating any new LLM release.

    1. Why You Need a Unified View of Architecture and Scale

    When developers evaluate a specific model, three questions come up most often: what structure does it use, how many parameters does it have, and what does inference cost. Yet models iterate quickly, and model names change almost every quarter. What stays stable is the underlying architectural paradigm and the logic of scale tiers. So instead of focusing on any particular model, this article abstracts a general technical framework that the industry broadly accepts, so you can quickly assess the technical positioning of any new model you encounter.

    One clarification: parameter count is not the same as a capability ceiling. With an identical parameter count, training data quality, data mixture, number of training epochs, and post-training strategy (supervised fine-tuning, preference optimization, reinforcement learning) can all change final performance significantly. Scale is better understood as a marker on a cost budget, not the sole determinant of quality.

    2. Four Core Dimensions of Mainstream Architectures

    2.1 Dense vs. Sparse Mixture-of-Experts (MoE)

    In a dense architecture, every parameter participates in each forward pass, so training and inference cost grow linearly with parameter count. A sparse mixture-of-experts architecture splits the feed-forward layers into multiple “experts” and uses a router network to select a few experts per token. The result is a large total parameter count with a smaller activated parameter count.

    The engineering trade-offs are concrete: memory usage is determined by total parameters, while compute is determined by activated parameters; uneven routing load can overload some experts; and expert parallelism across devices adds communication overhead in distributed training. The routing logic looks roughly like this:

    1. # Pseudocode: Top-K expert routing
    2. logits = router(hidden_state) # [tokens, num_experts]
    3. topk_val, topk_idx = logits.topk(k=2) # activate only 2 experts
    4. weights = softmax(topk_val, dim=-1)
    5. out = sum(weights[i] * experts[topk_idx[i]](hidden_state)
    6. for i in range(k))

    2.2 Efficiency Improvements to Attention

    Standard multi-head attention (MHA) has memory and bandwidth costs that grow quadratically with sequence length. Common industry approaches include: multi-query and grouped-query attention (MQA/GQA), where multiple query heads share one set of key-value heads, sharply reducing the KV cache during inference; sliding-window and local attention, which confine global dependencies to a fixed window; and linear attention or state-space hybrid structures, which replace a growing cache with a fixed-size state and keep memory flat for long-context inference.

    2.3 Positional Encoding and Extrapolation

    Rotary position embedding (RoPE) has become the mainstream choice. Its advantage is a relative-position inner-product property that is friendly to attention, and it supports context window extrapolation by adjusting the base frequency, position interpolation, or segmented scaling. One practical caveat: training length, advertised context length, and effective context length are often three different numbers. For long-context scenarios, validate with your own key-information retrieval evaluations.

    2.4 Normalization, Activation Functions, and Stability

    Pre-Norm combined with RMSNorm is now the default pairing and noticeably reduces training oscillation. Gated activations such as SwiGLU have largely replaced traditional ReLU/GELU in feed-forward layers. Large-scale training also introduces several stability techniques, including scaling of the output and residual branches, attention soft-cap, and loss scaling under low-precision training.

    3. Parameter Scale Tiers and Selection Guidance

    The industry usually groups models into four tiers by activated parameter count. Match the tier to your task and budget:

    • Edge/small tier (hundreds of millions to a few billion): low latency, deployable locally or at the edge, suitable for classification, extraction, and fixed-format rewriting.
    • Lightweight general tier (a few billion to low tens of billions): fits on a single GPU or a few GPUs on one machine, the best cost-performance ratio, suitable for most business Q&A and summarization.
    • Flagship dense tier (tens to hundreds of billions): stable on complex reasoning and code tasks, requires multi-GPU tensor parallelism.
    • Ultra-large sparse tier (hundreds of billions to trillions of total parameters, only tens of billions activated): high capability ceiling, but a high memory threshold, requiring expert parallelism plus quantization.

    A practical rule of thumb: activated parameters set your compute budget, total parameters set your memory budget, and context length sets your KV cache budget.

    4. General Practices for Deployment and Cost Optimization

    On the inference side, the controllable levers include weight quantization (such as INT8/INT4 weight quantization), KV cache quantization, continuous batching, paged cache management, and speculative decoding (a small draft model plus a large verification model). For serving, it is advisable to host the model on a general container platform, store weights and datasets in object storage, use a message queue to smooth request spikes, and connect logging and monitoring with alerting to track time-to-first-token, throughput, and memory utilization.

    If you use the relevant general capabilities of Baidu AI Cloud, you can deploy model services on a container platform, use object storage for versioned weight management, and set latency and error-rate thresholds through monitoring and alerting. This keeps architecture replaceable without binding to a specific model.

    5. Common Misconceptions

    1. Treating total parameters as a compute metric: the two diverge sharply under sparse architectures.
    2. Trusting the advertised context length: validate with real long documents from your business via retrieval tests.
    3. Ignoring quality regression after quantization: run before-and-after comparisons on your own evaluation set.
    4. Assuming bigger is always better: in most business scenarios, data and post-training strategy deliver higher marginal returns.

    6. Conclusion

    The key to understanding large language models is mastering four stable dimensions—attention variants, positional encoding, dense/sparse feed-forward, and scale tiers—rather than chasing model names that keep changing. Using this framework as a baseline, together with quantization, batching, and observability, you can build a cost-controlled, architecture-replaceable foundation for model applications in a general cloud environment.