将专家混合推向极限:参数效率极高的 MoE 指令调节

将专家混合推向极限:参数效率极高的 MoE 指令调节

name=Ted Zadouriaffiliation=Cohere for AI email=ted@cohere.com name=Ahmet Üstün affiliation=Cohere for AI email=ahmet@cohere.comname=Arash Ahmadian†affiliation=Cohere for AI email=arash@cohere.com name=Beyza Ermiş affiliation=Cohere For AI email=beyza@cohere.com name=Acyr Locatelli affiliation=Cohere email=acyr@cohere.com name=Sara Hooker affiliation=Cohere for AI email=sarahooker@cohere.com

摘要

专家混合 (MoE) 是一种众所周知的神经架构,其中一组专门的子模型以恒定的计算成本优化整体性能。 然而,由于需要将所有专家存储在内存中,传统的 MoE 带来了大规模的挑战。 在本文中,我们将 MoE 推向了极限。 我们通过独特地将 MoE 架构轻量级专家相结合,提出了参数效率极高的 MoE。我们的 MoE 架构优于标准参数高效微调 (PEFT) 方法,并且仅通过更新轻量级专家即可与完全微调相媲美 - 少于 1% 11B 参数模型的百分比。 此外,我们的方法可以推广到看不见的任务,因为它不依赖于任何先前的任务知识。 我们的研究强调了专家混合架构的多功能性,展示了即使受到严格的参数约束也能提供稳健性能的能力。 我们在所有实验中使用的代码均可在此处公开获取:GitHub - for-ai/parameter-efficient-moe

0

1简介

Refer to caption

图1:左边:使用 T5-XL (3B) 演示的相当数量的参数,我们的 PEFT 专家组合优于 SOTA 单一 PEFT 方法。 PEFT方法的混合可扩展到11B;通过微小的参数更新,它接近或匹配完整的微调性能。

传统的训练范例是将模型的权重应用于每个输入。 可以说,这效率不高,因为给定的输入可能不需要模型的全部容量。 相比之下,MoE 的前提是子模块化组件(所谓的专家)可以专门处理不同类型的输入。 这种对条件计算的强调具有重要的效率副作用,例如恒定的推理成本。 这使得 MoE 在大规模 Transformers 时代成为重要研究和广泛采用的领域,在大规模 Transformer 时代,扩展增加了部署和延迟成本(Shazeer 等人,2018;Riquelme 等人,2021;Du 等人,2022; Fedus 等人,2022)。

虽然迄今为止的大多数工作都将 MoE 作为预训练策略,但 MoE 的内在动机并不仅仅局限于预训练。 事实上,MoE 的优点可以说非常适合指令微调设置,其中数据通常被故意结构化以表示不同的任务集,通常称为多任务微调(Chung 等人, 2022; Wei 等人, 2022; Sanh 等人, 2022; Longpre 等人, 2023; Muennighoff 等人, 2023)。

在这项工作中,我们提出了这个问题 我们可以利用 MoE 进行指令微调吗? MoE 范式的主要缺点之一是它引入了大量的总参数(Fedus 等人,2022)。 尽管有条件计算,但考虑到需要更新所有参数,完全微调 MoE 架构的计算要求极高。 对于大多数从业者来说,考虑到现代大语言模型 (Brown 等人, 2020; Touvron 等人, 2023; Kaplan 等人, 2020; Anil 等人, 2023) 的规模,这是一个不可行的计算成本。

因此,我们专注于为日常实践者提供更现实的环境 - 我们能否成功地将 MoE 应用于参数高效微调(PEFT)方法,例如(IA)3 (Liu等人, 2022) 或 LORA (Hu 等人, 2021) 只调整了少得多的参数。 这是一个重大挑战,不仅因为我们的目标是仅更新所有参数的一小部分,而且因为我们还要应对先前工作中已经注意到的 MoE 固有的优化挑战(Chen 等人,2022)在更加受限的环境中。

在这项工作中,我们提出了一个新框架,在严重受限的计算环境中利用 MoE 的优势。 我们引入了Mixture of Vectors (MoV)和Mixture of LORA (MoLORA),这是专家混合方法的参数高效适应。 与标准 MoE 不同,我们的框架由于其轻量级性质,可以在参数有限的设置中使用。 值得注意的是,我们的方法通过更新不到 1% 的参数,对未见过的任务进行全面微调,从而实现了性能平价。 它还可以轻松胜过 (IA)3 或 LORA 等基本参数高效技术。

我们在 55 个数据集 P3 (Sanh 等人,2022)的 12 不同任务中,在 T5 模型 (Raffel 等人,2020) 上取得了一致的结果,范围从 770M 到 11B 。 总之,我们的贡献如下:

  1. (我) 

    我们提供参数极其高效的 MoE。 该架构利用模块化和轻量级专家在更现实的环境中利用 MoE。 我们的 MoE 可以通过更新不到 1% 的参数来调节密集模型。

  2. (二) 

    使用我们提出的方法进行指令微调在未见过的任务上始终优于传统的参数有效方法,同时在不同尺度上保持高参数效率。 在 3B 和 11B 模型尺寸下,(IA)3 向量 (MoV) 的混合比标准 (IA)3 分别实现了高达 14.57% 和 8.39% 的改进。 这种优势适用于不同的模型大小、专家类型和可训练参数预算。

  3. (三) 

    我们证明,我们的配方可以在大范围内匹配完全微调的性能,同时更新一小部分模型参数。 我们在 8 个未见过的任务中的结果表明,我们的 MoV 仅更新了 3B 和 11B 模型中 0.32% 和 0.86% 的参数,在完全微调方面实现了极具竞争力的性能,同时显着降低了计算成本。

  4. (四) 

    最后,我们提出了一系列广泛的消融研究,系统地评估了各种 MoE 架构和 PEFT 策略在不同模型大小、不同适配器类型、专家数量、路由机制以及优化超参数的重要性下的功效,特别是考虑到教育部的敏感性。

2方法论

指令调整设置是这样制定的,其中有一组任务分为训练任务和保留评估任务𝑇=𝑇train∪𝑇eval。 基本预训练模型首先在 𝑇𝑡​𝑟​𝑎​𝑖​𝑛 上进行微调,然后以零样本的方式对 𝑇𝑒​𝑣​𝑎​𝑙 中每个未见过的任务进行评估。 标准方法是微调所有导致高计算和内存成本的模型参数。 我们的方法提供了一种使用参数有效的专家组合的有效替代方案。 在本节中,我们详细描述我们的框架。

2.1使用(IA)3和LORA适配器进行参数高效的微调

在这项工作中,我们使用参数高效微调 (PEFT) 方法将专家混合 (MoE) 架构推向参数效率的极限。 PEFT 方法通过将权重更新限制为有限数量的参数,解决了与更新大量参数相关的挑战,尤其是在完全微调大语言模型时大规模出现的挑战。 为了展示我们的方法如何使用不同的 PEFT 技术进行扩展,我们对 (IA)3 和 LORA 进行了实验。 这些方法向现有的预训练模型添加少量参数。 下面我们简单介绍一下每种PEFT方法:

(IA)3 引入了三个新向量,𝑙k∈ℝ𝑑k、𝑙v∈ℝ𝑑v、𝑙ff∈ℝ𝑑ff,它们重新缩放自注意力和中间值中的键和值激活位置前馈层中的激活:

softmax​(𝑄​(𝑙k⊙𝐾𝑇)𝑑k)​(𝑙v⊙𝑉);(𝑙ff⊙𝛾​(𝑊1​𝑥))​𝑊2((IA)3)

其中 𝑄、𝐾、𝑉 是用于自注意力的查询、键和值投影矩阵,𝑊1、𝑊2 是预训练模型中前馈层的冻结权重。 由于 (IA)3 仅更新每个 Transformer 层的 𝑙k、𝑙v、𝑙ff 重新缩放向量1,它的参数效率极高。 对于30亿参数的T5模型(Raffel等人,2020),它只更新总参数中的0.018%。

请注意,与适配器 (Houlsby 等人, 2019) 或提示调整 (Lester 等人, 2021) 不同,(IA)3

Refer to caption

