Large Language Model Generations Explained: Long Context, AI Agents, and Efficient Inference
This article explains how recent large language model generations differ from earlier ones. It covers why version numbers alone do not show capability changes, how Mixture of Experts (MoE) models separate total and active parameters, architectural improvements for long context and efficient inference, and the engineering costs of million-token context windows. It also describes the shift toward task execution by AI agents and how evaluation methods should change to match.
1. Version Numbers Do Not Directly Show Capability Changes
Model version numbers usually signal continuity within a product line, but they do not reflect the actual changes in capability boundaries. To judge whether a generational upgrade is worthwhile, look at three types of evidence: architecture and training details in official technical reports or release notes, results from third-party or internal benchmarks, and performance on real business data.
Version numbers can also lead to two kinds of misjudgment. One is treating a “same series, number plus one” release as a minor tweak and overlooking architectural rewrites. The other is treating a “completely new name” as a qualitative leap without checking concrete metrics such as context length, inference cost, and tool-calling stability. Developers should rely on metrics and compare them item by item.
Preview versions and general availability versions often differ in API stability, rate limits, and billing rules. During evaluation, first confirm the release status of the version in use. Performance during a preview period should not be treated as a long-term commitment.
2. Model Positioning: From General Conversation to Task Execution
Early general-purpose large language models were built mainly for question answering, writing, and knowledge retrieval. They were judged primarily on single-turn answer quality and cost-effectiveness. As applications matured, expectations shifted in three directions: handling longer input materials, calling external tools during multi-step tasks, and reasoning more thoroughly on complex problems.
This shift changes how models should be evaluated. Single-turn question answering focuses on whether the answer is correct. Task-oriented models require evaluation of multi-step task completion rates, the validity of tool parameters, recovery ability after errors, and state retention across long workflows. If an evaluation set still contains only single-turn questions, it cannot reflect the main advantages of the new generation of models.
3. Parameter Scale: The Difference Between Total and Active Parameters
For models that use a Mixture of Experts (MoE) architecture, two parameter metrics need to be distinguished. Total parameters determine the storage space that the model weights occupy. Active parameters determine how many parameters take part in computing each token, which directly affects the computational cost of each inference step.
Suppose a model has 400B total parameters and activates 20B parameters per token. Its per-step computation is then close to that of a 20B dense model. Deployment, however, still requires holding all expert weights in memory. As a result, two models that are both labeled as “large parameter count” can differ greatly in hardware requirements and inference latency.
Routing is the core mechanism of MoE. For each token, the router scores every expert and selects the top-scoring experts to participate in computation. The illustrative code below shows the top-k routing process for a single token:
import numpy as npdef top_k_moe_route(hidden, gate_weight, k=2):"""Compute expert scores for a single token and return the top-k experts with their normalized weights (illustrative code)"""logits = hidden @ gate_weight # shape: [num_experts]top_idx = np.argsort(logits)[-k:][::-1] # select the k experts with the highest scoresscores = logits[top_idx] - logits[top_idx].max()probs = np.exp(scores)probs /= probs.sum()return top_idx, probsrng = np.random.default_rng(0)hidden = rng.normal(size=16) # hidden state of a single tokengate = rng.normal(size=(16, 8)) # routing matrix for 8 expertsexperts, weights = top_k_moe_route(hidden, gate, k=2)print("Selected experts:", experts, "Weights:", np.round(weights, 3))
In engineering terms, MoE also has to address uneven expert load. If a few experts are selected for long periods, the others receive insufficient training, and overall efficiency drops. A common approach adds an auxiliary loss to the training objective to constrain the load on each expert. However, the auxiliary loss can interfere with optimization of the main task. For this reason, some teams also explore balancing load by dynamically adjusting routing biases.
4. Four Directions of Architectural Improvement
Architectural improvements in new-generation models fall mainly into four directions.
4.1 Attention Compression and Sparsification
In standard attention, the memory footprint of the key-value (KV) cache grows linearly with context length. Compressing key-value representations, or computing sparse attention over only a subset of key positions, can reduce memory and compute costs for long sequences. These techniques are foundational for supporting very long contexts.
4.2 Expert Load Balancing
Load balancing affects both training stability and expert utilization during inference. Beyond auxiliary losses, bias-based dynamic adjustment and capacity limits are also widely discussed. When selecting a model, engineering teams should review the training details the model publisher discloses. They can also verify balance indirectly through metrics such as expert activation distribution.
4.3 Multi-Token Prediction
Traditional language models predict only the next token at each step. Multi-token prediction requires the model to predict several subsequent positions at once, which can improve the training efficiency of each sample. Some inference systems also use this structure for speculative decoding, which speeds up generation while keeping the output distribution unchanged.
4.4 Optimizers and Training Stability
In large-scale training, the choice of optimizer affects convergence speed and stability. Besides common adaptive optimizers, some teams are experimenting with update methods based on matrix orthogonalization. The benefits of these methods depend on the model scale and data setup, so they must be validated through controlled experiments. Their conclusions should not be applied directly.
5. Engineering Costs of Million-Token Context
Supporting a 1M-token context requires more than increasing a single parameter. The model must solve memory and latency problems on both the training and inference sides.
The KV cache memory footprint can be estimated with the following formula:
KV cache memory (bytes) = 2 × number of layers × number of KV heads × head dimension × sequence length × bytes per element
Assume a model has 60 layers, 8 KV heads, a head dimension of 128, FP16 precision (2 bytes per element), and a sequence length of 1,048,576 tokens. Substituting these values gives 257,698,037,760 bytes, or about 240 GiB. The cache for a single very long request alone exceeds the memory of a common accelerator card. Compression, paged memory management, cache quantization, or multi-card sharding is therefore required.
Long-context usability must be verified separately. Supporting a context window and accurately retrieving and reasoning over information near the end of that window are two different capabilities. At least two types of tests are recommended. The first is a retrieval test that locates specific information in very long text. The second is question answering and summarization on real long documents, such as contracts, code repositories, and log collections. Tests should cover different length ranges so that the accuracy curve across lengths can be observed.
6. Agent Capabilities: From Answering Questions to Completing Tasks
A typical agent workflow follows this pattern. The model understands the goal, plans steps, calls tools, reads the results, and revises its plan based on those results until the task is complete. This requires three foundational abilities: selecting the right tool, generating parameters that conform to the schema, and adjusting strategy when a tool returns an error.
The illustrative code below shows a minimal tool-calling loop:
tools = [{"name": "query_order","description": "Query order status by order ID","parameters": {"type": "object","properties": {"order_id": {"type": "string"}},"required": ["order_id"],},}]def agent_loop(llm, messages, tools, executor, max_steps=8):"""Call the model and tools in a loop until the model returns a final answer or the step limit is reached (illustrative code)"""for _ in range(max_steps):reply = llm(messages, tools=tools)call = reply.get("tool_call")if call is None:return reply["content"]result = executor(call["name"], call["arguments"])messages.append({"role": "tool", "name": call["name"], "content": result})raise RuntimeError("Maximum step count exceeded, task not completed")
In production, the executor must validate parameters, restrict the resources it can access, and log every call. Model-generated parameters should be treated as untrusted input. They must never be concatenated directly into database queries or system commands.
When evaluating agent capabilities, focus on these metrics: tool selection accuracy, parameter validity rate, multi-step task completion rate, error recovery rate, and average number of calls. Of these, the error recovery rate best reflects a model’s reliability in a real environment.
7. Inference Efficiency and Serving Costs
Inference cost has three main components: the cost of processing input tokens in the prefill stage, the cost of generating output tokens one at a time in the decoding stage, and the cache footprint that long contexts introduce. Service providers typically measure efficiency with time to first token, output tokens per second, and cost per request.
The cost of a single request can be approximated as:
Cost per request ≈ input tokens × input price per token + output tokens × output price per token
This formula applies only to pay-as-you-go scenarios. Self-hosted deployments must also account for hardware depreciation, electricity, operations, and resource utilization. MoE models activate fewer parameters, so each token requires less computation. All expert weights still occupy memory, so the analysis needs to be combined with batch size and
