大型语言模型架构对比:从 DeepSeek V3 到 Kimi K2
Sebastian Raschka 博士
最初的 GPT 架构开发至今已有七年。回顾 GPT-2(2019年)并展望 DeepSeek V3 和 Llama 4(2024-2025年),人们可能会惊讶地发现这些模型在结构上仍然非常相似。当然,位置嵌入已从绝对位置演变为旋转位置(RoPE),多头注意力在很大程度上已被分组查询注意力取代,更高效的 SwiGLU 已取代 GELU 等激活函数。但在这些微小改进之下,我们是看到了真正的突破性变化,还是只是在打磨相同的架构基础?
比较大型语言模型以确定有助于良好性能的关键因素是众所周知的挑战:数据集、训练技术和超参数差异很大,而且往往记录不全。然而,我认为检查架构本身的结构变化仍然很有价值,可以看到开发者们在 2025 年在做什么。
1. DeepSeek V3/R1
DeepSeek R1 于2025年1月发布时产生了重大影响。DeepSeek R1 是建立在 DeepSeek V3 架构之上的推理模型,该架构于2024年12月推出。这里重点介绍 DeepSeek V3 引入的两个关键架构技术:多头脑潜注意力(MLA)和混合专家(MoE)。
MLA:与分组查询注意力(GQA)不同——GQA 通过跨头共享键值投影来减少内存——MLA 在存储到 KV 缓存之前将键值张量压缩到更低维空间。在推理时,这些压缩张量被投影回原始大小。MLA 在建模性能方面优于 MHA,同时减少了内存使用。
MoE:DeepSeek V3 用多个专家层替换每个前馈模块,路由器仅选择每个令牌的一小部分专家。DeepSeek V3 每个 MoE 模块有 256 个专家,总共 6710 亿个参数,但每次仅 9 个专家处于活跃状态(1 个共享专家加 8 个路由器选择的专家),即每次推理步骤仅使用 370 亿个参数,而非全部 6710 亿。
一个值得注意的特点是共享专家的使用:一个对每个令牌始终处于活跃状态的专家。共享专家的好处是,共同或重复的模式不必由多个单独专家学习,这为学习更多专门化模式留出了更多空间。
DeepSeek V3 是一个巨大的 6710 亿参数模型,在发布时优于其他开放权重模型,包括 4050 亿参数的 Llama 3。尽管更大,但由于其 MoE 架构,在推理时效率更高。
2. OLMo 2
OLMo 系列由非营利组织 Allen Institute for AI 开发,因其在训练数据和代码方面的透明度而值得注意。OLMo 2 的有趣架构设计选择主要在于归一化:RMSNorm 层的放置以及 QK-norm 的添加。
大多数 LLM 使用 Pre-Norm(在注意力和前馈模块之前放置归一化)。OLMo 2 采用了一种 Post-Norm 形式(在之后放置),这有助于提高训练稳定性。QK-Norm 是在注意力模块内部应用于查询和键的 RMSNorm 层,在应用 RoPE 之前。Post-Norm 和 QK-Norm 共同稳定了训练损失。
3. Gemma 3
Gemma 3 使用滑动窗口注意力来降低计算成本。通过滑动窗口注意力,我们限制当前查询位置周围的上下文大小,显著减少 KV 缓存内存需求。Gemma 2 使用混合注意机制,以 1:1 的比例结合滑动窗口和全局注意力。Gemma 3 转变为 5:1 的比例:每 5 个滑动窗口(局部)注意力层只有 1 个完整注意力层,滑动窗口大小从 4096 减少到仅 1024 个令牌。
Gemma 3 还在注意力和前馈模块之前和之后都使用 RMSNorm 层——一种结合 Pre-Norm 和 Post-Norm 优点的混合方法。
4. Mistral Small 3.1
Mistral Small 3.1 于 3 月发布,在多个基准测试中优于 Gemma 3 27B,同时速度更快。较低推理延迟的原因可能是他们定制的分词器以及缩小 KV 缓存和层数。有趣的是,早期 Mistral 模型使用了滑动窗口注意力,但在 Mistral Small 3.1 中似乎已放弃,这可能是为了使用更多优化的 FlashAttention 代码。
5. Llama 4
Llama 4 也采用了 MoE 方法,整体架构与 DeepSeek V3 非常相似。Llama 4 Maverick 总参数 4000 亿,活跃参数 17B(2 个活跃专家,每个隐藏大小 8,096),而 DeepSeek V3 活跃参数 37B(9 个活跃专家,每个隐藏大小 2,048)。DeepSeek 在每个 transformer 块中使用 MoE 层(除前 3 个外),而 Llama 4 在每隔一个 transformer 块中交替使用 MoE 和密集模块。
6. Qwen3
Qwen3 提供 7 个密集模型:0.6B、1.7B、4B、8B、14B 和 32B;还有 2 个 MoE 模型:30B-A3B 和 235B-A22B。0.6B 模型可能是目前最小的当前代开源权重模型。Qwen3 内存占用更小,但使用比 Llama 3 更多的 transformer 块,导致运行时更慢但内存使用更低。
Qwen3 235B-A22B(22B 活跃参数)的架构与 DeepSeek V3 非常相似。但 Qwen3 不再使用共享专家(早期 Qwen 模型使用共享专家)。开发者指出:"当时我们没有发现共享专家有足够显著的改进,而且担心共享专家带来的推理优化问题。"
7. SmolLM3
SmolLM3 以 30 亿参数的大小提供了良好的建模性能,最有趣的方面是使用 NoPE(无位置嵌入)。在 NoPE 中,根本不添加位置信号:不是固定的、不是学习的、也不是相对的。因果注意力掩码隐式保留自回归顺序。NoPE 论文发现,无需注入位置信息,而且 NoPE 具有更好的长度泛化能力。
8. Kimi K2
Kimi K2 最近引起轰动,因为它是一个开源权重模型,性能与 Gemini、Claude 和 ChatGPT 等最佳专有模型相当。一个值得注意的方面是使用 Muon 优化器而非 AdamW——据报道这是首次在任何这种规模的生产模型上使用 Muon。
关键结论:MoE 在 2025 年变得主导;MLA 优于 GQA 但实现更复杂;滑动窗口注意力在不损害性能的情况下减少内存;归一化放置(Pre vs Post)影响训练稳定性。该领域继续在相同核心架构基础上进行改进,而非革新。
The Big LLM Architecture Comparison: From DeepSeek V3 to Kimi K2
Sebastian Raschka, PhD
It has been seven years since the original GPT architecture was developed. At first glance, looking back at GPT-2 (2019) and forward to DeepSeek V3 and Llama 4 (2024-2025), one might be surprised at how structurally similar these models still are. Sure, positional embeddings have evolved, Multi-Head Attention has largely given way to Grouped-Query Attention, and SwiGLU has replaced activation functions like GELU. But beneath these refinements, have we truly seen groundbreaking changes, or are we simply polishing the same architectural foundations?
Comparing LLMs to determine the key ingredients that contribute to good performance is notoriously challenging: datasets, training techniques, and hyperparameters vary widely. However, examining the structural changes of the architectures themselves reveals what LLM developers are up to in 2025.
1. DeepSeek V3/R1
DeepSeek R1 made a big impact when released in January 2025. DeepSeek R1 is a reasoning model built on top of the DeepSeek V3 architecture, introduced in December 2024. Two key architectural techniques distinguish DeepSeek V3:
Multi-Head Latent Attention (MLA): Unlike Grouped-Query Attention (GQA), which shares key and value projections across heads to reduce memory, MLA compresses key and value tensors into a lower-dimensional space before storing them in the KV cache. At inference time, these compressed tensors are projected back to their original size. MLA offers better modeling performance than MHA while reducing memory usage.
Mixture-of-Experts (MoE): DeepSeek V3 replaces each FeedForward module with multiple expert layers, where a router selects only a small subset of experts per token. DeepSeek V3 has 256 experts per MoE module and a total of 671 billion parameters, yet only 9 experts are active at a time (1 shared expert plus 8 selected by a router). This means just 37 billion parameters are used per inference step, not all 671 billion.
A notable feature is the shared expert: an expert that is always active for every token. Common or repeated patterns don't have to be learned by multiple individual experts, leaving more room for learning specialised patterns.
DeepSeek V3 is a massive 671-billion-parameter model that, at launch, outperformed other open-weight models including the 405B Llama 3. Despite being larger, it is much more efficient at inference time thanks to its MoE architecture.
2. OLMo 2
The OLMo series by the Allen Institute for AI is noteworthy due to its transparency in training data and code. OLMo 2's interesting architectural design choices come down to normalizations: the placement of RMSNorm layers and the addition of QK-norm.
Most LLMs use Pre-Norm (placing normalisation before attention and FeedForward modules). OLMo 2 adopted a form of Post-Norm (placing normalisation after), which helped with training stability.
QK-Norm is an RMSNorm layer placed inside the Multi-Head Attention module and applied to queries and keys before applying RoPE. Together with Post-Norm, QK-Norm stabilises the training loss.
3. Gemma 3
Gemma 3 uses sliding window attention to reduce computational costs. With sliding window attention, we restrict the context size around the current query position, substantially reducing KV cache memory requirements. The Gemma 2 predecessor used a hybrid attention mechanism combining sliding window and global attention in a 1:1 ratio. Gemma 3 shifts to a 5:1 ratio: there's only 1 full attention layer for every 5 sliding windows (local) attention layers, with the sliding window size reduced from 4096 to just 1024 tokens.
Gemma 3 also uses RMSNorm layers both before AND after the attention and FeedForward modules – a hybrid approach that gets the best of both Pre-Norm and Post-Norm.
4. Mistral Small 3.1
Mistral Small 3.1, released in March, outperforms Gemma 3 27B on several benchmarks while being faster. The reasons for lower inference latency are likely their custom tokenizer and shrinking the KV cache and layer count. Interestingly, earlier Mistral models had utilized sliding window attention but appear to have abandoned it in Mistral Small 3.1, possibly to use more optimised FlashAttention code.
5. Llama 4
Llama 4 has adopted an MoE approach and follows a relatively standard architecture very similar to DeepSeek V3. Llama 4 Maverick has 400 billion total parameters with 17B active parameters (2 active experts with 8,096 hidden size each), compared to DeepSeek V3's 37B active parameters (9 active experts with 2,048 hidden size each). DeepSeek uses MoE layers in each transformer block (except the first 3), whereas Llama 4 alternates MoE and dense modules every other block.
MoE architectures have seen a significant rise in popularity in 2025.
6. Qwen3
Qwen3 offers 7 dense models: 0.6B, 1.7B, 4B, 8B, 14B, and 32B; and 2 MoE models: 30B-A3B and 235B-A22B. The 0.6B model may well be the smallest current-generation open-weight model. Qwen3 has a smaller memory footprint but uses more transformer blocks than Llama 3, leading to slower runtime but lower memory usage.
In Qwen3 235B-A22B (22B active parameters), the architecture is remarkably similar to DeepSeek V3. However, Qwen3 moved away from using a shared expert (earlier Qwen models used shared experts). The developer noted: 'At that moment we did not find significant enough improvement on shared expert and we were worrying about the optimisation for inference caused by shared expert.'
7. SmolLM3
SmolLM3 offers good modelling performance at 3-billion parameter size. Its most interesting aspect is the use of NoPE (No Positional Embeddings). In NoPE, no positional signal is added at all: not fixed, not learned, not relative. The causal attention mask preserves autoregressive ordering implicitly. The NoPE paper found that no positional information injection is necessary and that NoPE has better length generalisation.
8. Kimi K2
Kimi K2 recently made big waves due to being an open-weight model with performance on par with the best proprietary models like Gemini, Claude, and ChatGPT. A notable aspect is its use of the Muon optimizer over AdamW – reportedly the first time Muon was used for any production model of this size. This resulted in very smooth and well-decaying training loss curves.
The key takeaway from this architectural survey is that MoE has become dominant in 2025, MLA outperforms GQA but is more complex to implement, sliding window attention reduces memory without hurting performance, and normalisation placement (Pre vs Post) affects training stability. The field continues to refine the same core architectural foundations rather than revolutionising them.