1class MOV_Layer(nn.module):2 n_experts: int # number of experts34 def call(self, inputs):5 # inputs shape: [batch, seq, h_dim]6 batch, seq, h_dim = inputs.shape78 # MOV scaling vectors: [n_experts, h_dim]9 mov_vectors = self.param(’mov_scalers’,10 nn.init.ones(), (self.n_experts, h_dim))1112 # router probs: [batch, seq, n_experts]13 router_probs = self.router(inputs,14 self.n_experts, dtype=’float32’)1516 # combined vector: [batch, seq, h_dim]17 mov_combined = jnp.einsum(’...e,ed->...d’,18 router_probs,19 mov_vectors)2021 return inputs * mov_combined

图2:左边:MoV 架构概述,强调软合并,其中每个多头注意力块仅更新向量和路由器,如颜色所示。 :类似于 JAX 的伪代码,说明了 MoV 层的核心实现。

低秩自适应 (LORA; Hu 等人, 2021)优化大语言模型中密集层的低秩分解。 对于预训练的权重矩阵 𝑊0∈ℝ𝑑m×𝑑p 和输入激活 𝑥∈ℝ𝑑m,LORA 将 𝑊0 分解为两个低秩矩阵:

ℎ=𝑊0+Δ​𝑊𝑥=𝑊0+𝐵​𝐴​𝑥(LORA)

其中 𝐵∈ℝ𝑑p×𝑟 𝐴∈ℝ𝑟×𝑑m 和排名 𝑟=min⁡(𝑑m,𝑑p)。 在微调期间,所有预训练权重都被冻结,并且仅更新 𝐴 和 𝐵 矩阵。

LORA 适配可用于每个 Transformer 块中的所有线性层,包括查询 𝑄、键 𝐾、值 𝑉 和输出 𝑂 自注意力和前馈层 𝑊1 和 𝑊2。 与(IA)3不同,LORA自适应在使用的参数方面提供了更大的灵活性。 我们可以通过增加矩阵分解的等级 𝑟 来调整容量,直到达到由 𝑟=min⁡(𝑑m,𝑑p) 确定的最大值。 为了说明其参数效率,对于T5 3B模型,等级为4的LORA更新模型参数的0.3%。

2.2极其参数高效的专家组合

我们提出了一种参数效率极高的专家混合(MoE)框架,该框架利用轻量级“适配器”作为预训练密集模型之上的专家。 具体来说,MoE 是一个神经网络架构家族,它可以通过基于门控机制(路由器)激活的多个专家来进行条件计算。 MoE 层由路由器网络 𝑅 和一组 𝑛 专家 𝐸1,…,𝐸𝑛 组成,其中每个专家 𝐸𝑖 都是参数化函数。 遵循 Fedus 等人 (2022),我们的路由器网络通常由具有可训练权重 𝑊𝑔∈ℝ𝑑m×𝑛 的密集层组成,后跟一个 softmax 函数,该函数采用中间值词符表示 𝑥 作为输入,并根据门控分数 𝑠1,…,𝑠𝑛 组合每个专家的输出:

𝑠𝑖=𝑅​(𝑥)𝑖=softmax​(𝑊𝑔𝑇​𝑥)(Router)
𝑦=∑𝑖=1𝑛𝑠𝑖⋅𝐸𝑖​(𝑥)(MoE)

对于 Transformer 模型(Vaswani 等人,2023),密集前馈层被 MoE 层取代,其中每个专家 𝐸𝑖 对应一个独立的密集前馈网络。 随着每个专家规模和专家数量的增加,模型参数的总数会成倍增加。 然而,在我们的参数高效 MoE 架构中,我们用轻量级 PEFT 适配器(例如 (IA)3 向量或 LORA 适配器)替换每个专家。 在微调过程中,密集层的预训练权重保持固定,而专家层和路由器层则从头开始训练。 与标准 MoE 不同,我们的轻量级专家学习在微调时间内调整预训练的 Transformer 层。 这样,我们的 MoE 框架需要有限数量的参数更新,并且总共不会引入巨大的模型大小。

除了参数效率之外,我们选择的 PEFT 适配器还可以通过软合并进行路由计算。 具体来说,由于 (IA)3 向量和 LORA 适配器都是线性函数,因此我们首先计算专家的加权平均值,然后使用类似于 Muqeeth 的组合专家 𝐸𝑚​𝑖​𝑥 进行 PEFT 变换等人(2023):

𝐸𝑚​𝑖​𝑥=∑𝑖=1𝑛𝑠𝑖⋅𝐸𝑖;𝑦=𝐸𝑚​𝑖​𝑥​(𝑥)(Soft Merging)

我们将方法的变体称为向量混合(MoV)和LORA混合(MoLORA)分别利用 (IA)3 向量或 LORA 适配器作为专家,两者都比相应的 PEFT 方法表现出一致的增益。 图2显示了MoV层的架构以及相应的伪代码。 仅通过 MoV 和 MoLORA 更新一小部分参数不仅对训练而且对推理时间都有多种实际好处,后者是 MoE 架构所独有的。 我们在下面简要概述了这些收益:

训练效率 我们极其参数高效的 MoE 公式可显着减少记忆力。 训练期间冻结大多数参数减少了计算模型参数梯度的计算开销,同时也减少了存储模型优化器状态的内存需求。 后者可能非常重要,具体取决于优化器的选择,例如 Adam (Kingma & Ba,2017) 的变体,包括 AdamW (Loshchilov & Hutter,2019) ,需要每个参数所需内存的两倍来存储优化器状态(第一和第二时刻的估计),而 Adafactor (Shazeer & Stern, 2018) 通过对二阶参数矩。

推理效率 我们的 MoV 和 MoLORA 方法固有的结构模块化可以在推理时显着提高内存。 对于传统的 MoE 模型,在推理时需要将成熟的前馈块的许多副本(甚至基于特定架构的模型的完整副本)存储在内存中,这是一项昂贵的工作。 使用我们的方法,无论具体类型如何,除了轻量级参数高效专家之外,只需要在内存中存储模型主干的单个副本。 这导致推理时的内存需求显着减少。

3实验

数据集我们使用公共提示池(P3)数据集Sanh等人(2022)中的一套全面的提示指令进行指令调优实验。 我们遵循与 Raffel 等人 (2020) 相同的过程,其中每个任务都转换为 (Sanh 等人, 2022) 中提供的模板格式。 P3 是 62 个数据集的集合,涵盖各种任务。

实验设置 对于基础预训练模型,我们使用 T5 v1.1+LM 适配(Lester 等人, 2021),其中包括从 770M 到 11B 不同大小的 T5 模型参数。 对于所有实验,我们使用 Adafactor 优化器 (Shazeer & Stern,2018) 进行学习,学习率为 3​𝑒−4。 我们将输入的序列长度设置为 1024,将 Sanh 等人 (2022) 之后的目标序列长度设置为 256。 对于所有参数高效的 MoE 变体,我们使用超过 500K 步的批量大小 32 来构建 T5 模型。

基线我们将参数高效专家的组合与作为完全微调模型的T0基线以及标准参数高效微调方法(IA)3和LORA进行比较。 对于 T0 基线,根据我们使用不同超参数的实验,我们发现较大的批量大小和学习率会带来更好的性能,因此,我们通过微调 10k 步骤、批量大小为 256 和学习率来复制 T0的1​𝑒−3,遵循Phang等人(2023)——这些超参数取得了明显更高的结果,如表4所示。 对于(IA)3和rank=4的LORA,我们使用相同的训练超参数,例如3​𝑒−4的学习率和超过500k步的32个批次。

指标 按照 T0 Sanh 等人 (2022) 中提出的零样本评估,我们在 8 个保留的(训练期间未见的)数据集上测试我们的方法和基线 – ANLI (Nie 等人, 2020)、HellaSwag (Zellers 等人, 2019)、WinoGrande (Sakaguchi 等人, 2019) 和 5 Super Glue 数据集Wang 等人 (2020)。 这些数据集涵盖了不同的任务,包括共指消解、自然语言推理、多项选择题回答、故事完成和词义消歧。 我们计算不同提示模板中每个评估数据集的准确度中位数,然后报告每个数据集的结果以及所有数据集的平均值。 我们还在附录中列出了所有评估数据集的平均准确度。

基础设施 所有实验均在最多 256 个 pod 切片的 TPU v4 机器上进行。 对于所有实验模型的训练、评估和推理,我们使用了 SeqIO 和 T5X (Roberts 等人,2022) 框架,这些框架通过集成的顺序数据处理实现跨 TPU 内核的数据和模型并行化。

