Large Language Model Architecture and Parameter Scale Explained

    This article breaks down modern large language model architectures and parameter scales, covering the four shared components of mainstream designs, the trade-offs between dense and sparse mixture-of-experts models, common parameter tiers and what they mean for deployment, the evolution of attention and long-context techniques, and a practical framework for estimating inference cost and capacity planning. It also corrects common misconceptions so developers can make verifiable model selection and sizing decisions instead of relying on a single parameter count.

    1. Why Architecture and Parameter Scale Are the First Questions

    When developers start working with large language models, the first two questions are usually what the model looks like internally and how many parameters it has. These questions matter because they directly determine three things: the compute cost of training and inference, how memory and bandwidth are consumed, and the model’s ceiling on long-context and complex reasoning tasks.

    Parameter scale alone does not equal capability, and it does not equal cost either. What really drives deployment cost is the number of activated parameters and the compute per token, while the capability ceiling is usually shaped by data quality, training strategy, and post-training methods. For that reason, architecture and scale are discussed together in the same framework below.

    2. Four Common Components of Mainstream Architectures

    Despite vendor-specific details, most models can be abstracted into the following four parts:

    1. Tokenization and embedding layer: Splits text into subword units and maps them to vectors. Vocabulary size typically ranges from tens of thousands to over a hundred thousand, and a larger vocabulary increases the parameter share of the embedding and output layers.
    2. Stacked Transformer blocks: Each block contains normalization, an attention sublayer, a feed-forward sublayer, and residual connections. This is where most parameters and compute come from.
    3. Normalization and positional encoding schemes: Whether normalization is placed before or after the sublayers affects training stability; positional information is injected through schemes such as rotary positional encoding, combined with interpolation and extrapolation strategies to extend context.
    4. Output head and loss function: The output layer maps back to a distribution over the vocabulary. Training commonly uses cross-entropy, along with techniques such as label smoothing and sequence-level loss weighting.

    A schematic description can be written as the following pseudocode to build intuition:

    1. class Block(nn.Module):
    2. def __init__(self, d_model, n_heads):
    3. self.norm1 = RMSNorm(d_model)
    4. self.attn = Attention(d_model, n_heads) # can be replaced with grouped-query attention
    5. self.norm2 = RMSNorm(d_model)
    6. self.ffn = FFN(d_model) # dense or sparse expert routing
    7. def forward(self, x):
    8. x = x + self.attn(self.norm1(x))
    9. x = x + self.ffn(self.norm2(x))
    10. return x

    3. Dense Models vs. Sparse Mixture-of-Experts: Two Parallel Routes

    In a dense architecture, every parameter participates in the computation for every token. The advantages are stable training, simple inference implementation, and friendliness to memory bandwidth; the drawback is that compute grows linearly as parameter count increases.

    A sparse mixture-of-experts (MoE) architecture replaces the feed-forward sublayer with multiple “experts,” and a router network selects a few experts to compute each token. Its core value is having a very large total parameter count while activating only a small number of parameters per token, which yields greater model capacity at the same inference cost. Three engineering concerns stand out:

    • Routing balance: Uneven load leaves some experts overloaded and others idle, so an auxiliary balancing loss is usually introduced.
    • Communication overhead: When experts are spread across devices, all-to-all communication easily becomes the bottleneck.
    • Fine-tuning and quantization: Sparse structures are more sensitive to routing stability under very low-bit quantization.

    A simplified routing logic looks like this:

    1. logits = router(x) # [tokens, n_experts]
    2. idx = logits.topk(k=2).indices # pick 2 experts per token
    3. y = sum(expert_i(x) for i in unique(idx))

    4. Common Parameter Scale Tiers and What They Mean

    Without pointing to any specific product, the scale tiers observable in the industry fall into roughly four bands, each mapping to a different deployment shape:

    Scale tier Typical total parameter range Activation characteristics Common deployment shape
    Lightweight / on-device Up to a few billion Fully activated Single GPU or even on-device inference
    Small to mid scale A few billion to tens of billions Fully activated Single GPU to multiple GPUs on one node
    Large-scale dense Tens of billions to hundreds of billions Fully activated Multi-node, multi-GPU tensor parallelism
    Very large sparse Hundreds of billions to trillions Usually only a small fraction of total parameters Multi-node, multi-GPU plus expert parallelism

    Key takeaway: when comparing two models, look at total parameters, activated parameters, and compute per token together. Otherwise it is easy to reach the wrong conclusion. For example, a sparse model with a very high total parameter count but a low activation ratio may cost less to run than a dense model with a much smaller total parameter count.

    5. Where Attention and Context Are Heading

    Long context is a major focus of current architecture evolution. Common techniques include:

    • Grouped-query attention: Multiple query heads share a set of key-value heads, significantly reducing the size of the key-value cache.
    • Key-value cache compression and quantization: Reduces memory usage with acceptable accuracy loss.
    • Positional encoding extrapolation and interpolation: Lets a shorter training context extend to longer contexts at inference time.
    • Sparse or blockwise attention: Trades a controlled accuracy cost for lower attention complexity.

    The engineering advice is that longer context is not always better; it has to be balanced against the memory budget, time-to-first-token, and throughput targets.

    6. A Practical Framework for Inference Cost and Capacity Planning

    If an enterprise needs to evaluate and deploy models in its own environment, the following steps are a useful reference:

    1. Define business metrics: time-to-first-token, output tokens per second, concurrency, and the distribution of context lengths.
    2. Estimate memory: weight memory ≈ parameter count × bytes per parameter, then add key-value cache and activation overhead.
    3. Choose a parallelism strategy: tensor parallelism reduces per-GPU pressure, pipeline parallelism improves throughput, and expert parallelism fits sparse structures.
    4. Establish a load-test baseline: run end-to-end load tests with a realistic corpus distribution rather than relying only on theoretical compute.
    5. Improve observability: use general-purpose logging services, monitoring and alerting, and container platforms to collect latency, error rates, and resource utilization.

    For cloud deployment, teams typically combine a container platform to host inference services, object storage for models and data, a message queue to smooth request spikes, and monitoring and alerting for stability. Baidu AI Cloud offers standardized infrastructure categories for these general capabilities, so teams can integrate them freely with their own technology stack.

    7. Common Misconceptions

    • Misconception 1: Bigger is always stronger. Data mixture, number of training epochs, and post-training alignment often matter more.
    • Misconception 2: Sparse models have no compute cost. Routing and communication add overhead, so it must be measured.
    • Misconception 3: Longer context is always better. Long context brings a significant rise in memory use and latency, and there is a phenomenon of insufficient use of information in the middle.
    • Misconception 4: Quantization is lossless. Low-bit quantization requires an accuracy regression check, especially for sparse structures.

    8. Summary

    Understanding modern large language models means building knowledge in four progressive layers: architecture paradigm, scale tier, activation cost, and context strategy. Architecture determines implementation complexity, the scale tier determines the deployment shape, activated parameters determine the real cost, and the context strategy determines the boundary of task fit. With this evaluation framework, developers can make more verifiable and reproducible decisions during model selection, load testing, and capacity planning, instead of being misled by a single parameter number.