Modern LLM Architecture and Parameter Scale: A Practical Guide

    This article examines modern large language model architecture and explains why parameter count alone is a poor proxy for capability, speed, or deployment cost. It covers tokenizers, embeddings and positional information, attention, feed-forward networks, and stacked Transformer layers; compares dense and mixture-of-experts models; and clarifies total versus active parameters, training versus serving memory, and the roles of pretraining, instruction tuning, and preference optimization. It also discusses long-context evaluation, reasoning cost, and a practical model-selection framework based on task-specific benchmarks, latency, cost, and stability.

    1. Why Parameter Count Alone Is Not Enough

    When people discuss large language models, “how many parameters does the model have?” is often the first question. But parameter scale is only one dimension of model capacity. It does not directly equal model quality, inference speed, or practical usability.

    A complete large language model typically includes the following core parts:

    1. Tokenizer: Converts text, code, or symbols into discrete IDs that the model can process.
    2. Token embeddings and positional representations: Map discrete IDs to continuous vectors and provide positional information to the model.
    3. Transformer backbone: Performs context modeling through multiple layers of attention mechanisms and feed-forward networks.
    4. Output layer: Converts hidden states into a probability distribution over the vocabulary.
    5. Training and inference systems: Handle data processing, parallel computation, cache management, and serving scheduling.

    Therefore, parameter scale mainly reflects the model’s “learnable capacity.” Final performance is also affected by training data quality, training objectives, data mix, optimization methods, context window, alignment strategy, inference configuration, and other factors.

    For example, a model with more parameters may not outperform a smaller model that was trained more thoroughly if its training data contains heavy noise or severe duplication. Conversely, some models have a very large total parameter count but activate only a subset of parameters during each inference pass, so their actual compute cost may be lower than that of a dense model of comparable scale.


    2. Basic Structure of Modern Large Language Models

    2.1 Tokenizer: The First Step for Text Entering the Model

    Models cannot directly understand natural language text. They must first split text into tokens. A token can be a single Chinese character, a word, an English fragment, a punctuation mark, or part of a character sequence in code.

    Tokenization affects several aspects:

    • The number of tokens corresponding to the same text;
    • The actual content that can fit within the context window;
    • Compute cost during training and inference;
    • Efficiency in handling Chinese, English, code, and mathematical expressions.

    If a tokenizer encodes many common words as shorter sequences, the model can process more content within the same context length. Conversely, if code symbols or Chinese text are split too fragmentally, the model needs to consume more positions to express the same information.

    Therefore, when comparing context lengths across models, it is not enough to look only at the nominal number. Tokenizer differences must also be considered.

    2.2 Token Embeddings and Positional Information

    The tokenizer outputs discrete IDs. The model must convert them into high-dimensional vectors through an embedding layer. This process can be understood as mapping each token into a continuous space so that the model can learn relationships between words through vector operations.

    In addition, the model needs to know the order of tokens. “The user modified the order” and “the order modified the user” have completely different meanings. Modern models usually adopt some form of positional encoding mechanism to integrate positional information into attention computation, allowing the model to recognize relative or absolute positional relationships between tokens.

    The design of positional encoding affects:

    • Position discrimination in long texts;
    • Extrapolation performance on very long contexts;
    • Alignment between training length and inference length;
    • Stability of attention computation.

    2.3 Attention Mechanism: Understanding Contextual Relationships

    Self-attention is the core of modern large language models. For each position in the input sequence, the model calculates its degree of association with other positions and then aggregates contextual information according to those associations.

    This can be simplified as:

    1. Attention(Q, K, V) = softmax(QKᵀ / √d) V

    Where:

    • Q represents the query vector;
    • K represents the key vector;
    • V represents the value vector;
    • d represents the vector dimension.

    The attention mechanism allows the model to dynamically select important information according to the current task. For example, when generating code, the model may focus on function definitions, variable declarations, and previously appearing exception-handling logic. When analyzing a long document, it needs to locate paragraphs relevant to the question.

    However, the compute cost of standard attention grows rapidly with sequence length. To reduce long-context inference cost, engineering approaches often reduce the size of the key-value cache, use chunked computation, sparse attention, or sliding windows.

    2.4 Feed-Forward Networks: Carrying Much of the Knowledge Transformation

    Each Transformer layer usually also contains a feed-forward network. It applies nonlinear transformations to the attention output, enhancing the model’s expressive capability.

    A feed-forward network generally includes an expansion dimension, an activation function, and a dimensionality reduction process. Although the attention mechanism establishes connections between different positions, the feed-forward network often carries much of the knowledge storage and feature transformation work.

    In mixture-of-experts architectures, the feed-forward network is often split into multiple expert modules, and a router selects a small number of experts to participate in computation based on the input content.

    2.5 Stacking Layers to Form a Deep Model

    A complete model is usually formed by stacking multiple Transformer modules. More layers theoretically allow more feature transformations, but training difficulty, memory requirements, and inference latency also increase.

    Key hyperparameters in model architecture include:

    • Number of layers;
    • Hidden dimension;
    • Number of attention heads;
    • Intermediate dimension of the feed-forward network;
    • Vocabulary size;
    • Maximum context length;
    • Number of experts and the number of experts activated each time.

    These parameters jointly determine the model’s total scale and compute characteristics. Model size cannot be judged by layer count or hidden dimension alone.


    3. Dense Models vs. Mixture-of-Experts Models

    3.1 Dense Models

    The defining feature of a dense model is that most parameters participate in computation as the input passes through each layer. If a model has a total of 10 billion parameters, one inference pass typically uses close to that scale.

    Advantages include:

    • Relatively simple structure;
    • Mature training and deployment workflows;
    • Relatively stable inference behavior;
    • Hardware and parallelism requirements that are easier to understand.

    The disadvantage is higher compute cost. As model scale increases, every input token must pass through the full network, so inference throughput and memory pressure rise significantly.

    3.2 Mixture-of-Experts Models

    A mixture-of-experts model sets up multiple feed-forward experts in the network and uses a router to select a subset of them for each token. For example, a model may have a total parameter count of tens of billions or more, but each token activates only some of the experts.

    This architecture requires distinguishing two concepts:

    • Total parameter count: The sum of all experts and shared modules.
    • Active parameter count: The number of parameters that actually participate in computation during one forward pass.

    The advantage of mixture-of-experts models is that they can expand total capacity while controlling per-inference computation. They are suitable for scenarios that pursue high model capacity while hoping to reduce per-token compute cost.

    However, they also introduce new engineering challenges:

    • The router needs to achieve load balancing as much as possible;
    • Communication overhead may occur between different experts;
    • Expert parameters need to be distributed across different devices;
    • Some experts may be underutilized during small-batch inference;
    • Parallel strategies for training and deployment are more complex.

    Therefore, it cannot simply be assumed that a mixture-of-experts model is always faster than a dense model. Final speed also depends on hardware interconnect, batch size, expert distribution, sequence length, and serving scheduling.


    4. How to Accurately Understand “Parameter Scale”

    4.1 Total Parameter Count Is Not the Same as Inference Cost

    For dense models, total parameter count usually reflects the compute scale of a single inference pass reasonably well. For mixture-of-experts models, both total parameter count and active parameter count must be examined.

    In addition, inference cost is affected by the following factors:

    • Number of input and output tokens;
    • Context length;
    • Attention cache size;
    • Batch concurrency;
    • Precision type;
    • Whether quantization is enabled;
    • Whether speculative decoding is used;
    • Memory bandwidth of GPUs or other accelerators.

    For example, when the input is very long, the attention cache may become the main memory overhead. When the output is long, the computation time for token-by-token generation becomes the main bottleneck.

    4.2 Parameter Scale and Capability Are Not Linear

    Model capability usually does not grow simply linearly with parameter count. As parameters increase, a model may gain stronger knowledge representation and reasoning ability, but the benefit is limited by data scale, data quality, and training methods.

    If training data is insufficient, too many parameters may lead to low utilization. If data quality is poor, increasing model size can only amplify noise learning. For specialized domains such as code, mathematics, law, or healthcare, dedicated data and training strategies are needed rather than simply adding parameters.

    4.3 Distinguish Training Parameters from Serving Parameters

    In actual deployment, several types of scale also need attention:

    • Raw weight size;
    • Weight size after quantization;
    • Runtime cache size;
    • Activation memory usage;
    • Number of parallel replicas;
    • Additional overhead from the serving framework.

    Take low-precision inference as an example. Weights can be converted from high-precision formats to lower-bit representations, reducing memory usage. But quantization may affect accuracy, especially in mathematical computation, code generation, and long-text tasks. Therefore, quantization needs to be validated across quality, memory, and speed rather than blindly pursuing lower bit widths.


    5. Main Sources of Model Capability

    5.1 Pretraining

    The pretraining stage usually uses large-scale text, code, and structured data to help the model learn language patterns, factual associations, expression styles, and basic reasoning patterns.

    The key to pretraining data is not only quantity but also:

    • Deduplication quality;
    • Diversity of data sources;
    • Filtering of low-quality content;
    • Language and domain distribution;
    • Ratio of code to natural language;
    • Data timeliness.

    High-quality data can improve the model’s knowledge density and generalization ability, while duplicated or contaminated data may reduce training efficiency.

    5.2 Instruction Tuning

    Pretrained models are usually good at continuation but may not accurately understand user intent. Instruction tuning uses samples such as question answering, task descriptions, code generation, summarization, and classification to help the model learn to complete tasks according to instructions.

    Instruction tuning mainly improves:

    • Instruction-following ability;
    • Output format stability;
    • Multi-turn dialogue performance;
    • Adaptation to specialized tasks;
    • Refusal and safety boundaries.

    5.3 Preference Optimization and Feedback Learning

    In actual use, users often care more about whether an answer is helpful, accurate, clear, and safe. Preference optimization uses human or automatic evaluation results to make the model tend to generate responses that better meet requirements.

    This stage may affect the model’s expression style, answer length, risk control, and task completion rate. It is also necessary to prevent the model from overfitting to user preferences, giving vague answers, or avoiding complex questions.


    6. Long Context and Reasoning Ability

    6.1 Context Length Is Not Effective Memory Length

    A model supporting a longer context does not mean it can always accurately use all information within that context. As text becomes longer, the model may suffer from information dilution, weaker long-distance associations, and difficulty locating key content.

    When evaluating long-context capability, focus on:

    • Whether it can find key information scattered across a document;
    • Whether it can handle cross-chapter references;
    • Whether it can maintain consistency;
    • Whether it can distinguish similar but different facts;
    • Whether the output is disturbed by irrelevant content.

    In engineering practice, document splitting, keyword retrieval, vector retrieval, reranking, and staged summarization should usually be combined rather than stuffing all content into the context at once.

    6.2 Reasoning Ability Depends on the Computation Process

    Complex mathematics, code debugging, and multi-step planning tasks often require the model to perform more thorough intermediate analysis. Some reasoning-oriented approaches improve reliability by increasing generation steps, verifying candidate answers, or introducing tool calls.

    But the longer the reasoning process, the higher the latency and cost. Therefore, actual systems can adopt a tiered strategy based on task difficulty:

    • Use fast generation for simple question answering;
    • Enable more thorough analysis for complex problems;
    • Add rule-based validation for high-risk tasks;
    • Assign computation tasks to deterministic tools;
    • Add tests and static checks for code tasks.

    Large language models are suitable for generating candidate solutions, but critical results such as amounts, permissions, inventory, transactions, and security policies should not rely solely on model text output.


    7. Practical Methods for Model Selection

    When selecting a model, it is advisable to establish a unified evaluation set rather than comparing only public parameters. The evaluation set should cover typical tasks in real business scenarios, for example:

    1. General question answering and knowledge retrieval;
    2. Long-document summarization and information extraction;
    3. Code generation and repair;
    4. Structured data output;
    5. Multi-turn dialogue;
    6. Mathematical and logical reasoning;
    7. Content safety and sensitive information handling;
    8. High-concurrency, low-latency serving.

    Evaluation metrics may include:

    • Accuracy;
    • Completion rate;
    • Format compliance rate;
    • Time to first token;
    • Tokens generated per second;
    • Cost per request;
    • Concurrency stability;
    • Long-context recall rate;
    • Error and exception rates.

    If you use cloud infrastructure, you should also consider model serving, object storage, logging, monitoring and alerting, and container platforms to build a complete deployment path. However, selection should still be based on actual evaluation results, not model names or parameter counts alone.


    8. Conclusion

    Modern large language models are generally built on the Transformer architecture. Their core differences mainly lie in attention design, feed-forward networks, expert routing, context handling, training data, and inference strategies.

    When understanding model scale, it is necessary to consider:

    • Total parameter count;
    • Active parameter count;
    • Model layer count and hidden dimension;
    • Context length;
    • Weight precision and quantization method;
    • Inference cache and hardware usage;
    • Accuracy and latency on actual tasks.

    For developers, the most important thing is not to memorize the parameter numbers of a particular model, but to establish a verifiable judgment method: first clarify the task, then evaluate capability; first measure latency and cost, then decide on deployment; first validate performance on real data, then judge whether the model scale is appropriate. Only by combining architecture, training, inference, and business metrics can the technical value of a large language model be truly understood.