3.1消融

鉴于迄今为止还没有在参数效率极高的设置中研究 MoE 的工作,我们还试图通过运行严格的消融来了解我们提出的方法的关键特征。 我们简要详细介绍两者以及下面的实验设置:

路由输入:词符 vs 句子嵌入 以指令嵌入形式呈现的任务表示的明显归纳偏差如何影响路由和下游泛化? 在我们的主要 MoV 和 MoLORA 方法中,路由器层将输入 Token 的中间嵌入作为输入,类似于其他 MoE 架构(Shazeer 等人,2017;Fedus 等人,2022)。 然而,作为替代方案,可以为每条指令计算一个句子嵌入(提示相应的输入),并将其用作路由器(Ye等人,2022)的输入。 为了比较两者,每条指令的句子嵌入都是使用 Sentence-T5 编码器 (Ni 等人,2022) 导出的,并使用 T5-XL 检索模型 (Ni 等人,2021)进行训练。 该编码器是根据预训练的 T5 进行初始化的,并根据 Ni 等人 (2022) 中所述的不同数据源进行训练。 在没有额外微调的情况下,传递由提示模板和输入句子组成的每个指令序列来检索维度为768的嵌入。

路由策略:软路由与离散路由 参数高效 MoE 中的最佳路由策略是什么? 在我们的 MoE 框架中,我们使用专家的软合并作为路由策略。 软合并是指在指定路由块内计算的所有专家的加权平均值。 作为替代方案,标准 MoE 架构中使用的离散 top-k 路由策略引入了稀疏性并减少了计算量(Shazeer 等人,2018;Fedus 等人,2022)。 在 top-k 路由方法中,不是考虑所有专家进行决策,而是仅选择由路由器确定的前“k”个专家进行计算。 请注意,虽然计算取决于前 k 个专家,但所需的内存取决于专家的总数。

我们用𝑘={1,2}评估top-k选择,因为它们是由之前的工作(Shazeer等人,2017;Fedus等人,2022)提出的。 4.4 节详细阐述了这些策略的结果。 此外,我们按照Fedus等人(2022)使用负载平衡评估具有top-k的离散路由,通过辅助损失促进平衡的top-k选择,旨在专家之间公平的工作量分配。

4结果与讨论

Zero-shot Results at 3B Scale

Model% Params.ANLICBRTEWSCWICCopaWNGHSAverage
Full-FTT0-3B (Sanh et al., 2022)100%33.4650.064.0864.4250.3974.9250.5127.5151.91
T0-3B (our replication)100%41.0880.3676.1753.3753.9288.9457.4629.1960.06
PEFT (IA)30.018%34.0850.066.4356.2555.4179.0852.0929.9152.90
LORA0.3%37.575.5773.5361.0251.2583.654.3325.3257.51
Our Method MoV-100.32%38.9275.078.8862.552.1985.7755.9630.2459.93
MoV-300.68%38.778.5780.8763.4651.187.2556.2728.6360.61
MoV-601.22%38.8376.7974.5560.152.6689.7955.4930.4759.83
MoLORA-103.18%38.578.5778.1663.4650.8686.555.4126.7259.77
MoLORA-154.69%40.080.3680.5162.9850.8689.055.3327.360.79

表1:使用 T5-3B,针对完整模型微调 (T0)、参数高效参数方法((IA)3 和 LORA)以及我们的参数高效专家组合(MoV 和 MoLORA)在未见任务上的平均中值结果基本模型(Raffel 等人,2020)。 请注意,我们复制的 T0 的性能明显高于原始 T0,这证实了之前的工作(Phang 等人,2023;Ivison 等人,2023)。

Parameter efficient MoEs vs PEFTs How does our MoE recipe compare to a single expert PEFT? Table 4 compares zero-shot performance of PEFTs methods ((IA)3 and LORA), and our variants of parameter-efficient MoE (MoV and MoLORA), using T5-3B as the base model. We observe that our MoE variants (MoV and MoLORA) present a significant performance boost over the standard (IA)3 vectors and LORA adapters.

MoV using 30 experts achieves a 14.57% performance improvement compared to its dense counterpart (IA)3. This improvement is consistent across all unseen tasks and is achieved at a marginal increase in the number of updated parameters – only an additional 0.018% parameters per expert. In the context of LORA, our MoLORA equipped with 15 experts, achieves an average median score increase of 5.70%. This improvement is notably less significant when compared to MoV. We attribute this disparity to the difference in updated parameter count in LORA adapters and (IA)3 vectors (0.3% vs 0.018%). Overall, learning a mixture for both MoV and MoLORA as opposed to a single dense model leads to notable gains in zero-shot performance.

MoV outperforms MoLORA given same parameter budget Between our methods, MoV achieves a better performance-parameter cost trade-off at 3B parameters base model. As shown in the left plot in figure 1 MoV with 30 experts, only updating 0.68% of all parameters, achieves nearly the same performance as MoLORA with 15 experts that updates 4.69% of parameters. This shows the effectiveness of our MoE approaches even with tiny experts at a large base model scale.

Parameter efficient MoEs vs full fine-tuning How does MoE compare to updating all parameters during finetuning? As shown in Table 4 when compared to fully fine-tuned T0-3B, our proposed methods, MoV and MoLORA both with 10 experts, are on par with full fine-tuning. This is impressive as MoV-10 only updates 0.32% of all model parameters. Furthermore, when increasing the number of experts from 10 to 15 and 30 for MoV and MoLORA respectively, our both methods outperform the full fine-tuning by a small margin.

Refer to caption

Figure 3:Comparison of the top-performing variants from our proposed mixture of PEFT experts versus their dense counterparts across T5-Large (Left) and T5-XL (Right).

4.1How do parameter-efficient MoEs scale with base model size?

Figure 1 (right) shows the scaling characteristic of MoV with 60 experts compared with (IA)3 and full fine-tuning for 770M, 3B and 11B parameters base models. We find that across all model sizes we evaluate, our parameter-efficient MoEs consistently maintain higher performance compared to standard PEFTs and achieve comparable results with full fine-tuning.

MoV benefits from scaling At all model sizes, MoV-60 significantly outperforms standard (IA)3. It is also far closer in performance to full fine-tuning than a single expert. For example, at 770M parameters, there is a 12.34% performance gap between (IA)3 and full fine-tuning vs 5.56% for MoV-60. As the base model scales up, MoV becomes more competitive with full fine-tuning. For 3B and 11B parameter models, MoV-60 achieves performance approximately on par with the full fine-tuning, despite updating less than 1.3% of the total parameters.

MoLORA outperforms MoV in smaller model size regimes As discussed in the main results, at larger model sizes MoV achieves a better performance-parameter efficiency trade-off compared to MoLORA. Conversely, at the 770M scale, MoLORA with 10 experts that updates 3.18% of total parameters, performs better compared to MoV-60 and nearly matches the performance of full fine-tuning (Figure 3). Finally, similar to MoV, MoLORA archives higher performance than LORA at both 770M and 3B scales.

4.2How does the number of experts impact the downstream performance?

The center plot of Figure 4 shows the performance of MoV with different numbers of experts at all model sizes. We find that increasing the number of experts generally improves unseen task performance. However, this improvement is contingent upon the specific number of experts and the base model size. For both 770M and 11B parameter base models, our MoV method achieves its best performance by using 60 experts. To illustrate, when number of experts is increased from 10 to 60, the average median accuracy improves from 52.47 to 53.63 for the 770M model and from 62.3 to 64.08 for the 11B model. However, for the 3B model, using just 30 experts, updating 0.68% of the parameters, reaches peak accuracy with a score of 60.61 at this scale, as performance stagnates when 60 experts are used.

This trend of performance improvement by scaling more experts is further corroborated in the context of MoLORA; when scaling experts from sets of (5, 10, 15), there was a corresponding elevation in the average median score, registering at 58.6, 59.77, and 60.79, respectively.

Refer to caption

Figure 4:Left: Zero-shot performance of passing embedding of the token sequence to the router vs. passing tokens to the router. Middle: Zero-shot performance across T5 model sizes (Large, XL, XXL) as the number of experts increases. Right: The effectiveness of activating top-k experts.

4.3What is the best routing strategy in parameter-efficient MoEs?

