The Evolution of LLM Architectures: A Component-Level Breakdown of the Key Techniques
Large language models may look architecturally similar on the surface, yet the performance gap between top models increasingly comes from refined components rather than radical redesigns. This article walks through the evolution of decoder-based LLM architectures, from their early form to modern open-weight models, examining the key technical milestones along the way: mixture of experts, attention optimizations, rotary position embeddings, the width-versus-depth tradeoff, and supporting component refinements. It also covers evaluation and deployment practices such as quantization, distillation, and KV cache optimization. By the end, you'll have a component-level framework for understanding what each design choice solves, what it costs, and when it applies.
Introduction: A Stable Skeleton, Relentless Evolution
One of the most striking patterns in the development of large language models over the past few years is that, at the overall architecture level, mainstream models have not undergone any disruptive change. They still follow the fundamental paradigm of “stacked decoder blocks.” Yet beneath this seemingly stable skeleton, nearly every component has been repeatedly refined. The performance gap between top models increasingly comes not from an architectural revolution that starts from scratch, but from improvements in data quality, tuning of training algorithms, and a series of careful refinements to classic components.
This article takes a “teardown” approach, tracing the evolution of LLM architectures from their early forms to modern open-weight models. It systematically reviews the key technical milestones along the way and extends into practical considerations at the engineering and deployment level.
1. Overall Architecture: Why It Looks Familiar
When you first examine the structural parameters of a modern open-weight model, many people feel it is no different from models they have seen before. This sense of familiarity is no illusion: mature developers tend to reuse the same well-validated foundational architecture.
The mainstream approach can be summarized as a structure built by vertically stacking multiple decoder blocks. Each block typically contains two sublayers: a self-attention sublayer (responsible for information exchange within the sequence) and a feed-forward sublayer (responsible for per-position feature transformation), along with residual connections and normalization layers to keep deep networks trainable.
The key insight here is this: when architectures “converge” in shape, we no longer need to chase the specific structure of every new model. Instead, we should focus on which components have been improved and why. This is the main thread of this teardown.
2. Back to the Beginning: The Basic Form of Early Decoder Architectures
To understand how modern models “evolved,” we first need to return to the most straightforward starting point. Early decoder architectures established several basic design principles that are still used today:
- Decoder-only: Using a causal mask ensures that each position can only see the content before it, enabling the autoregressive “predict the next token” training objective. This design is simple and scalable, and naturally fits self-supervised learning on large-scale corpora.
- Multi-head self-attention (MHA): The input is projected into multiple subspaces where attention is computed in parallel, then concatenated and fused. This allows the model to capture semantic relationships across different dimensions simultaneously.
- Introduction of positional encoding: Because self-attention is inherently insensitive to order, positional information must be explicitly injected.
An important lesson from early exploration is that not every seemingly reasonable design delivers benefits. Some improvements are theoretically attractive but fail to translate into performance gains during large-scale training, while adding computational and memory overhead. This lesson reminds us that architectural evolution must ultimately be measured against a fundamental yardstick: whether it genuinely improves the output per unit of compute.
3. Mixture of Experts (MoE): The Core Idea of Sparse Activation
When scaling up LLMs, the field found an important compromise between “increasing parameter count” and “controlling inference cost”—sparsification, best represented by the Mixture of Experts (MoE) approach.
The defining trait of a traditional dense model is that every parameter participates in computation for each token it processes. This creates a tension: more parameters mean greater capability, but the compute per token also grows linearly.
The MoE approach is “call on demand.” It replaces the feed-forward sublayer with multiple parallel experts, then uses a gating network (Gating Network / Router) to dynamically select a few experts for each token. Illustrative code:
def moe_forward(x, experts, router, top_k=2):# router: compute each token's assignment weights over expertsgate_scores = router(x) # shape: [tokens, num_experts]topk_weights, topk_ids = gate_scores.topk(top_k, dim=-1)output = torch.zeros_like(x)for i in range(top_k):expert_idx = topk_ids[:, i]weight = topk_weights[:, i].unsqueeze(-1)# compute per expert and weighted sum (in practice, group tokens for efficiency)expert_out = dispatch_to_experts(x, expert_idx, experts)output = output + weight * expert_outreturn output
The value of MoE is that the total parameter count can be made very large (increasing knowledge capacity), yet each token activates only a small fraction of it. This balances “model capacity” against “inference compute,” which also explains a common phenomenon: some models appear to have a huge parameter count, but the amount actually activated per inference is relatively limited.
However, MoE also introduces engineering challenges. Imbalanced expert load causes some experts to be “overworked” while others sit “idle.” As a result, training usually requires a load balancing loss to guide the routing distribution toward uniformity.
4. Optimizing the Attention Mechanism
Self-attention is the core of the Transformer and a primary target for optimization. As model scale grows, the memory and bandwidth overhead of standard multi-head attention rises sharply, leading the industry to develop several improvement directions:
- Grouped-query attention (GQA): Multiple query heads share a single group of key/value heads. It strikes a balance between quality and efficiency, significantly reducing the memory footprint of the KV cache during inference. Its extreme form is multi-query attention (MQA), where all query heads share a single group of key/value.
- Sliding window attention: This limits each token to attend only to neighbors within a local window, reducing the complexity of attention from quadratic in sequence length to linear, while expanding the receptive field through stacking multiple layers.
- Sparse and local-global hybrid designs: A few global tokens handle information transfer across long distances, while the remaining tokens process only local information, balancing long-context capability with computational efficiency.
These optimizations share a common engineering goal: supporting longer contexts while keeping KV cache and compute overhead as low as possible, because inference cost in long-context scenarios is almost entirely dominated by attention and the KV cache.
5. Positional Encoding: From Absolute Positions to Rotary Position Embedding
Positional encoding has evolved from “explicit injection” to “implicit rotation.”
Early approaches added a set of fixed position vectors at the input layer (absolute positional encoding) or used learnable position embeddings. Such methods often struggle to extrapolate beyond the training length.
Today’s widely adopted approach is Rotary Position Embedding (RoPE). Its core idea is not to “add” a position vector, but to fold positional information into the inner product of queries and keys through a rotation matrix, so that attention scores naturally depend on the relative distance between them. Its intuitive benefits are:
- Better relative position modeling;
- Stronger length extrapolation potential, making it easier to extend reasonably beyond the training length;
- Compatibility with linear attention for a simpler implementation.
RoPE has become a standard component in modern models. Combined with techniques such as attention scaling, it can further alleviate numerical instability issues in long sequences.
6. The Tradeoff Between Width and Depth
An unavoidable design question is this: given a fixed parameter or compute budget, should the model be made “wider” (larger hidden dimension, more attention heads) or “deeper” (more stacked layers)?
There is no universal answer to this tradeoff; it usually requires a combined judgment based on task characteristics and hardware characteristics:
- Deeper models tend to have stronger hierarchical abstraction and reasoning composition capabilities, but face harder gradient propagation and reduced parallelism due to serial dependencies;
- Wider models more easily exploit hardware parallelism and achieve higher single-step compute throughput, but may introduce representational redundancy.
It is worth emphasizing that the different choices made by different model teams under the same constraints are an important source of the phenomenon where “architectures look similar but capabilities differ.” When evaluating such design choices, we should not look only at parameter count, but focus on actual performance under an equal inference budget.
7. Refining the Supporting Components
Beyond the core components, modern architectures continue to evolve in a series of “details.” These changes may seem minor, but they directly affect the stability and efficiency of training:
- Normalization approach: A shift from the classic LayerNorm to RMSNorm, which removes the mean-centering step. It is lighter to compute and stable in effect.
- Feed-forward layer structure: The use of gated linear unit activations (such as gated SwiGLU), where a learnable gating branch modulates features, often delivers better representational power than simple ReLU/GELU feed-forward layers.
- Bias simplification: Many modern implementations tend to remove bias terms from some linear layers to simplify the structure and stabilize training.
Together, these changes form a modern architecture that “looks familiar but differs in every detail upon closer inspection.”
8. Performance Evaluation and Engineering Deployment
Ultimately, the merits of an architecture must be validated through rigorous evaluation. Evaluation should cover multiple perspectives: not only general knowledge and reasoning benchmarks, but also scenarios such as long-context processing, code generation, and multilingual understanding. It should also distinguish between “base model capability” and “post-alignment capability.”
At the deployment level, to run large models on limited local or cloud resources, the industry commonly employs the following engineering techniques:
- Quantization: Compressing weights from high precision to low-precision representations, greatly reducing memory footprint and bandwidth pressure;
- Distillation: Using a large model to guide the training of a small model, compressing its size while retaining most of its capabilities;
- KV cache optimization: Combined with mechanisms like GQA mentioned earlier, further reducing long-context inference overhead.
When hosting such models in the cloud, a set of general-purpose capabilities is typically involved: using a container platform to handle the orchestration and elastic scaling of inference services, using object storage to host model weights and data, and leveraging logging services and monitoring alerts to track service health, latency, and throughput. For example, general cloud capabilities offered by providers such as Baidu AI Cloud can help teams focus more on the model itself rather than building the underlying infrastructure.
