Modern LLM Architecture, Parameter Scale, and Model Selection Practices

    This article provides a technical overview of modern large language model (LLM) design and selection. It covers the Decoder-only Transformer architecture and its main components, distinguishes total, active, and trainable parameters, explains how model matrices address different capability, cost, latency, and context requirements, and discusses KV cache, parallelism, quantization, memory estimation, and evaluation practices for deployment.

    Modern large language models (LLMs) are typically implemented as autoregressive Decoder-only Transformers. Model families and versions can be abstracted into general technical questions: What structural components make up a model? How is parameter scale defined? How does a version matrix serve different business scenarios? How should memory and cost be estimated for engineering deployment? The following sections address these questions across architecture, parameters, matrix design, engineering trade-offs, and model selection and evaluation.

    1. Mainstream Architecture: Core Components of a Decoder-only Transformer

    Most modern LLMs use a Decoder-only architecture, trained to predict the next token given the preceding context. The core stacked layers usually contain the following components:

    1. Token embeddings and positional encoding: Input tokens are mapped to dense vectors, and positional information is injected. A common approach is rotary position embedding (RoPE) and its extrapolation or interpolation variants, which support longer contexts. Positional encoding design directly affects long-sequence modeling capability and inference stability.
    2. Self-attention layers: Queries, keys, and values are used to compute dependencies between tokens. Multi-head attention (MHA) has strong expressive capability but incurs high KV cache overhead. Multi-query attention (MQA) and grouped-query attention (GQA) reduce inference memory and bandwidth pressure by sharing key-value heads, and are common engineering compromises today.
    3. Feed-forward network (FFN): Usually composed of linear transformations and activation functions. Gated activations such as SwiGLU achieve a good balance between expressive capability and computational efficiency. The FFN is one of the main sources of parameters and a key location where dense models differ from sparse expert models.
    4. Normalization and residual connections: Pre-Norm with RMSNorm or LayerNorm is common and helps stabilize deep training. Residual connections ensure gradient propagation. For deep stacking, initialization, learning rate, and numerical precision also require attention.
    5. Output layer: Maps hidden states to the vocabulary dimension and may share weights with the embedding layer. During inference, sampling strategies, temperature, top-k/top-p, and related controls determine generation behavior.

    It is important to note that architecture selection is not about choosing the most complex option. It is jointly determined by training data scale, context length, inference cost, and hardware topology. Dense models activate all parameters for each token, resulting in a simple structure and stable inference path. Sparse expert models (MoE) route each token to a subset of experts, expanding total parameter capacity while controlling per-token computation, but they introduce challenges such as load balancing, expert-parallel communication, and routing stability.

    2. Parameter Scale: Total Parameters, Active Parameters, and Compute Cost

    When discussing “how large the parameter scale is,” three concepts must be distinguished:

    • Total parameters: The total amount of model weights, which determines storage footprint and the upper bound of model capacity.
    • Active parameters: The parameters actually involved in the forward computation for a single token, which directly affect inference compute.
    • Trainable parameters: The parameters involved in gradient updates during training. These are usually close to total parameters, but frozen layers, adapters, and similar techniques can change the statistical basis.

    For a dense model, parameter count can be roughly understood as: embedding layer parameters + number of layers × (attention parameters + FFN parameters) + output layer parameters. An MoE model usually contains shared experts or shared layers plus multiple routed experts. Total parameters are approximately the shared part plus all expert parameters, while active parameters are approximately the shared part plus the top-k expert parameters. Therefore, “a large total parameter count” does not mean “per-token computation is proportionally large,” but memory capacity is still constrained by total parameters.

    The relationship between parameter scale and capability is not simply linear. Data quality, number of training tokens, data mixture, post-training alignment, context length, and inference strategy all significantly affect final performance. Scaling laws commonly used in the industry describe the relationship between loss and parameter count, data volume, and compute, but their premise is sufficient data and stable training. Practical model selection should not rely only on parameter numbers; it should also consider active parameters, context cost, throughput and latency, and task fit.

    3. Design Logic of a Model Family Matrix

    From a general product matrix perspective, a model family is usually tiered by capability, cost, latency, and context length—for example, a high-performance flagship version, a balanced version, a lightweight fast version, a long-context version, or a version optimized for high throughput. Multiple series and versions essentially reflect this matrix design: different versions cover different business scenarios through parameter scale, sparsity ratio, training data mixture, post-training strategy, and inference optimization.

    1. High-performance tier: Usually uses larger total parameters or higher sparse capacity, emphasizing complex reasoning, long-document understanding, and multitask generalization, but with higher per-inference cost. It is suitable for offline batch processing, high-value tasks, or use as the “strong model” in a routing setup.
    2. Balanced tier: Strikes a trade-off among capability, latency, and cost, and is suitable for most online businesses. Its active parameters and KV cache size need to match the SLA, and throughput is usually improved through batching, quantization, and caching strategies.
    3. Lightweight fast tier: Has a smaller parameter scale or a higher degree of quantization, with low latency and low unit cost. It is suitable for classification, extraction, summarization, intent recognition, draft generation, and similar tasks, and can also serve as a pre-filter for larger models.
    4. Long-context/high-speed version: Supports longer inputs or higher concurrency through attention optimization, positional extrapolation, KV cache management, and parallelism strategies. Long context depends not only on positional encoding, but also on training data length distribution, retrieval augmentation, and cache memory limits.

    Version iteration usually focuses on data mixture, training stability, alignment quality, tool calling and structured output, inference kernel optimization, and context extension. When selecting models, enterprises should treat a “version number” as an identifier of capability and cost configuration rather than a simple new-versus-old relationship; actual task evaluation and stress test results should be the basis.

    4. Key Engineering Trade-offs: Attention, KV Cache, and Parallel Deployment

    The two major costs during inference come from weight memory and KV cache. KV cache grows with the number of layers, batch size, sequence length, number of KV heads, and per-head dimension. GQA/MQA can significantly reduce the number of KV heads, thereby lowering memory and bandwidth pressure under long contexts and high concurrency. General techniques such as paged KV cache management, continuous batching, and prefix caching can improve memory utilization and throughput, but they need to work with scheduling policies.

    Training and inference also involve data parallelism, tensor parallelism, pipeline parallelism, expert parallelism, and sequence parallelism. Dense models commonly use tensor parallelism and pipeline parallelism to split layers and matrices. MoE models also require expert parallelism and routing load balancing, making communication overhead more complex. For quantization, INT8/INT4 weight, activation, and KV quantization can reduce memory usage and bandwidth, but accuracy loss must be evaluated, especially for long-context, mathematical reasoning, and structured output tasks.

    In general cloud environments, generic categories such as training platforms, inference services, object storage, logging services, and monitoring and alerting can support model training, deployment, and observability workflows. Specific configurations should be based on actual stress testing, cost budgets, and compliance requirements.

    5. Parameter and Memory Estimation Practice (Illustrative)

    The following pseudocode only demonstrates estimation formulas. Variable values do not represent any real product configuration. Weight memory is approximately parameter count multiplied by bytes per parameter. KV cache must be estimated according to the number of layers, batch size, sequence length, number of KV heads, and head dimension.

    1. # Rough inference memory estimation for a dense model (weights and KV cache only)
    2. def dense_memory_gb(params_b, bytes_per_param=2,
    3. layers=32, kv_heads=8, head_dim=128,
    4. batch=1, seq_len=4096, kv_bytes=2):
    5. weights_gb = params_b * 1e9 * bytes_per_param / (1024**3)
    6. kv_gb = (2 * layers * batch * seq_len *
    7. kv_heads * head_dim * kv_bytes) / (1024**3)
    8. return weights_gb, kv_gb
    1. # Illustrative relationship for MoE active parameters
    2. def moe_active_params(shared_b, experts, top_k, expert_b):
    3. total_b = shared_b + experts * expert_b
    4. active_b = shared_b + top_k * expert_b
    5. return total_b, active_b

    Estimates should also include activation temporary areas, communication buffers, framework overhead, and safety margins. In production, stress testing should be used to determine maximum concurrency, P95 latency, and memory watermark, and then batch size, quantization strategy, and model routing rules can be decided.

    6. Model Selection and Evaluation Methods

    It is recommended to build a model selection framework around the following dimensions:

    1. Task complexity: Prefer lightweight models for simple extraction or classification; use high-performance tiers or routing combinations for complex reasoning and long-document analysis.
    2. Context length: Evaluate the real input distribution, KV cache cost, and long-document recall quality, rather than only the maximum context claim.
    3. SLA and throughput: Focus on P95 latency, concurrency capability, time to first token, output token rate, and error rate.
    4. Cost structure: Consider weight memory, active parameters, KV cache, batching efficiency, and quantization benefits together.
    5. Evaluation loop: Use domain test sets, long-context sets, robustness sets, and safety sets offline; run small-traffic A/B tests, model routing, and human review online.
    6. Observability and governance: Record request logs, token consumption, latency, failure rate, and output quality, and establish version rollback and rate-limiting mechanisms.

    7. Conclusion

    The main structure of modern large language models remains the Decoder-only Transformer, but engineering differences are concentrated in attention variants, normalization and activation, dense versus sparse parameter organization, long context, and inference optimization. Parameter scale should be assessed in terms of both total parameters and active parameters. A model family matrix covers different scenarios through high-performance, balanced, lightweight, and long-context tiers. For enterprise deployment, decisions should be based on real task evaluation, memory estimation, and SLA stress testing rather than parameter numbers alone.