In Figure 4, the rightmost plot shows the overall unseen task performance when using different routing strategies for MoV. Specifically, we compare the soft merging of 10 experts (dashed line) with discrete top-2 and top-1 routing. We observe that soft merging significantly outperforms discrete routing in the MoV-10 setting. Specifically, for discrete routing with top-k experts, where k is 1 and 2, the MoE achieves an average median accuracy of 54.92 and 57.45 respectively. In contrast, using the soft merging approach, where all experts are activated, we observe an accuracy of 59.93.

Furthermore, to understand if we recover the performance loss of top-k routing by using load balancing, we integrated the loss balancing following to Fedus et al. (2022). However, we find that the top-k selection of 𝑘=2 with load balancing loss leads to a further decrease in performance 1.5 average median score.

Together, these results show that in extremely parameter-efficient MoE settings, soft merging enables superior performance. Note that top-2 and top-1 routing strategies (among 10 experts) perform better than MoV with only 2 experts and a single expert (IA)3 respectively, showing that soft merging performs better when a larger number of experts are used.

4.4Does a pronounced task information in routing lead to higher performance?

To understand the effects of a pronounced inductive bias towards task representations in our MoE framework, we compare using sentence embeddings of instructions with token embeddings for the routing input. These sentence embeddings are obtained offline using an external sentence embedding model. Here, we aim to evaluate how pronounced task information affects the router’s decision and the subsequent generalization capabilities of the model in downstream tasks. Figure 4 leftmost plot shows performances of token routing and sentence routing at all model sizes. We find that the token routing exhibits superior performance with 3.03%, 8.86%, and 0.94% improvement for 770M, 3B, and 11B base model sizes respectively. These results suggest that a higher degree of inductive bias for task datasets is not necessarily beneficial as our approaches can acquire a diverse set of task knowledge directly from the hidden representations of tokens. Furthermore, token routing enables the use of learned experts and routing layers without any prior task information for unseen tasks.

Refer to caption

Figure 5:Mean expert routing probabilities for intermediates activations at the last feedforward layer. Values are averaged across tokens and batch. Experts are weighted differently in soft merging depending on the task. Left: Measured on tasks seen during training. Right: Measured on unseen evaluation tasks.

4.5Do experts specialize in diverse knowledge across different tasks?

To understand how expert routing differs for different tasks, we take a closer look at how experts are activated for a variety of tasks. Figure 5 shows the mean expert probabilities for MoV with 5 experts that are located in feed-forward layers in the last decoder block at 770M parameter T5 model. We selected the last decoder block as it has been shown deeper layers learn more task-specific information (Rogers et al., 2020). We plot the mean routing probabilities for both training tasks and evaluation tasks that are unseen during training, to understand cross-task generalization through the lens of experts if skills learned at training time generalize to unseen tasks at evaluation time. Intuitively, if experts have indeed learned different skills, we expect that they contribute in different degrees to tasks that are different in nature. The amount of contribution is directly reflected in the routing probability of each expert since we use soft merging i.e. summation of expert vectors weighted by the routing probability as described in Figure 2. As such, the mean routing probabilities plotted in Figure 5 provide an overall picture of the contribution of each expert, depending on the downstream task.

Specialization across unseen vs seen tasks As depicted in Figure 5, both evaluation and training tasks lead to the activation of experts at different magnitudes. For example, both quail and super_glue_cb activate Expert 3 the most out of the 5 experts, followed by Expert 4 but are different both in terms of the relative contribution of each expert and the ordering of the remaining 3 experts based on routing probability. A similar pattern can be observed for common_gen & winogrande as they both activate Expert 2 the most but are otherwise different. Overall, the fact that routing specialization seems to occur regardless of whether the downstream task was trained on, suggests that expert specialization is inherent and transferable from seen tasks to unseen tasks.

4.6Hyper-parameters Sensitivity

Given the widely documented sensitivity of MoE-style architecture to hyperparameters (Fedus et al., 2022; Shazeer et al., 2017), we ran extensive ablation studies to uncover the idiosyncrasy of PEFT methods in the context of MoE. We experimented with batch sizes of 32, 128, 256, and 2048 and we found that the larger the batch size, the more likely our MoEs to collapse to a single expert. Our empirical finding resonates with Shen et al. (2023) which also finds that a small batch is necessary for stable training. For instance, by experimenting with a batch size of 2048 and evaluating every 5K steps up to 20K, we observed that the performance of our parameter-efficient MoEs deteriorates after 5K steps, converging to performance levels akin to their dense counterparts. Additionally, we experimented with varying learning rates from 3​𝑒−3 to 6​𝑒−4 where we discovered for our methods, a smaller learning rate of 3​𝑒−4 leads to higher performance relative to their dense PEFT counterpart and full fine-tuning. Smaller learning rates stabilize training in parameter-efficient experts by preventing rapid, imbalanced updates that can suppress diversity and lead to suboptimal solutions.

5Related Work

Mixture-of-Experts The Mixture-of-Experts (MoE) has been investigated thoroughly in Natural Language Processing (Lou et al., 2022; Mustafa et al., 2022; Shazeer et al., 2017; Lepikhin et al., 2020; Fedus et al., 2022; Du et al., 2022; Zoph et al., 2022; Clark et al., 2022; Zhou et al., 2022; Komatsuzaki et al., 2023; Kudugunta et al., 2021; Zuo et al., 2022) as an effective way of increasing the model’s capacity in parameter size where certain parts of the model are activated while computation is kept the same or close to its dense counterpart. In the context of MoE, there is a body of work focusing on improving the routing (Hazimeh et al., 2021; Lewis et al., 2021; Roller et al., 2021; Zhou et al., 2022) including random routing (Zuo et al., 2022) activating all expert through weighted average (Eigen et al., 2014) to sparsely select a single or 𝑘 experts (Fedus et al., 2022; Du et al., 2022). MoE has also been invested in multi-task settings including multilingual neural machine translation(Hazimeh et al., 2021; Kudugunta et al., 2021). Unlike these studies, our research addresses MoE by scaling both the volume of data and the number of tasks, aiming to mitigate the instability inherent in training the MoE models. But our primary emphasis remains on achieving efficient fine-tuning. Recently, Shen et al. (2023) highlighted how instruction fine-tuning with scaled tasks can counteract the generalization challenges tied to MoE models. In distinction from this, our study scrutinizes the efficacy of instruction fine-tuning in the MoE domain, specifically concentrating on a unique ensemble of the PEFT components, considering the memory cost of the traditional MoE can be prohibitive for many practitioners. Similar to the aforementioned work, Ye et al. (2022) utilized MoE in a multi-task context, employing BART Lewis et al. (2019) as their pre-trained model. However, they limited their experimental scope to a smaller scale and used replicas of each transformer layer as experts, simply multiplying the model by the number of experts. Our work, on the other hand, presents an extreme parameter efficiency with small experts at a large scale up to 11B parameter base model.

Instruction Tuning Instruction tuning, as elucidated in (Sanh et al., 2022; Wei et al., 2022; Mishra et al., 2022), is a technique where a language model is fine-tuned over a collection of tasks using paired prompts and responses. The primary goal of this technique is to enable the model to predict responses accurately based on the provided prompts, thereby augmenting its ability to understand and execute instructions effectively. The method has gained considerable attention due to its pronounced success in enhancing zero-shot performance on tasks to which the model has not been previously exposed. Additionally, instruction tuning has led to breakthroughs such as Chain of Thought Prompting (Wei et al., 2023) where a breakdown of complex problems into smaller steps to produce intermediate reasoning along with the final solution, PaLM (Chowdhery et al., 2022), FLAN (Wei et al., 2022). In our work, we explore the use of instruction fine-tuning with the intention of harnessing its benefits that enable the model to learn from a diverse set of inputs where the mixture of expert style models suits well, for enhanced evaluation performance on unseen tasks. Our objective remains to optimize computational efficiency without compromising zero-shot performance.

