Evolution of Large Language Model Architectures: Sparse Experts, Reinforcement Learning, and Multimodality
This article explores the recent evolution of large language models (LLMs) across three main dimensions: model architecture, training methodologies, and capability expansion. It delves into the advancements of Sparse Expert (MoE) architectures, such as fine-grained expert segmentation and shared experts, which aim to increase model capacity without proportionally increasing computational costs. Furthermore, it examines base model and code-specific training strategies, and introduces Group Relative Policy Optimization (GRPO), a reinforcement learning approach that eliminates the need for a critic model to reduce memory overhead. The insights are primarily drawn from technical reports published in early 2024.
1. Reading Framework: Three Main Trajectories
Over the past two years, the technological progress of large language models (LLMs) has largely unfolded along three trajectories. The first is model architecture, focusing on solving the problem of “increasing parameters without proportionally increasing computation per inference.” The second is training methodology, addressing the high cost and instability of applying reinforcement learning (RL) to LLMs. The third is capability expansion, including specialized abilities like coding, mathematics, multimodality, and long-context processing.
These three trajectories are not independent. Architecture determines the cost boundaries for training and inference; training methods dictate the reasoning capabilities a model can acquire; and capability expansion imposes new requirements on the former two. This article follows this logic: first discussing architecture, then base model training, followed by reinforcement learning and multimodality, and finally offering engineering selection recommendations.
It should be noted that this article primarily references a set of technical reports publicly released by a research team between early 2024 and March 2024, supplemented by general industry technical background. Specific figures mentioned in the text are derived directly from the corresponding papers without external extrapolation.
2. Sparse Expert Architecture: Greater Capacity with Less Computation
2.1 Bottlenecks of Dense Models
In a standard dense Transformer, every token must pass through all feedforward network parameters. Doubling the parameters roughly doubles the computation per inference. This creates a direct conflict between “scaling model capacity” and “controlling inference costs.”
The concept of Mixture of Experts (MoE) addresses this by splitting the feedforward layer into multiple “experts,” with a router selecting only a few experts for each token. The total parameters can be very large, while the parameters actually activated per token represent only a small fraction.
2.2 Issues with Traditional MoE
Early MoE models typically utilized a small number of large experts, such as 8 or 16. This design introduced two issues. First, knowledge overlap easily occurs among experts. Multiple experts must learn basic capabilities like general grammar and common vocabulary, leading to parameter redundancy. Second, the knowledge scope each expert carries is too broad, resulting in a low degree of specialization.
2.3 Fine-Grained Expert Segmentation
Fine-grained expert segmentation involves splitting each large expert into several smaller experts. Under the premise of maintaining the same total parameter count, it increases the number of routable experts while correspondingly increasing the number of experts selected per token. This increases the number of combinations, allowing each small expert to focus on a narrower knowledge domain, thereby improving specialization.
2.4 Shared Experts
The Shared Expert is another key design. Certain experts bypass routing and are open to all tokens, responsible for carrying general linguistic knowledge. The remaining routed experts focus on specific patterns. The benefit here is that routed experts do not need to repeatedly learn general knowledge, clarifying their respective responsibilities.
According to the paper, its 145B-scale MoE model performs comparably to a 67B dense model, with a computation volume of about 28.5% of the latter. This ratio refers to computation volume, not the ratio of activated parameters. Readers should distinguish between these two concepts when citing such figures.
2.5 Routing and Load Balancing Illustration
The code below illustrates the basic structure of a forward pass in a fine-grained MoE. To highlight the logic, batch processing optimizations and residual connection placement details are omitted.
import torchimport torch.nn.functional as Fdef moe_block(x, shared_experts, routed_experts, router, top_k=6):# x: [num_tokens, hidden_dim]# Shared experts process all tokensshared_out = sum(expert(x) for expert in shared_experts)# The router scores each token and selects top_k routed expertsscores = F.softmax(router(x), dim=-1) # [num_tokens, num_routed]weights, idx = scores.topk(top_k, dim=-1)routed_out = torch.zeros_like(x)for k in range(top_k):for e, expert in enumerate(routed_experts):mask = idx[:, k] == eif mask.any():routed_out[mask] += weights[mask, k:k + 1] * expert(x[mask])return shared_out + routed_out
In actual training, a load balancing loss must be added to prevent a few experts from being over-selected while others remain nearly idle. This is indispensable in engineering implementations; otherwise, “expert collapse” occurs, where most experts lose the opportunity to learn.
3. General Base Models and Code Models
3.1 Training Strategy for Base Models
The general base models in the report range from 7B to 67B, with a pre-training data volume of 2 trillion tokens. The authors propose a “long-termism” training philosophy, emphasizing the long-term benefits of data cleaning, deduplication, and proportioning, rather than solely pursuing metric improvements at a specific stage.
For engineering teams, this approach can be implemented in three ways: first, establish an offline evaluation process for data quality to prevent low-quality data from entering training; second, adjust data proportions by stage—expanding coverage in the early phase and increasing the weight of high-quality and specialized data in the later phase; third, validate training strategies on smaller models before scaling up to reduce trial-and-error costs.
The report shows that the 67B model outperforms a contemporary 70B-scale open-source model on coding, math, and reasoning tasks, approaching the level of mainstream closed-source general models. This indicates that with reasonable data and training budgets, the capability boundaries of open-source models can be significantly pushed forward.
3.2 Specialized Training for Code Models
The training data for code models differs significantly from general text. The code model series reported in the paper ranges from 1.3B to 33B parameters, with a pre-training corpus of approximately 2 trillion tokens, covering 87 programming languages. Its data processing typically includes the following steps:
- Organize files by language and repository structure to preserve project context;
- Filter out auto-generated code, compressed files, and duplicate samples;
- Incorporate code completion and Fill-in-the-Middle (FIM) formats into training samples, enabling the model to master both left-to-right generation and middle completion capabilities.
In terms of evaluation, code models typically use function-level generation tasks, using the pass rate of unit tests as the primary metric. This type of evaluation is closer to real development scenarios than simple perplexity but still has limitations. For example, it cannot fully reflect dependency understanding and cross-file modification capabilities in large projects.
4. Mathematical Reasoning and Critic-Free Reinforcement Learning
4.1 Memory Overhead of PPO
Proximal Policy Optimization (PPO) is a commonly used algorithm in LLM reinforcement learning. It requires maintaining both a policy model (Actor) and a value model (Critic) simultaneously. The value model is similar in size to the policy model, and during training, its parameters, gradients, and optimizer states must be saved, multiplying the memory footprint. Additionally, training the value model itself is unstable, further affecting policy updates.
4.2 Core Idea of GRPO
Group Relative Policy Optimization (GRPO) eliminates the value model. For the same prompt, the model samples a group of responses (e.g., G responses) at once, and a reward function scores each response. The advantage of each response is determined by its relative position within the group: the reward of the response minus the group’s average reward, divided by the group’s standard deviation.
This way, the baseline is provided by the statistics of the in-group samples, eliminating the need for an extra value network. The memory overhead is thus close to the training overhead of the policy model itself. The paper reports that this method achieved leading performance among open-source models on competitive mathematics benchmarks at the time.
4.3 Implementation Illustration
The code below demonstrates the calculation of in-group relative advantage.
import torchdef group_relative_advantage(rewards: torch.Tensor, eps: float = 1e-6) -> torch.Tensor:# rewards: Rewards for G sampled responses under the same prompt, shape [G]mean = rewards.mean()std = rewards.std()return (rewards - mean) / (std + eps)# Example: Sample 4 responses for the same prompt, rewards are 0 or 1 (whether the answer is correct)rewards = torch.tensor([1.0, 0.0, 1.0, 0.0])print(group_relative_advantage(rewards))# Correct responses get positive advantage, incorrect responses get negative advantage
The complete GRPO objective function also includes two parts. The first is clipping the policy ratio to limit the magnitude of a single update, similar to PPO. The second is applying a KL divergence constraint to the reference model to prevent the policy from deviating too far from the initial model.
4.4 Implementation Considerations
The effectiveness of GRPO heavily depends on the design of the reward function. In mathematical tasks, rewards typically come from answer comparison or formal verification. If the reward signal is too sparse—meaning all responses in a group are either all correct or all incorrect—the in-group standard deviation approaches zero, and the advantage loses its discriminative power. In engineering practices, common approaches to address this…
