emerging-techniques-moe-training 是什么?
Train Mixture of Experts (MoE) models using DeepSpeed or HuggingFace. Use when training large-scale models with limited compute (5× cost reduction vs dense models), implementing sparse architectures like Mixtral 8x7B or DeepSeek-V3, or scaling model capacity without proportional compute increase. Covers MoE architectures, routing mechanisms, load balancing, expert parallelism, and inference optimization.
以上为来源原文,中文用途说明尚待整理。
怎么接入你的 Agent?
- 定位完整 Skill 目录
打开本项目来源,核对
SKILL.md及其引用的脚本和资料。 - 交给你正在用的 Agent
在下面选择客户端,展开并复制安装指令,让 Agent 读取来源后选择安装方式。
- 确认识别,再做具体任务
让 Agent 回报安装目录和识别到的名称
emerging-techniques-moe-training,然后告诉 Agent 你的任务和实际输入,让它先核对触发条件。
展开并复制给 Codex 的安装指令
安装并检查 emerging-techniques-moe-training
请在 Codex 的当前工作环境中安装并检查 emerging-techniques-moe-training 这个 Skill。
项目身份:davila7/claude-code-templates / emerging-techniques-moe-training
来源:https://github.com/davila7/claude-code-templates/blob/c1bc5c1df4ff0bffb9a04d8f7790543681232423/cli-tool/components/skills/ai-research/emerging-techniques-moe-training/SKILL.md
已定位的源文件:cli-tool/components/skills/ai-research/emerging-techniques-moe-training/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 Claude Code 的安装指令
安装并检查 emerging-techniques-moe-training
请在 Claude Code 的当前工作环境中安装并检查 emerging-techniques-moe-training 这个 Skill。
项目身份:davila7/claude-code-templates / emerging-techniques-moe-training
来源:https://github.com/davila7/claude-code-templates/blob/c1bc5c1df4ff0bffb9a04d8f7790543681232423/cli-tool/components/skills/ai-research/emerging-techniques-moe-training/SKILL.md
已定位的源文件:cli-tool/components/skills/ai-research/emerging-techniques-moe-training/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 Cursor 的安装指令
安装并检查 emerging-techniques-moe-training
请在 Cursor Agent 的当前工作环境中安装并检查 emerging-techniques-moe-training 这个 Skill。
项目身份:davila7/claude-code-templates / emerging-techniques-moe-training
来源:https://github.com/davila7/claude-code-templates/blob/c1bc5c1df4ff0bffb9a04d8f7790543681232423/cli-tool/components/skills/ai-research/emerging-techniques-moe-training/SKILL.md
已定位的源文件:cli-tool/components/skills/ai-research/emerging-techniques-moe-training/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 当前 Agent 的安装指令
安装并检查 emerging-techniques-moe-training
请在 当前 Agent 的当前工作环境中安装并检查 emerging-techniques-moe-training 这个 Skill。
项目身份:davila7/claude-code-templates / emerging-techniques-moe-training
来源:https://github.com/davila7/claude-code-templates/blob/c1bc5c1df4ff0bffb9a04d8f7790543681232423/cli-tool/components/skills/ai-research/emerging-techniques-moe-training/SKILL.md
已定位的源文件:cli-tool/components/skills/ai-research/emerging-techniques-moe-training/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。来源原文与资料状态
- 源文件
- 已保存 SKILL.md,抓取于 2026-11-23T04:29:48.865Z
- 中文使用说明
- 尚待整理,保留英文来源内容
- 安装与任务测试
- 本站未执行安装或任务测试
- 来源复核
- 已保留来源记录;当前完整用法未逐项人工复核
展开 SKILL.md 原文、章节与历史收录资料
cli-tool/components/skills/ai-research/emerging-techniques-moe-training/SKILL.md · 抓取时间 2026-11-23T04:29:48.865Z
以下保留源文件的 description、章节及摘录,供核对中文说明;完整文件通过上方链接打开。
抓取成功不代表已完成安装或任务测试。
Train Mixture of Experts (MoE) models using DeepSpeed or HuggingFace. Use when training large-scale models with limited compute (5× cost reduction vs dense models), implementing sparse architectures like Mixtral 8x7B or DeepSeek-V3, or scaling model capacity without proportional compute increase. Covers MoE architectures, routing mechanisms, load balancing, expert parallelism, and inference optimization.
查看源文件章节 / Source sections
- 原文:MoE Training: Mixture of Experts
- 原文:When to Use This Skill
- 安装 / Installation
- 快速开始 / Quick Start
- 原文:Basic MoE Architecture
- 原文:DeepSpeed MoE Training
- 原文:Core Concepts
- 原文:1. MoE Architecture
- 原文:2. Routing Mechanisms
- 原文:3. Load Balancing
- 原文:4. Expert Parallelism
- 原文:Training Configuration
- 原文:DeepSpeed MoE Config
- 原文:Training Script
- 原文:Advanced Patterns
- 原文:Mixtral 8x7B Architecture
- 原文:PR-MoE (Pyramid-Residual-MoE)
- 原文:Best Practices
- 原文:1. Expert Count Selection
- 原文:2. Capacity Factor Tuning
- 原文:3. Learning Rate Guidelines
- 原文:4. Loss Coefficient Tuning
- 原文:5. Avoid Common Pitfalls
- 原文:Inference Optimization
- 原文:Sparse Inference
- 原文:Resources
- 原文:See Also
原文:When to Use This Skill
Use MoE Training when you need to: - **Train larger models** with limited compute (5× cost reduction vs dense models) - **Scale model capacity** without proportional compute increase - **Achieve better performance** per compute budget than dense models - **Specialize experts** for different domains/tasks/languages - **Reduce inference latency** with sparse activation (only 13B/47B params active in Mixtral) - **Implement SOTA models** like Mixtral 8x7B, DeepSeek-V3, Switch Transformers **Notable MoE Models**: Mixtral 8x7B (Mistral AI), DeepSeek-V3, Switch Transformers (Google), GLaM (Google), NLLB-MoE (Meta)
安装 / Installation
```bash # DeepSpeed with MoE support pip install deepspeed>=0.6.0 # Megatron-DeepSpeed for large-scale training git clone https://github.com/microsoft/Megatron-DeepSpeed cd Megatron-DeepSpeed pip install -r requirements.txt # Alternative: HuggingFace Transformers pip install transformers accelerate ```
原文:Basic MoE Architecture
```python import torch import torch.nn as nn class MoELayer(nn.Module): """Sparse Mixture of Experts layer.""" def __init__(self, hidden_size, num_experts=8, top_k=2): super().__init__() self.num_experts = num_experts self.top_k = top_k # Expert networks (FFN) self.experts = nn.ModuleList([ nn.Sequential( nn.Linear(hidden_size, 4 * hidden_size), nn.GELU(), nn.Linear(4 * hidden_size, hidden_size) ) for _ in range(num_experts) ]) # Gating network (router) self.gate = nn.Linear(hidden_size, num_experts) def forward(self, x): # x shape: (batch_size, seq_len, hidden_size) batch_size, seq_len, hidden_size = x.shape # Flatten for routing x_flat = x.view(-1, hidden_size) # (batch_size * seq_len, hidden_size) # Compute gate scores gate_logits = self.gate(x_flat) # (batch_size * seq_len, num_experts) # Top-k routing gate_scores = torch.softmax(gate_logits, dim=-1) topk_scores, topk_indices = torch.topk(gate_scores, self.top_k, dim=-1) # Normalize top-k scores topk_scores = topk_scores / topk_scores.sum(dim=-1, keepdim=True) # Dispatch and combine expert outputs output = torch.zeros_like(x_flat) for i in range(self.top_k): expert_idx = topk_indices[:, i] expert_scores = topk_scores[:, i].unsqueeze(-1) # Route tokens to experts for expert_id in range(self.num_experts): mask = (expert_idx == expert_id) if mask.any(): expert_input = x_flat[mask] expert_output = self.experts[expert_id](expert_input) output[mask] += expert_scores[mask] * expert_output # Reshape back return output.view(batch_size, seq_len, hidden_size) ```
原文:DeepSpeed MoE Training
```bash # Training script with MoE deepspeed pretrain_gpt_moe.py \ --num-layers 24 \ --hidden-size 1024 \ --num-attention-heads 16 \ --seq-length 2048 \ --max-position-embeddings 2048 \ --micro-batch-size 4 \ --global-batch-size 256 \ --train-iters 500000 \ --lr 0.0001 \ --min-lr 0.00001 \ --lr-decay-style cosine \ --num-experts 128 \ --moe-expert-parallel-size 4 \ --moe-loss-coeff 0.01 \ --moe-train-capacity-factor 1.25 \ --moe-eval-capacity-factor 2.0 \ --fp16 \ --deepspeed_config ds_config.json ```
原文:1. MoE Architecture
**Key Components:** - **Experts**: Multiple specialized FFN networks (typically 8-128) - **Router/Gate**: Learned network that selects which experts to use - **Top-k Routing**: Activate only k experts per token (k=1 or k=2) - **Load Balancing**: Ensure even expert utilization ``` Input Token ↓ Router (Gate Network) ↓ Top-k Expert Selection (e.g., 2 out of 8) ↓ Expert 1 (weight: 0.6) + Expert 5 (weight: 0.4) ↓ Weighted Combination ↓ Output ```
原文:2. Routing Mechanisms
**Top-1 Routing (Switch Transformer):** ```python # Simplest routing: one expert per token gate_logits = router(x) # (batch, seq_len, num_experts) expert_idx = torch.argmax(gate_logits, dim=-1) # Hard routing ``` **Top-2 Routing (Mixtral):** ```python # Top-2: two experts per token gate_scores = torch.softmax(router(x), dim=-1) top2_scores, top2_indices = torch.topk(gate_scores, k=2, dim=-1) # Normalize scores top2_scores = top2_scores / top2_scores.sum(dim=-1, keepdim=True) # Combine expert outputs output = (top2_scores[:, :, 0:1] * expert_outputs[top2_indices[:, :, 0]] + top2_scores[:, :, 1:2] * expert_outputs[top2_indices[:, :, 1]]) ``` **Expert Choice Routing:** ```python # Experts choose top-k tokens (instead of tokens choosing experts) # Guarantees perfect load balancing expert_scores = router(x).transpose(-1, -2) # (batch, num_experts, seq_len) topk_tokens = torch.topk(expert_scores, k=capacity_per_expert, dim=-1) ```
文件 SHA256:90ccd303cb0d78b68593313126da2af1d9ef00566690505f266e9de45d255827
仓库许可证记录:MIT;skill-declaration-captured-not-interpreted,查看来源。
Train Mixture of Experts (MoE) models using DeepSpeed or HuggingFace. Use when training large-scale models with limited compute (5× cost reduction vs dense models), implementing sparse architectures like Mixtral 8x7B or DeepSeek-V3, or scaling model capacity without proportional compute increase. Covers MoE architectures, routing mechanisms, load balancing, expert parallelism, and inference optimization.
历史收录数据
| 来源仓库 | davila7/claude-code-templates |
|---|---|
| Skill源路径 | cli-tool/components/skills/ai-research/emerging-techniques-moe-training/SKILL.md |
安装前请让使用的Agent先读取这个SKILL.md及其所在目录,确认依赖和所需权限。此页不生成未经来源验证的安装命令。