Parameter-Efficient Fine-tuning. Houlsby et al. (2019) established "adapters" in the NLP domain to fine-tune BERT. There are many variants of adapters with different design choices (Bapna et al., 2019; Pfeiffer et al., 2021). Li & Liang (2021) proposed updating soft prompts concatenated to embeddings or layer outputs instead of adapters. Zaken et al. (2022) show that just updating only a small subset of parameters during fine-tuning (e.g. just biases) is very effective. Hu et al. (2021) proposed LORA based on low-rank decomposition matrices of transformer layers. They show superior performance with a smaller parameter budget and no inference cost as LORA parameters can be applied offline to the baseline model. Liu et al. (2022) proposed (𝐼​𝐴)3, task-specific vectors to modify attention activation. Instead of using feedforward layers inserted in transformer layers as adapters, they learn vectors to update (by broadcast multiplication) key, value, and linear layer weight matrices. Unlike the other PEFT methods, (IA)3 does not induce any additional inference cost and enables mix-batches (from different datasets). The multiplicative nature of the (IA)3 creates an interesting opportunity for the mixture-of-expert type of modeling without parallelization overhead. Chen et al. (2023) experiment with different design spaces (essentially a hyperparameter search) for PEFT. They suggest four phases: 1) grouping layers into different sets; 2) adding trainable parameters towards each group; 3) deciding which group should be trained; 4) assigning groups with different training strategies. Their finding is that different architectures have different best settings. We have chosen (𝐼​𝐴)3 and LORA as our PEFT components because they offer an optimal balance between performance and parameter efficiency (Mahabadi et al., 2021; Liu et al., 2022).

Several studies have explored PEFT in the context of MoE or in a similar fashion, albeit with certain distinctions. For instance, Wang et al. (2022) focused on single-task fine-tuning employing a mixture of adapters for BERTbase with 110M parameters (Devlin et al., 2019) and 𝑅​𝑜​𝐵​𝐸​𝑅​𝑇​𝑎𝑙​𝑎​𝑟​𝑔​𝑒 with 355M parameters (Liu et al., 2019), incorporating random routing, and adopting a few-shot evaluation. In divergence from this, our work centers on instruction-tuning with multiple tasks present during fine-tuning. We underscore the efficacy of this approach by rigorously testing up to 11B parameter text-to-text model Raffel et al. (2020), implementing token routing, and strictly emphasizing evaluation on a set of unseen (held-out) tasks to underscore the potential of instruction tuning. In another work, Ponti et al. (2022) introduced Polytropon, which involves learning adapters (termed as ’skills’) specific to each task and employing a task-skills binary matrix to determine the skill set associated with each task. In their method, input examples dictate the selection of adapters. These adapters are then aggregated, and the resultant single adapter is integrated into the overall architecture. Extending upon the Polytropon framework, Caccia et al. (2023) implemented a distinct skill set for every layer in their variant named Polytropon-S. They introduce a deterministic routing function, delve into supplementary inductive biases, show effectiveness up to 3B models, and they don’t employ MoE style architecture. Our research presents a departure from these two studies. Specifically, our primary experimental setup employs MoEs that do not require any specific task identifier during fine-tuning by the use of their token routing strategy. In this way, we can evaluate our instruction-tuned MoEs on unseen tasks without any further task-specific few-shot fine-tuning. We showed the scaling property of our MoEs in this setting by fine-tuning models up to 11B parameters.

6Conclusion

This work introduces MoEs in an extremely computationally limited environment. We propose introduce the Mixture of Vectors (MoV) and Mixture of LoRA (MoLORA) to mitigate the challenges associated with scaling instruction-tuned LLMs at scale. Our method outperforms parameter-efficient techniques and achieves performance parity with full fine-tuning on unseen tasks by updating less than 1% of the 3B and 11B model parameters. This percentage may vary depending on the base model size and the number of experts involved. Our extensive experiments, including rigorous ablations across model sizes, representation of tokens vs embeddings, soft vs top-k routing, confirm the effectiveness of our approach across diverse unseen tasks, highlighting its superior accuracy and computational efficiency. Furthermore, our framework’s versatility seamlessly integrates with other parameter-efficient strategies and remains compatible with efficiency-enhancing techniques such as quantization.

Limitations A primary constraint of our experimental framework is its focus on text-to-text models, such as T5, without extending the evaluation to decoder-only such as GPT style models. We leave this as the subject of future work. Additionally, our assessment is exclusively within the context of fine-tuning. Exploration of its efficacy during the pre-training phase remains an avenue for future research.

