Large Language Models: From Scaling Laws to Efficient Deployment

    This article provides a technical framework for understanding large language models across data, architecture, training, inference, and application. It explains scaling laws, data quality, sparse mixture-of-experts design, routing and communication costs, KV-cache constraints, the division of labor between pretraining and post-training, and practical model evaluation for developers and enterprises. The goal is to help readers assess both model capability and system-level efficiency under real deployment constraints.

    1. Building a Complete Technical Picture of LLMs

    When discussing what a large language model can actually do, it is not enough to look only at parameter count or judge capability from a few question-and-answer examples. A more reasonable approach is to build a technical profile across five layers: data, architecture, training, inference, and application.

    Data determines what knowledge the model can access and whether that knowledge is reliable. Architecture determines how parameters are organized and how computation is allocated. Training strategy determines whether limited compute can be converted into stable capability. The inference system determines the cost and latency at which the model can provide service. Application design determines whether these capabilities can solve real business problems.

    Therefore, model development is not simply a matter of growing scale. It is a search for balance among several competing goals:

    • Improve language understanding, knowledge use, and complex task handling.
    • Achieve better results within a limited training budget.
    • Reduce computation, communication, and storage overhead during generation.
    • Maintain output reliability, service stability, and engineering maintainability.

    Understanding these goals is necessary to see the technical evolution from dense models to sparse mixture-of-experts models.

    2. Scaling Laws: More Than Adding Parameters or Piling Up Data

    2.1 Model quality is shaped by multiple factors

    Scaling laws describe empirical relationships among model parameter count, training data volume, compute budget, and training loss. Their value is to help research teams predict the potential returns from scaling training and find more reasonable ways to allocate resources.

    In a simplified analysis, the training compute of a dense model can be approximated as proportional to the product of parameter count and the number of training tokens:

    Training compute ≈ constant factor × number of parameters × number of training tokens

    This relationship is suitable for preliminary budgeting, but it is not a complete cost formula. Actual compute is also affected by sequence length, attention computation, training implementation, recomputation strategy, hardware utilization, and other factors.

    More importantly, there is a matching relationship between parameter count and data volume. A model that is too small may struggle to absorb patterns in complex data. A very large model trained on insufficient data may fail to make full use of its parameter capacity.

    Therefore, under a fixed budget, whether to expand the model or increase the data should be judged together with data distribution, data quality, training stage, and actual experimental results. The conclusion of a single experiment should not be treated as a universal law.

    2.2 Data quality changes the returns to scale

    The “quantity” of training data is not the same as the “amount of effective information.” Large amounts of repeated content, incorrect knowledge, low-quality text, and data irrelevant to the target task can reduce the return per unit of compute.

    High-quality data governance usually includes the following steps:

    • Remove duplicate or highly similar content to avoid repeatedly spending compute on the same information.
    • Filter out garbled text, structural anomalies, and clearly low-quality text.
    • Control the proportions of different languages, domains, and text types.
    • Check the risk of contamination between training data and evaluation sets.
    • Handle privacy, licensing, and sensitive information issues.

    However, data cleaning is not always better when it is stricter. Over-filtering can harm long-tail knowledge coverage and reduce the model’s ability to adapt to rare expressions, complex domains, or nonstandard text. Data governance should consider quality, diversity, and business relevance at the same time.

    2.3 Small-scale experiments are an important prerequisite for large-scale training

    Before committing large-scale resources, it is usually necessary to validate the training plan through a set of controlled experiments, including learning rate, batch size, data mix, and model depth and width.

    Experiments should control variables as much as possible and record loss curves, validation performance, training stability, and resource utilization. Otherwise, it is difficult to determine whether an improvement comes from an architecture change, a data change, or an increase in training duration.

    The practical meaning of scaling laws is not to provide a slogan that “larger models are necessarily better,” but to make resource allocation more predictable and training decisions more evidence-based.

    3. Sparse Mixture of Experts: Decoupling Model Capacity from Per-Token Compute

    3.1 The key difference between dense and sparse models

    In a dense model, each token usually passes through the full feed-forward network computation in each layer. As the number of model parameters grows, the computation required to process a single token also increases.

    A sparse mixture-of-experts model organizes part of the feed-forward network into multiple expert modules, and a router selects a subset of them for each token to participate in computation. The goal is to retain large parameter capacity while controlling the amount of computation actually used by each token.

    Three metrics need to be distinguished here:

    • Total parameter count: all parameters contained in the model.
    • Activated parameter count: the parameters actually involved in computation when processing a given token.
    • Actual inference cost: includes not only parameter computation, but also routing, communication, scheduling, and memory access overhead.

    A large total parameter count does not mean that every inference computes all parameters. A small activated parameter count does not mean that service cost is necessarily low.

    3.2 Why experts should be divided more finely

    If there are only a few large experts, each expert may learn multiple types of knowledge or processing patterns at the same time. Experts may also overlap with one another, causing the limited activated computation to be underused.

    Finer-grained expert partitioning allows the router to combine more small modules and thus provide more flexible computation paths. Under a controlled activated-compute budget, the model can try richer expert combinations.

    However, “experts” are not the same as human-defined domain departments. They do not necessarily form strict legal experts, math experts, or programming experts. They may also learn certain lexical features, semantic patterns, or intermediate representation transformations. Whether experts truly achieve specialization should be verified through routing statistics and ablation experiments, not judged by names alone.

    3.3 How shared experts reduce redundancy

    Language tasks contain many common capabilities, such as syntactic processing, common semantic relationships, and basic expression patterns. If every routed expert relearns these contents, parameter efficiency may decrease.

    Shared experts provide a division-of-labor mechanism:

    • The shared part performs computation for all tokens and handles more general representation transformations.
    • The routed part selects different experts according to the input and handles more targeted processing.

    This structure can help reduce some duplicate learning, but it does not guarantee that common knowledge and specialized knowledge can be completely separated. The size of shared experts, the number of routed experts, and how many experts are activated each time all need to be balanced through experiments.

    3.4 Sparse computation does not mean low memory usage

    This is one of the most common misunderstandings when understanding mixture-of-experts models.

    Reducing the number of activated experts mainly reduces part of the computation overhead. The expert weights of the full model still need to be stored on certain devices or storage tiers. During training, gradients, optimizer states, and intermediate activations must also be considered. During inference, weights, attention cache, and runtime buffers must be considered.

    Therefore, a sparse model may have lower per-token compute while still requiring a large total storage footprint. Whether memory is saved depends on parallel partitioning, quantization, offloading, and deployment methods. It cannot be inferred from the activated parameter count alone.

    4. Routing and Communication: Engineering Challenges of Mixture of Experts

    4.1 Load imbalance can slow down the entire system

    If the router frequently selects a small number of experts, hotspots can occur: some devices process a large number of tokens while other devices remain idle.

    This not only affects throughput but may also limit how fully experts are trained. During training, load-balancing constraints or other routing adjustment methods are usually needed to prevent selection from becoming overly concentrated.

    But balance is not the only goal. Forcing all experts to receive the same number of tokens may harm the effectiveness of routing decisions. A reasonable design needs to balance specialization, training stability, and device utilization.

    4.2 Cross-device dispatch can offset computational gains

    When different experts are deployed on different devices, token representations need to be dispatched to the target experts and gathered back after computation. This introduces cross-device communication.

    If network bandwidth is insufficient, communication batches are too small, or expert placement is unreasonable, the system may end up with “less computation but no reduction in latency.”

    Therefore, when evaluating a mixture-of-experts architecture, beyond theoretical compute, the following should also be measured:

    • Load distribution among experts.
    • Routing and dispatch time.
    • Share of cross-device communication.
    • Throughput at different concurrency levels.
    • Tail latency when long and short requests are mixed.

    Real efficiency gains come from co-optimization of architecture and the execution system.

    5. KV Cache: Another Key Cost in Long-Context Inference

    5.1 Why generation requires a cache

    During autoregressive generation, the model outputs new tokens step by step. To avoid recomputing the attention keys and values of the existing context, inference systems usually store a key-value cache.

    Cache size is generally related to the number of model layers, context length, number of key-value heads, dimension per head, number of concurrent sequences, and storage precision. Longer contexts and more concurrent requests usually mean larger cache usage.

    Therefore, even if a model’s weights can fit on a device, it does not mean that the model can support the expected long-context length and concurrency scale.

    5.2 Cache optimization must consider applicable conditions

    Common optimization ideas include reducing duplication in key-value representations, using more compact representations, lowering cache storage precision, and improving cache management.

    These methods each have boundaries:

    • Some representation compression methods depend on architecture design and cannot be directly applied to any existing model.
    • Low-precision caching requires validation of the impact of errors on long-text and complex tasks.
    • Memory management optimization can reduce waste, but it cannot eliminate the information storage requirement of the cache itself.

    Lower cache usage does not necessarily mean total latency falls by the same proportion. If the system bottleneck is in communication, sampling, or other computation stages, the gains may be limited.

    6. The Division of Labor Among Pretraining, Post-Training, and Application Augmentation

    Pretraining mainly establishes language patterns, knowledge representations, and basic task capabilities. A model with low pretraining loss does not necessarily follow business instructions stably.

    Post-training can improve response style, task following, and output behavior through instruction samples, preference feedback, or other optimization methods. But it cannot guarantee that the model is always correct, nor can it fill in all domain knowledge out of thin air.

    For enterprise applications, system-level augmentation should also be considered:

    • Provide updatable and traceable business materials through retrieval.
    • Use structured validation to check fields, formats, and business rules.
    • Set up human review for high-risk outputs.
    • Use permission controls to limit the scope of data access.
    • Set explicit authorization boundaries for the ability to execute external actions.

    Model capability, knowledge supply, and application control are different problems. Designing them in layers is usually more reliable than trying to make the model carry all responsibilities alone.

    7. How Developers and Enterprises Should Evaluate Models

    7.1 Define the task before choosing a model

    Model evaluation should start from business requirements. For example, document question answering focuses on evidence coverage and answer traceability; information extraction focuses on field accuracy; long-context analysis focuses on cross-section associations; code generation focuses on executability and safety boundaries.

    Different tasks place different requirements on models, and a single composite score should not replace all decisions.

    7.2 Build a representative test set

    The test set should include normal samples, edge cases, ambiguous inputs, and anomalous inputs, and should use authorized and de-identified real business materials where possible.

    During evaluation, prompt templates, generation length, context budget, and sampling settings need to be controlled, while observing:

    • Task completion rate and factual correctness.
    • Format compliance rate and whether refusals are reasonable.
    • Time to first token.
    • Sustained generation speed and total request latency.
    • Throughput and high-percentile latency at target concurrency.
    • Comprehensive cost per effective task.

    Among these, “effective task cost” is closer to business reality than “cost per call.” A cheap solution that often requires retries and manual correction may not have a lower overall cost.

    7.3 Validate under real deployment conditions

    Before launch, capacity testing and failure drills should be conducted to check behavior with mixed long and short requests, service scaling, timeout and retry handling, and resource shortages.

    The deployment system should also include logging, monitoring and alerting, access control, and version rollback mechanisms. After a model update, key tasks need to be revalidated to prevent capability changes from disrupting existing business workflows.

    8. Conclusion: Evaluate Capability and System Together

    The technical progress of large language models can be summarized as two interrelated routes. One improves capability through high-quality data, reasonable scale, and stable training. The other improves efficiency through sparse computation, cache optimization, and execution-system improvements.

    Scaling laws help answer “how should the training budget be allocated.” Mixture of experts helps answer “how can capacity be expanded while controlling activated computation.” Cache and communication optimization help answer “how can inference services become truly efficient.”

    For developers and enterprises, the final focus should not be a particular parameter number, but whether the model can complete tasks stably, accurately, and controllably under real constraints. Only by placing data, architecture, training, deployment, and business evaluation in the same framework can a complete technical judgment of large language models be formed.