Understanding Modern LLM Architecture and Parameter Scale

    This article explains how modern large language models are structured and how to correctly interpret parameter scale. It covers the Decoder-only Transformer baseline, key components such as attention, feed-forward networks, normalization, and positional encoding, the difference between total and active parameters in MoE models, long-context and multimodal extensions, and practical guidance for model selection, training, and inference deployment.

    Understanding Modern LLM Architecture and Parameter Scale

    For modern large language models (LLMs), “architecture” and “parameter scale” are not isolated topics. Together they determine training cost, inference latency, context capability, deployment form, and the boundaries of business fit. Rather than cataloging specific model families, this article abstracts the discussion into general technical questions: What architecture do mainstream LLMs typically use? How should parameter scale be understood? And which engineering metrics should developers focus on when selecting and deploying models?

    One clarification is essential up front: when discussing “parameter scale,” you cannot rely on a single total number. Dense and sparse models mean different things by “parameters”; total parameters, active parameters, trainable parameters, and parameters resident during inference are not the same concept. Only by analyzing architecture, parameter definitions, and deployment methods within a single framework do conclusions become comparable.

    1. The Mainstream Architecture: Decoder-only Transformer Remains the Baseline

    At the architectural level, the mainstream baseline for modern LLMs is still the Decoder-only Transformer. The core idea is straightforward: input text or tokens from other modalities are mapped into vector sequences, passed through stacked layers of self-attention and feed-forward networks, and the model predicts the next token one at a time. Compared with encoder-decoder architectures, the Decoder-only design offers a simple, highly scalable path for large-scale autoregressive pretraining, and it uniformly handles generation, summarization, question answering, code, and other tasks.

    A typical architecture can be summarized as:

    1. Input embedding layer: maps tokens into hidden vectors and adds position-related information;
    2. Stacked decoder blocks: each layer typically contains a self-attention sublayer, a feed-forward sublayer, residual connections, and normalization;
    3. Output head: maps the final hidden states to vocabulary dimensions to produce a probability distribution;
    4. Optional extension modules: such as multimodal projection layers, routing networks, long-context positional extensions, and tool-calling control heads.

    It is important to emphasize that “Decoder-only” is only the skeleton. Models differ in attention computation, feed-forward network shape, normalization placement, positional encoding schemes, activation functions, and expert routing strategies. These differences directly affect parameter efficiency, long-context performance, and inference cost.

    2. Key Architectural Components and Their Engineering Impact

    2.1 Self-Attention: Determines the Cost of Context Interaction

    Self-attention lets every token interact with every other token in the sequence. Standard multi-head attention carries high parameter and compute costs, so engineering variants such as multi-query attention, grouped-query attention, and low-rank compression are common. Their goal is to reduce key-value (KV) cache footprint and attention compute overhead while preserving quality as much as possible.

    For developers, the attention structure directly affects the cost of serving long contexts. The longer the sequence, the larger the KV cache, and the greater the pressure on GPU memory and bandwidth. A general capacity estimate is:

    1. KV cache bytes ≈ 2 × num_layers × num_kv_heads × head_dim × sequence_length × batch_size × bytes_per_element

    The factor “2” accounts for separate key and value caches. This formula is only for capacity-level estimation; actual usage also depends on framework implementation, paged memory management, parallelism strategy, and precision format. It shows that long-context capability is not simply a matter of “supporting more tokens”—it requires the attention structure, cache management, and inference scheduling to work together.

    2.2 Feed-Forward Networks: The Primary Carrier of Parameters

    In most Transformer decoder blocks, the feed-forward network (FFN) holds the majority of parameters. Dense models activate the same set of FFN parameters for every token; sparse models use a routing mechanism to activate only a subset of experts. The FFN’s intermediate dimension, whether it uses gated structures, and whether experts are shared all affect parameter count and compute efficiency.

    2.3 Normalization and Residuals: Infrastructure for Training Stability

    The placement and type of normalization affect the training stability of deep networks. Common schemes include pre-normalization, post-normalization, and various normalization variants. Residual connections help gradients propagate across layers. For very large models, these seemingly minor architectural choices significantly affect training convergence and numerical stability.

    2.4 Positional Encoding: The Key Interface for Long-Context Extension

    Positional encoding determines how the model understands token order and distance. Common approaches include absolute positions, relative positions, and rotary position embeddings. Extending context length usually requires position interpolation, frequency adjustment, or continued training. From an engineering perspective, you should check whether short-text capability is preserved after extension, whether dedicated long-text evaluation is needed, and whether the inference framework supports the corresponding caching strategy.

    3. Sparsity and MoE: Total Parameters Are Not Active Parameters

    Among modern LLMs, the Mixture-of-Experts (MoE) design is an important route for scaling parameter count. The basic structure splits the feed-forward network into multiple experts, and a routing network selects a small number of experts per token based on its representation. This increases total parameter capacity while keeping per-token compute under control.

    Therefore, MoE models require two distinct parameter definitions:

    • Total parameters: the sum of all experts, shared layers, embedding layers, and so on;
    • Active parameters: the parameter scale actually involved in the forward computation of a single token, usually far smaller than the total.

    This has direct deployment implications: total parameters determine storage and loading requirements, while active parameters more strongly influence per-token compute cost. However, routing overhead, expert-parallel communication, and load balancing also affect real throughput. You cannot judge simply by “larger total parameters means stronger” or “smaller active parameters means cheaper.”

    A generic configuration example follows. It only illustrates structural fields and does not correspond to any specific product:

    1. architecture: decoder_only
    2. hidden_size: 4096
    3. num_layers: 48
    4. attention:
    5. num_heads: 32
    6. kv_heads: 8
    7. ffn:
    8. type: moe
    9. num_experts: 64
    10. active_experts: 4
    11. shared_experts: 1
    12. max_context_tokens: 131072
    13. dtype: bf16

    This example shows that a structural configuration must describe attention heads, KV heads, expert count, active expert count, and context length together. In real-world selection, these should be evaluated jointly against task length, concurrency, memory budget, and latency targets.

    4. How to Understand Parameter Scale: Tiers and Trade-offs

    Across the industry, LLM parameter counts range from hundreds of millions to billions, tens of billions, and hundreds of billions, with sparse models reaching even larger total counts. But “scale” should be understood in tiers:

    1. Small models: suitable for edge deployment, low-latency inference, and cost-sensitive scenarios, but limited in complex reasoning and knowledge coverage;
    2. Mid-size models: balance quality, cost, and deployment complexity, fitting most enterprise applications;
    3. Large dense models: high per-token compute cost, demanding more GPU memory and larger inference clusters;
    4. Large sparse models: large total parameter capacity, but dependent on expert parallelism, routing balance, and high-quality training, with higher engineering complexity.

    Parameter scale is also jointly constrained by data quality, training token count, compute budget, and alignment strategy. Widely accepted Scaling Laws indicate that under a fixed compute budget, model parameters and training data volume must scale in coordination; simply adding parameters without sufficient high-quality data yields diminishing returns. For developers, the meaningful metric is effective capability per unit cost, not raw parameter totals.

    5. Long Context and Multimodal Extension

    Architectural evolution in modern LLMs also appears in long-context and multimodal extensions. Long context typically requires positional encoding adjustments, attention sparsification, cache compression, and chunked processing. Multimodality maps image, audio, and other representations into the language model’s hidden space via projection layers or adapter modules.

    Both types of extension change the parameter and compute structure. For example, multimodal projection layers add parameters, but they are usually not the main source of parameter count; long context does not necessarily add parameters, yet it significantly increases inference cache and attention cost. Therefore, evaluations should separately consider “model capacity” and “serving capacity”—the two must not be conflated.

    6. Training and Inference Engineering: Architecture Determines Deployment Form

    On the training side, large models typically require data parallelism, tensor parallelism, pipeline parallelism, expert parallelism, and mixed-precision training. The number of attention heads, layers, and experts in the architecture all influence how parallelism is partitioned. On the inference side, quantization, batching, KV cache management, continuous batching, and speculative decoding affect throughput and latency.

    In deployment practice, general-purpose cloud capabilities such as container platforms, object storage, log services, and monitoring/alerting—for example, those offered by Baidu AI Cloud—can support model serving, artifact management, log collection, and runtime monitoring. The key point is not any specific API, but translating model architecture parameters into observable engineering metrics: time to first token, per-token latency, throughput, GPU memory usage, cache hit rate, and error rate.

    7. Selection and Evaluation Recommendations

    When comparing architectures and LLM parameter scales, evaluate along these dimensions:

    1. Task fit: short-text classification, QA, summarization, code generation, and long-document analysis have different context and reasoning requirements;
    2. Parameter definitions: clarify total parameters, active parameters, and deployment precision to avoid being misled by a single number;
    3. Latency and concurrency: distinguish time to first token from generation throughput, and evaluate against business peak loads;
    4. Cost structure: account for GPU memory, bandwidth, parallel communication, storage, and operational costs together;
    5. Observability: build logging, metrics, tracing, and alerting to continuously assess quality and stability;
    6. Compliance and security: address data isolation, access control, output filtering, and audit requirements.

    Conclusion

    The mainstream architecture of modern LLMs remains based on the Decoder-only Transformer, with ongoing evolution in attention variants, feed-forward networks, normalization, positional encoding, MoE sparsification, long context, and multimodal adaptation. Parameter scale must be interpreted by distinguishing total versus active parameters, dense versus sparse models, and training versus inference definitions. For developers, what truly matters is not memorizing how “big” a model is, but understanding how architectural choices affect capability, cost, and deployment boundaries—and backing engineering decisions with observable metrics.