References

  • Anil et al. (2023)Rohan Anil, Andrew M. Dai, Orhan Firat, Melvin Johnson, Dmitry Lepikhin, Alexandre Passos, Siamak Shakeri, Emanuel Taropa, Paige Bailey, Zhifeng Chen, Eric Chu, Jonathan H. Clark, Laurent El Shafey, Yanping Huang, Kathy Meier-Hellstern, Gaurav Mishra, Erica Moreira, Mark Omernick, Kevin Robinson, Sebastian Ruder, Yi Tay, Kefan Xiao, Yuanzhong Xu, Yujing Zhang, Gustavo Hernandez Abrego, Junwhan Ahn, Jacob Austin, Paul Barham, Jan Botha, James Bradbury, Siddhartha Brahma, Kevin Brooks, Michele Catasta, Yong Cheng, Colin Cherry, Christopher A. Choquette-Choo, Aakanksha Chowdhery, Clément Crepy, Shachi Dave, Mostafa Dehghani, Sunipa Dev, Jacob Devlin, Mark Díaz, Nan Du, Ethan Dyer, Vlad Feinberg, Fangxiaoyu Feng, Vlad Fienber, Markus Freitag, Xavier Garcia, Sebastian Gehrmann, Lucas Gonzalez, Guy Gur-Ari, Steven Hand, Hadi Hashemi, Le Hou, Joshua Howland, Andrea Hu, Jeffrey Hui, Jeremy Hurwitz, Michael Isard, Abe Ittycheriah, Matthew Jagielski, Wenhao Jia, Kathleen Kenealy, Maxim Krikun, Sneha Kudugunta, Chang Lan, Katherine Lee, Benjamin Lee, Eric Li, Music Li, Wei Li, YaGuang Li, Jian Li, Hyeontaek Lim, Hanzhao Lin, Zhongtao Liu, Frederick Liu, Marcello Maggioni, Aroma Mahendru, Joshua Maynez, Vedant Misra, Maysam Moussalem, Zachary Nado, John Nham, Eric Ni, Andrew Nystrom, Alicia Parrish, Marie Pellat, Martin Polacek, Alex Polozov, Reiner Pope, Siyuan Qiao, Emily Reif, Bryan Richter, Parker Riley, Alex Castro Ros, Aurko Roy, Brennan Saeta, Rajkumar Samuel, Renee Shelby, Ambrose Slone, Daniel Smilkov, David R. So, Daniel Sohn, Simon Tokumine, Dasha Valter, Vijay Vasudevan, Kiran Vodrahalli, Xuezhi Wang, Pidong Wang, Zirui Wang, Tao Wang, John Wieting, Yuhuai Wu, Kelvin Xu, Yunhan Xu, Linting Xue, Pengcheng Yin, Jiahui Yu, Qiao Zhang, Steven Zheng, Ce Zheng, Weikang Zhou, Denny Zhou, Slav Petrov, and Yonghui Wu.Palm 2 technical report, 2023.
  • Bapna et al. (2019)Ankur Bapna, Naveen Arivazhagan, and Orhan Firat.Simple, scalable adaptation for neural machine translation, 2019.
  • Brown et al. (2020)Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei.Language models are few-shot learners, 2020.
  • Caccia et al. (2023)Lucas Caccia, Edoardo Ponti, Zhan Su, Matheus Pereira, Nicolas Le Roux, and Alessandro Sordoni.Multi-head adapter routing for cross-task generalization, 2023.
  • Chen et al. (2023)Jiaao Chen, Aston Zhang, Xingjian Shi, Mu Li, Alex Smola, and Diyi Yang.Parameter-efficient fine-tuning design spaces, 2023.
  • Chen et al. (2022)Zixiang Chen, Yihe Deng, Yue Wu, Quanquan Gu, and Yuanzhi Li.Towards understanding the mixture-of-experts layer in deep learning.In Alice H. Oh, Alekh Agarwal, Danielle Belgrave, and Kyunghyun Cho (eds.), Advances in Neural Information Processing Systems, 2022.URL Towards Understanding the Mixture-of-Experts Layer in Deep Learning | OpenReview.
  • Chowdhery et al. (2022)Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, Abhishek Rao, Parker Barnes, Yi Tay, Noam Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Ben Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, Michael Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, Sanjay Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier Garcia, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, David Luan, Hyeontaek Lim, Barret Zoph, Alexander Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, Thanumalayan Sankaranarayana Pillai, Marie Pellat, Aitor Lewkowycz, Erica Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathy Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel.Palm: Scaling language modeling with pathways, 2022.
  • Chung et al. (2022)Hyung Won Chung, Le Hou, Shayne Longpre, Barret Zoph, Yi Tay, William Fedus, Yunxuan Li, Xuezhi Wang, Mostafa Dehghani, Siddhartha Brahma, Albert Webson, Shixiang Shane Gu, Zhuyun Dai, Mirac Suzgun, Xinyun Chen, Aakanksha Chowdhery, Alex Castro-Ros, Marie Pellat, Kevin Robinson, Dasha Valter, Sharan Narang, Gaurav Mishra, Adams Yu, Vincent Zhao, Yanping Huang, Andrew Dai, Hongkun Yu, Slav Petrov, Ed H. Chi, Jeff Dean, Jacob Devlin, Adam Roberts, Denny Zhou, Quoc V. Le, and Jason Wei.Scaling instruction-finetuned language models, 2022.
  • Clark et al. (2022)Aidan Clark, Diego de las Casas, Aurelia Guy, Arthur Mensch, Michela Paganini, Jordan Hoffmann, Bogdan Damoc, Blake Hechtman, Trevor Cai, Sebastian Borgeaud, George van den Driessche, Eliza Rutherford, Tom Hennigan, Matthew Johnson, Katie Millican, Albin Cassirer, Chris Jones, Elena Buchatskaya, David Budden, Laurent Sifre, Simon Osindero, Oriol Vinyals, Jack Rae, Erich Elsen, Koray Kavukcuoglu, and Karen Simonyan.Unified scaling laws for routed language models, 2022.
  • Devlin et al. (2019)Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova.Bert: Pre-training of deep bidirectional transformers for language understanding, 2019.
  • Du et al. (2022)Nan Du, Yanping Huang, Andrew M. Dai, Simon Tong, Dmitry Lepikhin, Yuanzhong Xu, Maxim Krikun, Yanqi Zhou, Adams Wei Yu, Orhan Firat, Barret Zoph, Liam Fedus, Maarten Bosma, Zongwei Zhou, Tao Wang, Yu Emma Wang, Kellie Webster, Marie Pellat, Kevin Robinson, Kathleen Meier-Hellstern, Toju Duke, Lucas Dixon, Kun Zhang, Quoc V Le, Yonghui Wu, Zhifeng Chen, and Claire Cui.Glam: Efficient scaling of language models with mixture-of-experts, 2022.
  • Eigen et al. (2014)David Eigen, Marc’Aurelio Ranzato, and Ilya Sutskever.Learning factored representations in a deep mixture of experts, 2014.
  • Fedus et al. (2022)William Fedus, Barret Zoph, and Noam Shazeer.Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity, 2022.
  • Hazimeh et al. (2021)Hussein Hazimeh, Zhe Zhao, Aakanksha Chowdhery, Maheswaran Sathiamoorthy, Yihua Chen, Rahul Mazumder, Lichan Hong, and Ed H. Chi.Dselect-k: Differentiable selection in the mixture of experts with applications to multi-task learning, 2021.
  • Houlsby et al. (2019)Neil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin de Laroussilhe, Andrea Gesmundo, Mona Attariyan, and Sylvain Gelly.Parameter-efficient transfer learning for nlp, 2019.
  • Hu et al. (2021)Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen.Lora: Low-rank adaptation of large language models, 2021.
  • Ivison et al. (2023)Hamish Ivison, Akshita Bhagia, Yizhong Wang, Hannaneh Hajishirzi, and Matthew E Peters.Hint: Hypernetwork instruction tuning for efficient zero-and few-shot generalisation.In Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 11272–11288, 2023.
  • Kaplan et al. (2020)Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B. Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei.Scaling laws for neural language models, 2020.
  • Kingma & Ba (2017)Diederik P. Kingma and Jimmy Ba.Adam: A method for stochastic optimization, 2017.
  • Komatsuzaki et al. (2023)Aran Komatsuzaki, Joan Puigcerver, James Lee-Thorp, Carlos Riquelme Ruiz, Basil Mustafa, Joshua Ainslie, Yi Tay, Mostafa Dehghani, and Neil Houlsby.Sparse upcycling: Training mixture-of-experts from dense checkpoints, 2023.
  • Kudugunta et al. (2021)Sneha Kudugunta, Yanping Huang, Ankur Bapna, Maxim Krikun, Dmitry Lepikhin, Minh-Thang Luong, and Orhan Firat.Beyond distillation: Task-level mixture-of-experts for efficient inference, 2021.
  • Lepikhin et al. (2020)Dmitry Lepikhin, HyoukJoong Lee, Yuanzhong Xu, Dehao Chen, Orhan Firat, Yanping Huang, Maxim Krikun, Noam Shazeer, and Zhifeng Chen.Gshard: Scaling giant models with conditional computation and automatic sharding, 2020.
  • Lester et al. (2021)Brian Lester, Rami Al-Rfou, and Noah Constant.The power of scale for parameter-efficient prompt tuning, 2021.
  • Lewis et al. (2019)Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Ves Stoyanov, and Luke Zettlemoyer.Bart: Denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension, 2019.
  • Lewis et al. (2021)Mike Lewis, Shruti Bhosale, Tim Dettmers, Naman Goyal, and Luke Zettlemoyer.Base layers: Simplifying training of large, sparse models.In Marina Meila and Tong Zhang (eds.), Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pp. 6265–6274. PMLR, 18–24 Jul 2021.URL BASE Layers: Simplifying Training of Large, Sparse Models.
  • Li & Liang (2021)Xiang Lisa Li and Percy Liang.Prefix-tuning: Optimizing continuous prompts for generation, 2021.
  • Liu et al. (2022)Haokun Liu, Derek Tam, Mohammed Muqeeth, Jay Mohta, Tenghao Huang, Mohit Bansal, and Colin Raffel.Few-shot parameter-efficient fine-tuning is better and cheaper than in-context learning, 2022.
  • Liu et al. (2019)Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov.Roberta: A robustly optimized bert pretraining approach, 2019.
  • Longpre et al. (2023)Shayne Longpre, Le Hou, Tu Vu, Albert Webson, Hyung Won Chung, Yi Tay, Denny Zhou, Quoc V. Le, Barret Zoph, Jason Wei, and Adam Roberts.The flan collection: Designing data and methods for effective instruction tuning, 2023.
  • Loshchilov & Hutter (2019)Ilya Loshchilov and Frank Hutter.Decoupled weight decay regularization, 2019.
  • Lou et al. (2022)Yuxuan Lou, Fuzhao Xue, Zangwei Zheng, and Yang You.Cross-token modeling with conditional computation, 2022.
  • Mahabadi et al. (2021)Rabeeh Karimi Mahabadi, Sebastian Ruder, Mostafa Dehghani, and James Henderson.Parameter-efficient multi-task fine-tuning for transformers via shared hypernetworks, 2021.
  • Mishra et al. (2022)Swaroop Mishra, Daniel Khashabi, Chitta Baral, and Hannaneh Hajishirzi.Cross-task generalization via natural language crowdsourcing instructions, 2022.
  • Muennighoff et al. (2023)Niklas Muennighoff, Thomas Wang, Lintang Sutawika, Adam Roberts, Stella Biderman, Teven Le Scao, M Saiful Bari, Sheng Shen, Zheng-Xin Yong, Hailey Schoelkopf, Xiangru Tang, Dragomir Radev, Alham Fikri Aji, Khalid Almubarak, Samuel Albanie, Zaid Alyafeai, Albert Webson, Edward Raff, and Colin Raffel.Crosslingual generalization through multitask finetuning, 2023.
  • Muqeeth et al. (2023)Mohammed Muqeeth, Haokun Liu, and Colin Raffel.Soft merging of experts with adaptive routing, 2023.
  • Mustafa et al. (2022)Basil Mustafa, Carlos Riquelme, Joan Puigcerver, Rodolphe Jenatton, and Neil Houlsby.Multimodal contrastive learning with limoe: the language-image mixture of experts, 2022.
  • Ni et al. (2021)Jianmo Ni, Chen Qu, Jing Lu, Zhuyun Dai, Gustavo Hernández Ábrego, Ji Ma, Vincent Y. Zhao, Yi Luan, Keith B. Hall, Ming-Wei Chang, and Yinfei Yang.Large dual encoders are generalizable retrievers, 2021.
  • Ni et al. (2022)Jianmo Ni, Gustavo Hernandez Abrego, Noah Constant, Ji Ma, Keith Hall, Daniel Cer, and Yinfei Yang.Sentence-t5: Scalable sentence encoders from pre-trained text-to-text models.In Findings of the Association for Computational Linguistics: ACL 2022, pp. 1864–1874, 2022.
  • Nie et al. (2020)Yixin Nie, Adina Williams, Emily Dinan, Mohit Bansal, Jason Weston, and Douwe Kiela.Adversarial nli: A new benchmark for natural language understanding, 2020.
  • Pfeiffer et al. (2021)Jonas Pfeiffer, Aishwarya Kamath, Andreas Rücklé, Kyunghyun Cho, and Iryna Gurevych.Adapterfusion: Non-destructive task composition for transfer learning, 2021.
  • Phang et al. (2023)Jason Phang, Yi Mao, Pengcheng He, and Weizhu Chen.Hypertuning: Toward adapting large language models without back-propagation.In International Conference on Machine Learning, pp. 27854–27875. PMLR, 2023.
  • Ponti et al. (2022)Edoardo M. Ponti, Alessandro Sordoni, Yoshua Bengio, and Siva Reddy.Combining modular skills in multitask learning, 2022.
  • Raffel et al. (2020)Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu.Exploring the limits of transfer learning with a unified text-to-text transformer, 2020.
  • Riquelme et al. (2021)Carlos Riquelme, Joan Puigcerver, Basil Mustafa, Maxim Neumann, Rodolphe Jenatton, André Susano Pinto, Daniel Keysers, and Neil Houlsby.Scaling vision with sparse mixture of experts.Advances in Neural Information Processing Systems, 34:8583–8595, 2021.
  • Roberts et al. (2022)Adam Roberts, Hyung Won Chung, Anselm Levskaya, Gaurav Mishra, James Bradbury, Daniel Andor, Sharan Narang, Brian Lester, Colin Gaffney, Afroz Mohiuddin, Curtis Hawthorne, Aitor Lewkowycz, Alex Salcianu, Marc van Zee, Jacob Austin, Sebastian Goodman, Livio Baldini Soares, Haitang Hu, Sasha Tsvyashchenko, Aakanksha Chowdhery, Jasmijn Bastings, Jannis Bulian, Xavier Garcia, Jianmo Ni, Andrew Chen, Kathleen Kenealy, Jonathan H. Clark, Stephan Lee, Dan Garrette, James Lee-Thorp, Colin Raffel, Noam Shazeer, Marvin Ritter, Maarten Bosma, Alexandre Passos, Jeremy Maitin-Shepard, Noah Fiedel, Mark Omernick, Brennan Saeta, Ryan Sepassi, Alexander Spiridonov, Joshua Newlan, and Andrea Gesmundo.Scaling up models and data with t5x and seqio.arXiv preprint arXiv:2203.17189, 2022.URL https://arxiv.org/abs/2203.17189.
  • Rogers et al. (2020)Anna Rogers, Olga Kovaleva, and Anna Rumshisky.A primer in bertology: What we know about how bert works, 2020.
  • Roller et al. (2021)Stephen Roller, Sainbayar Sukhbaatar, Arthur Szlam, and Jason Weston.Hash layers for large sparse models, 2021.
  • Sakaguchi et al. (2019)Keisuke Sakaguchi, Ronan Le Bras, Chandra Bhagavatula, and Yejin Choi.Winogrande: An adversarial winograd schema challenge at scale, 2019.
  • Sanh et al. (2022)Victor Sanh, Albert Webson, Colin Raffel, Stephen H. Bach, Lintang Sutawika, Zaid Alyafeai, Antoine Chaffin, Arnaud Stiegler, Teven Le Scao, Arun Raja, Manan Dey, M Saiful Bari, Canwen Xu, Urmish Thakker, Shanya Sharma Sharma, Eliza Szczechla, Taewoon Kim, Gunjan Chhablani, Nihal Nayak, Debajyoti Datta, Jonathan Chang, Mike Tian-Jian Jiang, Han Wang, Matteo Manica, Sheng Shen, Zheng Xin Yong, Harshit Pandey, Rachel Bawden, Thomas Wang, Trishala Neeraj, Jos Rozen, Abheesht Sharma, Andrea Santilli, Thibault Fevry, Jason Alan Fries, Ryan Teehan, Tali Bers, Stella Biderman, Leo Gao, Thomas Wolf, and Alexander M. Rush.Multitask prompted training enables zero-shot task generalization, 2022.
  • Shazeer & Stern (2018)Noam Shazeer and Mitchell Stern.Adafactor: Adaptive learning rates with sublinear memory cost.In International Conference on Machine Learning, pp. 4596–4604. PMLR, 2018.
  • Shazeer et al. (2017)Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton, and Jeff Dean.Outrageously large neural networks: The sparsely-gated mixture-of-experts layer, 2017.
  • Shazeer et al. (2018)Noam Shazeer, Youlong Cheng, Niki Parmar, Dustin Tran, Ashish Vaswani, Penporn Koanantakool, Peter Hawkins, HyoukJoong Lee, Mingsheng Hong, Cliff Young, Ryan Sepassi, and Blake Hechtman.Mesh-tensorflow: Deep learning for supercomputers, 2018.
  • Shen et al. (2023)Sheng Shen, Le Hou, Yanqi Zhou, Nan Du, Shayne Longpre, Jason Wei, Hyung Won Chung, Barret Zoph, William Fedus, Xinyun Chen, Tu Vu, Yuexin Wu, Wuyang Chen, Albert Webson, Yunxuan Li, Vincent Zhao, Hongkun Yu, Kurt Keutzer, Trevor Darrell, and Denny Zhou.Mixture-of-experts meets instruction tuning:a winning combination for large language models, 2023.
  • Touvron et al. (2023)Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, and Guillaume Lample.Llama: Open and efficient foundation language models, 2023.
  • Vaswani et al. (2023)Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin.Attention is all you need, 2023.
  • Wang et al. (2020)Alex Wang, Yada Pruksachatkun, Nikita Nangia, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman.Superglue: A stickier benchmark for general-purpose language understanding systems, 2020.
  • Wang et al. (2022)Yaqing Wang, Sahaj Agarwal, Subhabrata Mukherjee, Xiaodong Liu, Jing Gao, Ahmed Hassan Awadallah, and Jianfeng Gao.Adamix: Mixture-of-adaptations for parameter-efficient model tuning, 2022.
  • Wei et al. (2022)Jason Wei, Maarten Bosma, Vincent Y. Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M. Dai, and Quoc V. Le.Finetuned language models are zero-shot learners, 2022.
  • Wei et al. (2023)Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Brian Ichter, Fei Xia, Ed Chi, Quoc Le, and Denny Zhou.Chain-of-thought prompting elicits reasoning in large language models, 2023.
  • Ye et al. (2022)Qinyuan Ye, Juan Zha, and Xiang Ren.Eliciting and understanding cross-task skills with task-level mixture-of-experts, 2022.
  • Zaken et al. (2022)Elad Ben Zaken, Shauli Ravfogel, and Yoav Goldberg.Bitfit: Simple parameter-efficient fine-tuning for transformer-based masked language-models, 2022.
  • Zellers et al. (2019)Rowan Zellers, Ari Holtzman, Yonatan Bisk, Ali Farhadi, and Yejin Choi.Hellaswag: Can a machine really finish your sentence?, 2019.
  • Zhou et al. (2022)Yanqi Zhou, Tao Lei, Hanxiao Liu, Nan Du, Yanping Huang, Vincent Zhao, Andrew Dai, Zhifeng Chen, Quoc Le, and James Laudon.Mixture-of-experts with expert choice routing, 2022.
  • Zoph et al. (2022)Barret Zoph, Irwan Bello, Sameer Kumar, Nan Du, Yanping Huang, Jeff Dean, Noam Shazeer, and William Fedus.St-moe: Designing stable and transferable sparse expert models, 2022.
  • Zuo et al. (2022)Simiao Zuo, Xiaodong Liu, Jian Jiao, Young Jin Kim, Hany Hassan, Ruofei Zhang, Tuo Zhao, and Jianfeng Gao.Taming sparsely activated transformer with stochastic experts, 2022.

