LLM Architecture Explained: From Scaling Laws to Sparse Mixture-of-Experts

    This article provides a structured framework for understanding large language model architecture and cost. It examines scaling laws and resource allocation, the differences between dense models and Mixture-of-Experts, fine-grained and shared expert designs, key MoE training challenges, attention cache optimization, post-training, and practical evaluation criteria for developers and enterprises.

    1. Understanding LLMs Starts with Three Separate Questions

    When developers encounter a new large language model, they usually ask three questions: How large is the model? How capable is it? How expensive is it to run? These questions are not equivalent, and a single parameter count cannot answer all of them.

    Parameter scale describes the model’s learnable capacity. Actual capability is also shaped by training data, optimization methods, and post-training procedures. Runtime cost depends on how many parameters are activated per computation, context length, memory usage, and hardware utilization. A sparse model with a larger total parameter count may use less computation per token than a smaller dense model, but it may still require more devices to store all weights.

    Therefore, analyzing a model’s technical approach should follow this chain:

    Data and compute budget → architecture design → training strategy → inference mechanism → application performance.

    This is more valuable than listing parameters by version. It explains why a model adopts a particular design and helps enterprises determine whether an innovation reduces training cost, lowers inference memory usage, or improves performance on specific tasks.

    2. Scaling Laws: What Really Needs Optimization Is Resource Allocation

    Scaling laws refer to the fit between model loss and parameter count, training data volume, and compute under certain conditions and ranges. Their engineering value is to help teams estimate how much benefit additional resources may bring and how resources should be allocated.

    However, these laws are not universal formulas independent of data and training conditions. Data repetition, noise ratio, domain coverage, text quality, and training stability can all affect fit results.

    For example, continuing to add large amounts of low-quality text increases the number of training tokens but may not produce corresponding capability gains. The model may also spend more computation learning repeated patterns, incorrect content, or distributions that do not match the target task.

    Therefore, when discussing scaling laws, first clarify the data, model structure, training objective, and budget range used in the experiments, then discuss whether the conclusions can be transferred.

    2.2 “Scaling the Model” and “Adding Data” Require Joint Trade-offs

    Under common training settings for dense models, training compute can be roughly expressed as:

    Training compute ≈ constant factor × parameter count × training tokens.

    This is an approximate relationship for budget planning. It does not include all engineering overhead and cannot be directly applied to every sparse architecture.

    Under a fixed budget, increasing model size usually means reducing the amount of trainable data; increasing data may require reducing model size. The two must be balanced rather than assuming one is always more worthy of investment.

    A more reliable practice is:

    • First clean, deduplicate, and stratify data by quality;
    • Run multiple small-scale experiments to observe how loss changes with model scale and data volume;
    • Estimate the returns of different resource allocation plans;
    • Consider deployment costs after training is complete.

    It is especially important to distinguish “compute-optimal training” from “optimal over the full lifecycle.” If a model will provide high-frequency service for a long time, a smaller model trained more thoroughly may reduce cumulative inference costs. If the goal is to explore a higher capability ceiling, a larger model capacity and higher deployment overhead may be acceptable.

    2.3 Data Quality Cannot Be Determined by a Single Score

    High-quality data does not mean keeping only fluent text. Data value varies by task.

    General knowledge question answering requires coverage and factual reliability; code understanding requires structurally correct and semantically clear code materials; mathematical reasoning requires verifiable derivations; enterprise applications also require professional terminology and real workflows.

    Data governance should therefore consider accuracy, duplication rate, domain proportions, difficulty distribution, and compliance requirements. Over-filtering may remove rare but valuable information; pursuing quantity alone can introduce large amounts of redundancy and noise.

    3. Dense Models and Mixture-of-Experts: Capacity and Computation Begin to Separate

    3.1 Basic Characteristics of Dense Models

    A dense model typically uses the corresponding parameters in each layer to process every token. Its execution path is relatively regular, which simplifies computation organization and deployment, but as parameter scale grows, per-inference computation and weight access costs often increase as well.

    This raises a natural question: Can we increase the model’s knowledge capacity without using all parameters for every token?

    Mixture-of-Experts architecture is a representative approach to this idea.

    3.2 Basic Mechanism of Mixture-of-Experts

    Mixture-of-Experts usually replaces part of the feed-forward network with multiple expert networks, then uses a router to select a small number of experts for each token. Other modules such as attention may still use dense computation, so “sparse” does not mean the entire model executes only a small number of parameters.

    This process can be described with a schematic expression:

    Output = weighted combination of the outputs of several selected experts.

    The router computes expert scores based on the current hidden state, selects several experts with higher scores, and combines their outputs.

    When understanding this architecture, it is essential to distinguish:

    • Total parameter count: all parameters stored by the model, affecting weight storage and deployment resource requirements.
    • Activated parameter count: parameters that actually participate in computation when processing one token, affecting computational overhead.
    • Actual serving cost: also includes communication, scheduling, memory access, request organization, and other overhead.

    Therefore, “many total parameters but fewer activated parameters” does not automatically mean low latency, nor does it mean the model can easily run on a single device.

    4. Fine-Grained Experts: More Flexible Routing Combinations

    4.1 Why a Small Number of Large Experts May Be Suboptimal

    If an expert network is very large, it may handle multiple types of feature processing at the same time. Multiple experts may also learn similar patterns redundantly, leaving parameter capacity underused.

    Note that “expert” here refers to a subnetwork in the architecture, not a manually designated domain knowledge base. Even if an expert is more sensitive to certain inputs, it cannot be directly equated with a “math expert” or “legal expert.” Actual specialization requires statistical analysis and experimental validation.

    4.2 Fine-Grained Partitioning Improves the Organization of Computation

    The idea behind fine-grained experts is to split larger experts into more smaller experts and appropriately increase the number of experts selected per token.

    When other conditions are approximately equal and the total size of activated experts is roughly comparable, this design can provide more routing combinations. The model does not have to make coarse-grained choices from only a few large modules; it can combine multiple small modules to process different input features.

    Potential benefits include:

    • Reducing the mixed functions that a single expert must handle;
    • Giving the router a finer selection space;
    • Improving parameter utilization under a controlled compute budget.

    These are design motivations, not guaranteed outcomes. More experts make routing and communication organization more complex, and individual compute tasks may become smaller, reducing hardware utilization. Actual results need to be evaluated together with expert width, selection count, batch size, and parallelism strategy.

    5. Shared Experts: Separating Common Computation from Selective Computation

    With routed experts alone, different experts may repeatedly learn common language patterns. The role of shared experts is to let some experts always participate in computation, providing common feature transformations for different tokens.

    The structure can be summarized as:

    Output = shared expert output + outputs of experts selected by routing.

    The shared part handles general processing, while the routed part performs selective computation based on the input. This can alleviate the problem of multiple routed experts duplicating the same functions.

    However, “shared experts handle common knowledge” is an explanation for intuition, not a strict knowledge partition. Model knowledge is usually distributed across attention, feed-forward networks, and other parameters, and training does not guarantee that all common knowledge exists only in shared experts.

    At the same time, shared experts add fixed computation. Design requires balancing shared capacity and routed capacity: if the shared portion is too large, it may weaken the benefits of sparse computation; if too small, it may not form valuable common representations.

    6. Three Key Challenges in Mixture-of-Experts Training

    6.1 Load Balancing

    Routing may consistently favor a small number of experts, overloading them while other experts receive insufficient training. This affects both model capacity utilization and distributed execution, causing waiting and idle resources.

    Common responses include load-balancing constraints, capacity control, and adjustments to routing scores or assignment strategies. Different methods have different costs. The goal should not be uniform assignment alone; routing must also retain its ability to respond to input differences.

    6.2 Communication Overhead

    When experts are distributed across multiple devices, token representations need to be sent to the locations of the corresponding experts, and results must then be collected. The model therefore becomes not only a computation problem but also a communication and scheduling problem.

    If network bandwidth is insufficient, assignment is too scattered, or the amount of data sent each time is too small, theoretical compute savings may be offset by communication overhead.

    Engineering optimization needs to address expert placement, batching, communication-compute overlap, and device memory layout together, rather than only changing the number of experts.

    6.3 Training Stability

    Routing decisions affect which experts receive gradients, and expert states in turn affect subsequent routing, creating dynamic feedback.

    If training quickly favors a few experts early on, specialization may become imbalanced; if routing changes too sharply, the optimization process may become unstable.

    Therefore, training loss, expert utilization, gradient state, and communication load should be monitored together. Looking only at overall loss often fails to reveal abnormalities in individual experts in time.

    7. Attention Cache: Another Important Efficiency Path

    Understanding model cost requires looking beyond expert networks.

    Autoregressive generation stores the keys and values corresponding to historical tokens to avoid recomputing the full history for each generation step. As context length and concurrent requests increase, this cache can become a major source of memory usage.

    General optimization directions include reducing the key-value information that must be stored, sharing some representations, using low-dimensional compressed representations, and optimizing cache precision and memory management.

    However, these optimizations address different problems from Mixture-of-Experts:

    • Mixture-of-Experts mainly adjusts the capacity and activation pattern of feed-forward computation;
    • Cache optimization mainly reduces the cost of storing and accessing historical information;
    • Long-context inference is also affected by attention computation, batching, and bandwidth.

    The two can be combined, but any compression method must be checked for accuracy, numerical stability, and implementation complexity. It should not be assumed that model behavior remains exactly the same after the cache is reduced.

    8. Architecture Is Not Final Capability; Post-Training Also Matters

    Pretraining mainly teaches the model language patterns and broad knowledge. For real applications, supervised fine-tuning, preference optimization, or feedback-based training is often needed to improve instruction following, task completion, and response consistency.

    Therefore, when comparing models, distinguish between base models and interaction-oriented models. The same architecture with different data and post-training procedures may produce noticeably different usage performance.

    In addition, a longer generation process does not necessarily indicate stronger reasoning. Effective evaluation should focus on answer correctness, process verifiability, and the time and compute cost required to obtain the result, rather than output length alone.

    9. How Developers and Enterprises Should Evaluate Models

    9.1 First Build a Real Task Set

    Evaluation should cover actual workloads, such as professional knowledge question answering, document information extraction, content generation under complex constraints, and business text classification.

    Each task type needs clear scoring rules. Factual questions should check evidence support; structured tasks should check field completeness; code-related tasks should use executable tests where possible, rather than judging quality only by fluency.

    9.2 Observe Quality, Latency, and Throughput Together

    Time to first output, sustained generation speed, concurrent throughput, and long-context performance reflect different capabilities.

    Average latency can also mask tail latency during peak periods. For interactive systems, focus on user waiting time; for batch systems, focus more on the amount of work completed per unit time.

    9.3 Judge Architecture Value with Full Cost

    Actual cost includes not only computation for a single generation but also weight residency, cache memory, inter-device communication, redundant deployment, and operations and maintenance.

    Sparse models may save some computation while increasing storage and scheduling requirements. Whether they are cost-effective should be determined by stress testing on target hardware and realistic request distributions, not inferred directly from total or activated parameter counts.

    9.4 Include Reliability in Launch Criteria

    Enterprise applications should also check model behavior when information is insufficient, questions are ambiguous, and inputs are noisy. For tasks requiring factual grounding, retrieval and source verification can be combined; for high-risk operations, rule checks, access controls, and human confirmation should be added.

    Architecture optimization improves capability or efficiency boundaries; it does not automatically eliminate incorrect answers and authorization risks.

    10. Conclusion: Understanding Model Evolution Through Technical Causality

    The evolution of large language models is not simply about making parameters larger. It is about continuously reallocating resources among data, capacity, computation, and serving cost.

    Scaling laws help determine how to invest training budgets; dense and sparse architectures determine how parameters participate in computation; fine-grained experts add combination flexibility; shared experts attempt to reduce redundant learning; cache optimization alleviates memory pressure in long contexts; and post-training turns base capabilities into more usable task behavior.

    When reading technical materials, always ask three questions: What bottleneck does this design address, what cost does it pay, and does it bring verifiable benefits in real business environments? Building this judgment framework helps avoid being misled by parameter scale and single benchmark results, and supports a complete understanding of model capability and engineering value.