当前位置: 首页 > news >正文

从LLM角度学习和了解MoE架构

MoE是目前国内LLM采用的技术路线,Deepseek R1、Qwen3、GLM4都采用了MoE架构。

这里尝试理解什么是MoE,以及MoE有哪些优点和缺点,后续分析为什么这么多LLM采用MoE。

1 什么是MoE

MoE,全称为Mixed Expert Models,1991年论文Adaptive Mixture of Local Exports提出。

1.1 MoE示例

在相同计算资源和参数量条件下,MoE模型与Dense模型相比,训练速度更快。

也就是说,MoE由于训练效率的提升,可以是更大的模型。

比如Google Switch Transformer模型,大小是T5-XXL的15倍,相比T5-XXL模型快4倍达到固定困惑度PPL。

In deep learning, models typically reuse the same parameters for all inputs. Mixture of Experts (MoE) models defy this and instead select different parameters for each incoming example. The result is a sparsely-activated model—with an outrageous number of parameters—but a constant computational cost. However, despite several notable successes of MoE, widespread adoption has been hindered by complexity, communication costs, and training instability. We address these with the introduction of the Switch Transformer. We simplify the MoE routing algorithm and design intuitive improved models with reduced communication and computational costs. Our proposed training techniques mitigate the instabilities, and we show large sparse models may be trained, for the first time, with lower precision (bfloat16) formats. We design models based off T5-Base and T5 Large (Raffel et al., 2019) to obtain up to 7x increases in pre-training speed with the same computational resources. These improvements extend into multilingual settings where we measure gains over the mT5-Base version across all 101 languages. Finally, we advance the current scale of language models by pre-training up to trillion parameter models on the “Colossal Clean Crawled Corpus”, and achieve a 4x speedup over the T5-XXL model.

https://arxiv.org/pdf/2101.03961

在相同计算预算条件下,MoE可以显著扩大模型的规模。特别是在预训练阶段,与稠密模型相比,混合专家模型通常能够更快地达到相同的质量水平。

1.2 MoE架构

MoE基于Transformer架构,主要由两部分组成:稀疏MoE层、token路由。

稀疏 MoE 层,MoE 层包含若干“专家”(如 8 个),每个专家本身是一个独立的神经网络,用于代替经典Transformer模型的前馈网络 (FFN) 层。实际应用中,这些专家通常是更简单的FFN,也可以是其他网络。

token路由,用于决定哪些token激活哪个专家。如下图所示,token “More”可能激活第二个专家,而“Parameters” 被激活第一个专家。一个 token 甚至能激活多个专家。token路由是MoE的一个关键点,路由器包含学习参数,与网络其他部分一同进行训练。

2 MoE优点

MoE与Dense模型相比,训练速度更快,可以训练更大的模型,如Google的Switch Transformer。

DeepSeek的16B MoE模型,仅消耗40%计算预算,就达到与LLaMA2 7B差不多的效果。

MoE优点总结如下:

1)训练速度更快,效果更好

2)推理成本低,只需要激活部分的参数参数运算

3)可以较容易扩展到更大的模型,计算预算不变,可以增加参数量。

4)多任务学习,如Switch Transformer在101种语言获得性能提升,具备较好的多任务学习能力。

3 MoE缺点

当然MoE也有缺点,总结如下

1)训练稳定性差,这与MoE的架构有关,在训练中可能会遇到稳定性问题。

2)通信开销大,MoE的专家路由机制,可能会增加通信成本,特别是在分布式训练环境中。

3)模型复杂,模型参数增加,嫌贵那贵的模型设计就会相对复杂,需要均衡和取舍。

4)下游任务容易过拟合,MoE由于其稀疏性,在微调时更容易过拟合,当然这不一定全是坏处,需要依据具体问题取舍和优化。

reference

---

Switch Transformers: Scaling to Trillion Parameter Models

https://arxiv.org/pdf/2101.03961

MoE(Mixture-of-Experts)大模型架构的优势是什么?为什么?

https://www.zhihu.com/tardis/bd/ans/3364787819

Adaptive Mixtures of Local Experts

https://www.cs.toronto.edu/~hinton/absps/jjnh91.pdf

http://www.dtcms.com/a/456885.html

相关文章:

  • 【学习笔记06】内存管理与智能指针学习总结
  • 0、FreeRTOS编码和命名规则
  • 无锡专业制作网站wordpress 手风琴
  • 通过camel AI创建多agent进行写作
  • qt常用控件
  • 离散化模板
  • linphone + minisipserver 下载和配置
  • 网站建设登录界面代码wordpress 按钮美化
  • 吴恩达机器学习课程(PyTorch 适配)学习笔记:3.4 强化学习
  • jEasyUI 自定义窗口工具栏
  • Spring Boot 和 MyBatis 环境下实现动态数据源切换
  • 2025 年度国产大模型「开源 vs. 闭源」深度评测与实战指南
  • 网页设计与网站建设电话香洲网站建设
  • 移动论坛网站模板免费下载revolution slider wordpress
  • TPM(Total Productive Maintenance)现场管理
  • 从 0 到 1 搭建 Python 语言 Web UI自动化测试学习系列 11 自动化测试--框架设计--基础知识 7--各种弹窗处理
  • ubuntu terminal 设置代理
  • 《传感器与检测技术》第 2 章 电阻式传感器原理与应用
  • Linux中input子系统
  • 探索Linux:开源世界的钥匙
  • GitHub 热榜项目 - 日榜(2025-10-08)
  • 手写Function.prototype.bind:从原理到完整实现
  • 百度做网站的公司施工企业的施工现场消防安全责任人应是
  • 做电商网站报价网站开发工程师需要会写什么
  • (3)容器布局进阶:Spacer、Divider、Frame 与 Alignment
  • 墨西哥证券交易所(BMV)等多个交易所股票数据API对接文档
  • 【数据分析与可视化】2025年一季度金融业主要行业资产、负债、权益结构与增速对比
  • app网站建设阿里巴巴卓拙科技做网站吗
  • 乌苏市城乡建设局网站北京朝阳区邮政编码
  • 个人用云计算学习笔记 --18(NFS 服务器、iSCSI 服务器)