AFull Experimental Results

A.1Zero-Shot Evaluation for P3 dataset

In our study, we conducted a comprehensive evaluation of the variants of our proposed methods in comparison to our established baselines. This evaluation encompassed various sizes of the T5 model, specifically 770M, 3B, and 11B. Both mean and median scores were reported for every evaluation set derived from the P3 dataset, which covers a range of tasks. For further details and a more in-depth exploration, please refer to the following URL: https://huggingface.co/datasets/bigscience/P3.

T5-Large (770M)

Model% Params.MetricANLICBRTEWSCWICCopaWNGHSAverage
Full-FTT0-770M (ours)100%median35.671.4375.6357.2151.4177.053.0426.7856.01
mean35.5757.7475.8852.3152.5274.652.9326.7453.54
PEFT (IA)30.036%median33.542.8667.8762.0252.3567.051.2226.3350.39
mean33.2745.1267.0858.1752.7466.6351.3526.3250.09
LoRA0.497%median35.055.3657.463.4650.2477.053.2826.6752.3
mean35.2651.6759.3562.9850.6676.552.4127.2452.0
Our Method MOV-50.27%median33.641.0771.4861.5450.8676.551.4626.0251.57
mean33.5142.6271.2660.9651.1473.851.5526.0151.36
MoV-100.55%median33.942.8674.1962.550.3177.052.6426.3452.47
mean33.6842.3874.5159.2350.7474.8252.226.7251.78
MoV-201.10%median33.741.0773.8363.4650.9475.4651.1425.4851.89
mean33.9845.1273.3659.1351.3373.4751.325.4551.64
MoV-301.66%median33.7541.0772.9255.7751.2577.051.4626.5551.22
mean33.8144.8872.5656.1551.2977.4351.8126.5251.81
MoV-603.32%median34.053.5775.8157.6950.5577.9653.1226.3353.63
mean34.2452.2675.0258.3750.7877.0652.8726.7453.42
MoLoRA-105.60%median33.267.8668.4164.950.3980.052.6452.6455.52
mean33.3756.3168.8863.3751.5579.3552.3152.3153.99

