Understanding Large Language Model Architecture and Parameter Scale

    This article breaks down the two main axes for evaluating foundation models: network architecture and parameter scale. It explains key concepts such as total parameters, activated parameters, and effective capacity, then reviews mainstream design choices including dense versus sparse mixture-of-experts layers, attention optimizations like GQA and sliding windows, positional encoding for long context, and normalization and activation functions. It also outlines parameter scale tiers, a constraint-driven selection process, and the coordination between training and inference. A final checklist highlights common misconceptions and the metrics to validate before deployment.

    1. Why Architecture and Parameter Scale Are the Two Main Axes

    When evaluating a foundation model in engineering practice, the first two things to confirm are what network architecture it uses and what order of magnitude its parameter count sits at. Architecture determines the shape of its capabilities, such as how long context is handled, the sparse activation ratio, and attention complexity. Parameter scale determines the ceiling of its capabilities and its cost curve. Together they drive memory footprint, throughput, time to first token, and cost per inference.

    Three concepts are often confused and need to be separated first:

    • Total parameters: the sum of all learnable parameters in the weight matrices, which sets the lower bound for storage and GPU memory.
    • Activated parameters: the parameters that actually participate in a single forward pass, far smaller than the total in sparse models.
    • Effective capacity: the portion that genuinely converts into capability given a fixed dataset and training budget, usually smaller than the nominal capacity.

    2. Breaking Down Mainstream Architecture Paradigms

    2.1 Dense Feed-Forward and Sparse Mixture of Experts

    In a dense architecture, every token passes through all feed-forward layers. It is simple to implement, with predictable memory and compute, and suits small to medium scale as well as on-device deployment. Sparse mixture of experts (MoE) replaces the feed-forward layer with multiple expert networks and a routing gate, where each token activates only the Top-K experts. This is a compromise between a very large total parameter count and a controllable per-token compute cost.

    1. # Illustration: a sparse feed-forward layer with Top-2 routing
    2. logits = router(x) # [batch*seq, num_experts]
    3. topk_val, topk_idx = logits.topk(2, dim=-1)
    4. weights = softmax(topk_val, dim=-1)
    5. y = sum(weights[i] * expert[topk_idx[i]](x) for i in range(2))

    The engineering focus is load balancing: routing collapse overloads a few experts while leaving the rest idle. Common practices include an auxiliary balancing loss, a capacity factor, and dropping strategies. In distributed training, expert parallelism splits different experts across devices, with All-to-All communication handling token dispatch and collection.

    2.2 Attention Optimization Paths

    The complexity of standard multi-head self-attention grows quadratically with sequence length. Layered optimizations widely used in the industry include: grouped-query attention (GQA) and multi-query attention (MQA) to compress the key-value cache; sliding windows and local attention to limit the receptive field; linear attention and gated linear unit style structures to reduce complexity; and sparse or block attention, which splits global interaction into fine-grained within-block processing plus between-block summaries.

    For inference serving, the key-value cache (KV Cache) is often the main consumer of GPU memory. Its size is approximately 2 × num_layers × num_kv_heads × head_dim × seq_len × batch × bytes_per_value. Reducing the number of KV heads or using a low-precision cache is therefore a direct way to increase concurrency.

    2.3 Positional Encoding and Long-Context Extrapolation

    Rotary position embedding (RoPE) injects relative position information through complex rotation. Combined with frequency scaling, position interpolation, or segmented extrapolation, it can keep performance outside the training length at a reasonable level. Long-context capability is not determined by positional encoding alone; it also depends on data construction (long document concatenation, retrieval-style pretraining) and attention implementation (chunked prefill, prefix reuse).

    2.4 Normalization, Residuals, and Activation Functions

    The Pre-Norm residual structure has become the de facto standard, paired with RMSNorm to reduce compute overhead. Feed-forward layers commonly use gated activations such as the SwiGLU family to improve gradients and representational efficiency. These details may look minor, but they directly affect the stability and convergence speed of large-scale training.

    3. Parameter Scale Tiers and Selection Logic

    The industry roughly divides scale into tiers: below one billion (on-device and specialized small models), one billion to tens of billions (high-concurrency general scenarios), tens of billions to hundreds of billions (complex reasoning and code), and above hundreds of billions (frontier capability exploration, mostly sparse architectures). The gains from increasing scale are not linear and must be assessed alongside data quality, number of training epochs, and post-training strategy.

    Selection recommendations work backwards from constraints:

    1. Define latency and concurrency targets, then convert them into the batch size and sequence length a single GPU can serve.
    2. Estimate memory: weight memory ≈ parameter count × bytes per value, then add the KV cache and activations.
    3. Determine whether capabilities such as long context, structured output, and tool calling are required.
    4. Run small-scale controlled experiments on a unified evaluation set rather than looking only at nominal parameter counts.

    4. Coordinated Design for Training and Inference

    The pretraining stage focuses on data mixtures, learning rate schedules, and parallelism strategies (combinations of data parallelism, tensor parallelism, pipeline parallelism, and expert parallelism). The post-training stage covers supervised fine-tuning, preference alignment, and reasoning capability reinforcement, which directly affect instruction following and format stability. On the inference side, throughput is improved through continuous batching, paged cache management, quantization, and speculative decoding.

    For cloud deployment, these can be combined: a container platform to host inference services, object storage for models and datasets, a message queue to smooth request spikes, and logging plus monitoring and alerting to track latency and error rates, forming a closed loop. Baidu AI Cloud provides standardized resource and operations support for these general capabilities, making it easier for teams to focus on the model and business logic itself.

    5. Common Misconceptions and a Verification Checklist

    • Misconception one: larger total parameters are always better. Sparse models require looking at activated parameters and routing quality at the same time.
    • Misconception two: long context equals window length. Retrieval hit rate and retention of intermediate information are equally critical.
    • Misconception three: quantization is lossless. Low-bit precision brings accuracy regression and needs task-level regression validation.

    Before going live, validate peak GPU memory, time to first token, cost per token, long-text recall, structured output compliance rate, concurrency jitter, and degradation strategies. Quantifying these questions into metrics is what makes a reliable tradeoff between architectural sophistication and engineering operability possible.