Understanding LLM Architecture and Parameter Scale: Key Factors for Capacity, Cost, and Deployment

    This article explains why both the architectural design and parameter count of modern large language models (LLMs) are critical, and how they jointly determine model capability, inference cost, and deployment feasibility. It breaks down the common decoder‑only Transformer structure, attention mechanism variants (MHA, MQA, GQA), the role of feed‑forward networks and normalization, and the distinction between total and activated parameters in mixture‑of‑experts (MoE) models. A practical KV‑cache sizing example is included to illustrate the impact of attention design on memory usage and concurrency.

    Why Structure and Parameter Scale Matter Equally

    The capability, inference cost, and deployment barrier of a large language model are primarily determined by two things: how the network organizes computation, and how many parameters it has. Parameter count defines the model’s knowledge capacity and expressive power. Architecture determines how fully each parameter is utilized in a single forward pass. The two are mutually constraining: more parameters increase memory and compute demands; a more efficient architecture delivers stronger capability at the same cost.

    Therefore, looking only at a “parameter count” number is insufficient to judge a model’s real cost and appropriate use cases. Model selection and capacity planning require an understanding of both architecture and scale.

    The Common Skeleton of Mainstream Architectures

    Most current general‑purpose LLMs adopt a decoder‑only Transformer structure. Its main components can be split into three parts:

    1. Token embedding layer: Maps discrete tokens to continuous vectors of dimension d. The number of parameters equals vocabulary size × hidden dimension.
    2. Repeated decoder layers: A stack of N layers, each containing a self‑attention sublayer and a feed‑forward sublayer, with residual connections and normalization.
    3. Output layer: Projects the final hidden state back to vocabulary dimensions to produce the probability distribution for the next token.

    During training, the model learns to predict the next token. During inference, it generates tokens autoregressively. Key hyperparameters that determine scale include the number of layers, hidden dimension, number of attention heads, feed‑forward width, and vocabulary size. Adjusting these numbers changes the parameter count accordingly.

    Evolution of Attention Mechanisms

    In standard multi‑head attention (MHA), every head has its own Query, Key, and Value projections. During inference, the model must cache the Key and Value of all previous tokens—this is called the KV cache. Its memory footprint grows linearly with sequence length and batch size, becoming especially noticeable in long‑context scenarios.

    To reduce KV‑cache overhead, two common approaches are used in practice:

    • Multi‑Query Attention (MQA): All query heads share a single set of Keys and Values. The cache is minimal, but expressiveness is somewhat reduced.
    • Grouped‑Query Attention (GQA): Query heads are divided into groups, each group sharing one set of Keys and Values. This offers a good balance between quality and memory usage and is currently the more common choice.

    The KV‑cache size can be estimated with the following formula:

    KV cache bytes = 2 × layers × KV heads × head dimension × sequence length × batch size × bytes per element

    For example: with 32 layers, 8 KV heads, a head dimension of 128, sequence length of 4096, batch size of 1, and 16‑bit floating point, the cache is approximately 512 MiB. If the number of KV heads is reduced from 32 to 8, the cache shrinks to one‑fourth of its original size. This calculation shows that attention structure design directly affects concurrency during deployment.

    Feed‑Forward Networks and Normalization

    The feed‑forward sublayer typically accounts for the majority of a model’s parameters. Modern implementations often use gated linear unit (GLU) style structures, such as SwiGLU. This architecture includes three matrices: a gating projection, an up projection, and a down projection. With similar parameter counts, this structure is more stable than the earlier two‑matrix feed‑forward design, and is therefore widely adopted.

    For normalization, RMSNorm is increasingly replacing LayerNorm. It eliminates the mean computation, reducing computational overhead while achieving similar training performance in practice. Normalization layers are usually placed before each sublayer (Pre‑Norm form), which helps stabilize training in deep networks.

    Mixture‑of‑Experts: Distinguishing Total vs. Activated Parameters

    The mixture‑of‑experts (MoE) architecture replaces the feed‑forward sublayer with multiple “expert” networks. A router selects k experts for each token to participate in the calculation. This allows the total parameter count to be large while only a small portion of experts is activated for each token.

    Two concepts need to be distinguished:

    • Total parameters: The sum of all expert weights and shared parts, which determines storage requirements.
    • Activated parameters: The parameters actually involved in a single forward pass, which approximately determines the computation per token.

    During deployment, all expert weights must be placed in memory, so memory usage is determined by the total parameter count. Inference speed is mainly influenced by the activated parameter count. When reporting model scale, both the total and activated numbers must be specified.