Table 2:Zero-shot evaluation of the 770M parameter model across all unseen tasks, comparing different numbers of experts for both MoV and MoLoRA.

T5-XL (3B)

Model% Params.MetricANLICBRTEWSCWICCopaWNGHSAverage
Full-FTT0-3B (Sanh et al., 2022)100%median33.4650.064.0864.4250.3974.9250.5127.5151.91
mean33.4245.3664.5565.1050.6972.4050.9727.2951.22
T0-3B (our replication)100%median41.0880.3676.1753.3753.9288.9457.4629.1960.06
mean40.7374.5276.8252.2153.8488.9956.8329.259.14
PEFT (IA)30.018%median34.0850.066.4356.2555.4179.0852.0929.9152.90
mean34.5651.0768.3854.955.6178.2352.1428.9752.98
LoRA0.3%median37.575.5773.5361.0251.2583.654.3325.3257.51
mean37.8566.977.0456.7352.2982.8355.6426.7957.01
Our Method MoV-20.18%median34.746.4366.0656.2554.8685.4253.7529.2553.34
mean35.1450.3669.3156.1554.483.7953.6928.4753.91
MoV-50.23%median37.176.7978.1657.6952.2786.7753.9929.3159.01
mean37.6662.1478.358.4653.5486.5254.5428.357.43
MoV-100.32%median38.9275.078.8862.552.1985.7755.9630.2459.93
mean38.8363.4579.4960.1953.0486.4156.2729.1158.35
MoV-200.50%median39.275.076.7157.6953.4589.055.6430.8959.7
mean39.2564.0576.5356.6353.4586.9356.2429.3657.81
MoV-300.68%median38.778.5780.8763.4651.187.2556.2728.6360.61
mean38.967.581.2359.952.4386.2856.3927.5758.77
MoV-601.22%median38.8376.7974.5560.152.6689.7955.4930.4759.83
mean38.9763.9375.3857.7953.586.0455.8829.2857.59
MoV-10 (top-1)0.32%median33.975.071.1261.0650.7170.051.725.8954.92
mean34.3160.671.4158.9451.2468.3951.7925.9852.82
MoV-10 (top-2)0.32%median38.782.1475.6348.0853.6879.8854.1427.3757.45
mean38.8969.7674.9547.6953.5179.8953.8326.9155.67
MoLORA-20.75%median39.282.1480.3262.550.3980.5857.3828.4760.12
mean38.8665.7180.060.050.882.1756.5128.0357.76
MoLORA-51.66%median36.7571.4379.9656.2555.1785.8155.827.6358.6
mean37.5262.1480.2252.655.3484.0556.0426.6256.82
MoLORA-103.18%median38.578.5778.1663.4650.8686.555.4126.7259.77
mean38.4966.4377.4459.951.6384.9656.126.757.71
MoLORA-154.69%median40.080.3680.5162.9850.8689.055.3327.360.79
mean39.7369.5280.9760.6751.5486.555.0327.2558.9

Table 3:In our most comprehensive experimental setup, we conducted a zero-shot evaluation across all unseen tasks using a 3B parameter model. We compared varying numbers of experts for both MoV and MoLoRA and experimented with a top-k selection routing strategy

T5-XXL (11B)

Model% Params.MetricANLICBRTEWSCWICCopaWNGHSAverage
Full-FTT0-11B (Sanh et al., 2022)100%median42.1778.5781.2364.4257.2190.7960.4633.6563.56
mean41.1670.1280.8361.4556.5890.0259.9433.5861.70
T0-11B (our replication)100%median47.180.3681.4160.156.2796.0867.3231.6165.03
mean45.8372.6281.5258.1756.6696.066.7730.9563.57
PEFT (IA)30.0098%median42.373.2175.9958.6552.0486.2754.330.2759.12
mean42.163.2775.3155.4952.2785.7455.0630.0957.41
Our Method MoV-100.143%median45.8376.7978.5253.8551.8894.2363.7733.562.3
mean44.7370.1278.8854.2353.2693.6463.5733.5961.5
MoV-200.287%median44.5876.7973.8355.7752.9895.062.2732.9261.77
mean43.5469.1774.452.8854.593.9362.9532.8560.53
MoV-300.431%median43.676.7977.6256.7353.8493.6264.2531.3462.22
mean43.3269.2977.2253.5656.0393.6563.5231.3260.99
MoV-600.862%median45.1775.083.0360.153.6895.4265.8234.3864.08
mean43.969.8883.0756.5454.5194.0164.5634.1762.58

Table 4:We evaluated the largest available model size from the original T5 pre-trained checkpoint, T5-XXL with 11B parameters, to demonstrate the efficacy of our proposed mixture of PEFT experts at this scale.

A.2Token vs. Sentence Embeddings for Routing

We present the mean and median results for our routing strategies. Specifically, we assessed performance by either passing tokens directly to the router or by passing sentence embeddings. Our findings indicate that, particularly for the T5-XL(3B) model, token routing consistently yields better performance in terms of both mean and median values. The Anli dataset is excluded from our embedding dataset.

MoV – Token vs. Sentence Embedding

ModelMetricCBRTEWSCWICCopaWNGHSAverage
MoV-10 (Token) - 770Mmedian42.8674.1962.552.6452.6477.026.3455.12
mean42.3874.5159.2352.252.274.8226.7254.37
MoV-10 (Embedding) - 770Mmedian48.2167.1562.9851.850.9967.026.3853.5
mean51.6767.2958.3751.7950.9965.826.5753.21
MoV-10 (Token) - 3Bmedian75.078.862.552.1955.9685.7730.2462.94
mean63.4579.4960.1953.0456.2786.4129.1161.14
MoV-10 (Embedding) - 3Bmedian57.1467.1561.0655.3352.4982.529.0857.82
mean51.0768.8158.6555.2852.5780.5328.5156.49
MoV-10 (Token) - 11Bmedian76.7978.5253.8551.8863.7794.2333.564.65
mean70.1278.8854.2353.2663.5793.6433.5963.9
MoV-10 (Embedding) - 11Bmedian75.078.757.6954.057.8592.033.0864.05
mean66.1979.158.3754.8358.7891.1732.763.02

Table 5:The above results demonstrate the effectiveness of token routing in comparison to imposing a strong inductive bias, such as sentence embedding across various model parameters.

  • 43
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI生成曾小健

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值