近年来,在自然语言处理中的伯特等变压器模型越来越多地采用了越来越多的采用,甚至在计算机视觉中。然而,由于大小,在资源受限的计算环境中,在资源受限的计算环境中采用了有限的采用本文提出了通过消除冗余注意头来压缩变压器模型的新颖修剪算法。我们应用A *搜索算法,以获得最小精度保证的修剪模型。我们的结果表明,该方法可以消除BERT变压器模型中的40%的注意力头,几乎没有精确损失。
translated by 谷歌翻译
Attention is a powerful and ubiquitous mechanism for allowing neural models to focus on particular salient pieces of information by taking their weighted average when making predictions. In particular, multi-headed attention is a driving force behind many recent state-of-the-art natural language processing (NLP) models such as Transformer-based MT models and BERT. These models apply multiple attention mechanisms in parallel, with each attention "head" potentially focusing on different parts of the input, which makes it possible to express sophisticated functions beyond the simple weighted average. In this paper we make the surprising observation that even if models have been trained using multiple heads, in practice, a large percentage of attention heads can be removed at test time without significantly impacting performance. In fact, some layers can even be reduced to a single head. We further examine greedy algorithms for pruning down models, and the potential speed, memory efficiency, and accuracy improvements obtainable therefrom. Finally, we analyze the results with respect to which parts of the model are more reliant on having multiple heads, and provide precursory evidence that training dynamics play a role in the gains provided by multi-head attention 1 .1 Code to replicate our experiments is provided at https://github.com/pmichel31415/ are-16-heads-really-better-than-1
translated by 谷歌翻译
近年来,变形金刚大大提高了自然语言处理(NLP)的最新技术,但呈现出非常大的计算和存储要求。我们观察到,变压器的设计过程(以自我监督的方式预先培训是大型数据集上的基础模型,随后将其用于不同的下游任务)导致特定于任务的模型,这些模型高度过度参数化,参数过度过度化,不利地影响准确性和推理效率。我们提出了Axformer,这是一个系统的框架,该框架应用精度驱动的近似值来为给定的下游任务创建优化的变压器模型。 Axformer结合了两个关键的优化 - 准确驱动的修剪和选择性的硬注意。准确驱动的修剪确定并删除了微调变压器的一部分,从而阻碍了给定下游任务的性能。稀疏的硬注意通过消除无关的单词聚合来优化选定层中的注意力块,从而帮助模型仅关注输入的相关部分。实际上,Axformer会导致更准确的模型,同时更快,更小。我们在胶水和小队任务上的实验表明,轴形模型的准确性高达4.5%,同时比传统的微调模型快2.5倍,高达3.2倍。此外,我们证明了轴形式可以与先前的努力(例如蒸馏或量化)结合使用,以实现进一步的效率提高。
translated by 谷歌翻译
基于变压器的语言模型应用于自然语言处理的广泛应用程序。但是,它们效率低,难以部署。近年来,已经提出了许多压缩算法来提高目标硬件上大型变压器的模型的实现效率。在这项工作中,我们通过整合体重修剪和模型蒸馏来提出一种训练稀疏预训练的变压器语言模型的新方法。这些稀疏的预训练型号可用于在维护稀疏模式的同时传输广泛的任务。我们展示了我们有三个已知的架构的方法,以创建稀疏的预训练伯特基,BERT-MAT​​RY和DISTOLBERT。我们展示了压缩稀疏的预训练模型如何培训他们的知识,以最小的精度损失将他们的知识转移到五种不同的下游自然语言任务。此外,我们展示了如何使用量化感知培训进一步将稀疏模型的重量压缩为8位精度。例如,在SQUAdv1.1上使用我们稀疏预训练的BERT频率,并量化为8位,我们为编码器达到40美元的压缩比,而不是1 \%$精度损失。据我们所知,我们的结果表明Bert-Base,Bert-Light和Distilbert的最佳压缩至准确率。
translated by 谷歌翻译
AD相关建模在包括Microsoft Bing在内的在线广告系统中起着至关重要的作用。为了利用强大的变压器在这种低延迟设置中,许多现有方法脱机执行广告端计算。虽然有效,但这些方法无法提供冷启动广告,从而导致对此类广告的相关性预测不佳。这项工作旨在通过结构化修剪设计一种新的低延迟BERT,以在CPU平台上授权实时在线推断对Cold Start Ads相关性。我们的挑战是,以前的方法通常将变压器的所有层都缩减为高,均匀的稀疏性,从而产生无法以可接受的精度实现令人满意的推理速度的模型。在本文中,我们提出了SwiftPruner - 一个有效的框架,利用基于进化的搜索自动在所需的延迟约束下自动找到表现最佳的稀疏BERT模型。与进行随机突变的现有进化算法不同,我们提出了一个具有潜伏意见的多目标奖励的增强突变器,以进行更好的突变,以有效地搜索层稀疏模型的大空间。广泛的实验表明,与均匀的稀疏基线和最先进的搜索方法相比,我们的方法始终达到更高的ROC AUC和更低的潜伏度。值得注意的是,根据我们在1900年的延迟需求,SwiftPruner的AUC比Bert-Mini在大型现实世界数据集中的最先进的稀疏基线高0.86%。在线A/B测试表明,我们的模型还达到了有缺陷的冷启动广告的比例,并获得了令人满意的实时服务延迟。
translated by 谷歌翻译
预磨料的语言模型的大小使它们在有多个所需的下游任务时使用挑战和昂贵。在这项工作中,我们采用了最近的近期模型修剪策略,以探索是否有可能修剪单个编码器,以便它可以用于多个任务。我们分配了固定的参数预算,并将修剪修剪单个模型,对单任务模型的最佳集合进行多任务目标。我们发现,根据两个修剪策略(元素 - 明智和排名修剪),当在所有任务中平均时,具有多任务目标的方法优于培训模型,并且在每个任务中都具有竞争力。其他分析发现,在修剪期间使用多任务目标也可以是减少低资源任务的模型大小的有效方法。
translated by 谷歌翻译
随着对深度学习民主化的向往,在资源约束设备上实施基于变压器的自然语言处理(NLP)模型的需求越来越大,以实施低延迟和高准确性。现有的BERT修剪方法要求域专家启发手工制作超参数,以在模型大小,延迟和准确性之间取得平衡。在这项工作中,我们提出了AE-Bert,这是一种具有有效评估的自动和高效的BERT修剪框架,以选择“良好”子网络候选(高精度),鉴于整体修剪比率的约束。我们提出的方法不需要人类专家的经验,并且可以在许多NLP任务上取得更好的准确性能。我们关于一般语言理解评估(胶水)基准的实验结果表明,AE-Bert优于Bert $ _ {\ Mathrm {base}} $的最先进的(SOTA)手工制作的修剪方法。在QNLI和RTE上,我们获得75 \%和42.8%的总体修剪比,同时获得更高的精度。在MRPC上,我们的得分比SOTA高4.6,在相同的整体修剪比为0.5。在STS-B上,与SOTA手工制作的修剪方法相比,我们可以达到40 \%的修剪比,而Spearman相关性的损失非常小。实验结果还表明,在模型压缩之后,单个bert $ _ {\ mathrm {base}} $ coder的推理时间在xilinx alveo u200 fpga板上具有1.83 $ \ times $ speedup,与intel(r)xeon相比)Gold 5218(2.30GHz)CPU,它显示了部署BERT $ _ {\ MATHRM {base}} $模型在计算限制设备上生成的方法生成的子网的合理性。
translated by 谷歌翻译
在本文中,我们提出了一种新型可调微调方法,可提高BERT模型对下游任务的训练和推理时间。在所提出的方法中,我们首先通过我们提出的冗余度量检测每层中的更重要的单词向量,然后通过我们提出的策略消除不太重要的单词向量。在我们的方法中,每层中的字矢量消除速率由倾斜速率超参数控制,并且模型学会使用比原始BERT \ TextSubscript {Base}相当较低数量的浮点操作(闪光)。模型。我们所提出的方法不需要任何额外的训练步骤,并且它也可以推广到其他基于变压器的模型。我们执行广泛的实验,显示较高层中的字矢量具有令人印象深刻的冗余,可以消除和减少训练和推理时间。实验结果对广泛情绪分析,分类和回归数据集,以及IMDB和胶水等基准表明我们的提出方法在各种数据集中有效。通过在BERT \ TextSubscript {Base}模型上应用我们的方法,我们平均将推理时间降低5.3倍的5.3倍,平均精度降低。在微调阶段之后,可以使用我们的方法脱机调整属性调整模型的推理时间,以获得各种倾斜率值选择。此外,我们提出了一种数学加速分析,可以准确估计我们方法的加速。在此分析的帮助下,可以在微调或离线调谐阶段之前选择倾斜速率超参数。
translated by 谷歌翻译
最近,视觉变压器(VIT)及其变体在各种计算机视觉任务中取得了有希望的表现。然而,VITS的高计算成本和培训数据要求将其应用程序限制在资源受限设置中。模型压缩是加快深度学习模型的有效方法,但压缩VITS的研究已经不太探索。许多以前的作品集中在减少令牌的数量。然而,这种攻击行会破坏VIT的空间结构,并且难以推广到下游任务中。在本文中,我们设计了统一的框架,用于对VITS及其变体的结构修剪,即升级Vits。我们的方法侧重于修剪所有VITS组件,同时保持模型结构的一致性。丰富的实验结果表明,我们的方法可以在压缩VITS和变体上实现高精度,例如,UP-DEIT-T在Imagenet上实现了75.79%的精度,这与Vanilla Deit-T以相同的计算成本优于3.59%。 UP-PVTV2-B0提高了PVTV2-B0的精度4.83%,以进行想象成分类。同时,上升VITS维护令牌表示的一致性,并在对象检测任务上提高一致的改进。
translated by 谷歌翻译
基于变压器的NLP模型是使用数亿甚至数十亿个参数训练的,从而限制了其在计算受限环境中的适用性。尽管参数的数量通常与性能相关,但尚不清楚下游任务是否需要整个网络。在最新的修剪和提炼预培训模型的工作中,我们探索了在预训练模型中放下层的策略,并观察修剪对下游胶水任务的影响。我们能够修剪Bert,Roberta和XLNet型号高达40%,同时保持其原始性能的98%。此外,我们证明,在大小和性能方面,您的修剪模型与使用知识蒸馏的型号相提并论。我们的实验产生有趣的观察结果,例如(i)下层对于维持下游任务性能最重要,(ii)某些任务(例如释义检测和句子相似性)对于降低层的降低和(iii)经过训练的模型更强大。使用不同的目标函数表现出不同的学习模式,并且层掉落。
translated by 谷歌翻译
Network pruning is widely used for reducing the heavy inference cost of deep models in low-resource settings. A typical pruning algorithm is a three-stage pipeline, i.e., training (a large model), pruning and fine-tuning. During pruning, according to a certain criterion, redundant weights are pruned and important weights are kept to best preserve the accuracy. In this work, we make several surprising observations which contradict common beliefs. For all state-of-the-art structured pruning algorithms we examined, fine-tuning a pruned model only gives comparable or worse performance than training that model with randomly initialized weights. For pruning algorithms which assume a predefined target network architecture, one can get rid of the full pipeline and directly train the target network from scratch. Our observations are consistent for multiple network architectures, datasets, and tasks, which imply that: 1) training a large, over-parameterized model is often not necessary to obtain an efficient final model, 2) learned "important" weights of the large model are typically not useful for the small pruned model, 3) the pruned architecture itself, rather than a set of inherited "important" weights, is more crucial to the efficiency in the final model, which suggests that in some cases pruning can be useful as an architecture search paradigm. Our results suggest the need for more careful baseline evaluations in future research on structured pruning methods. We also compare with the "Lottery Ticket Hypothesis" (Frankle & Carbin, 2019), and find that with optimal learning rate, the "winning ticket" initialization as used in Frankle & Carbin (2019) does not bring improvement over random initialization. * Equal contribution. † Work done while visiting UC Berkeley.
translated by 谷歌翻译
Multi-head self-attention is a key component of the Transformer, a state-of-the-art architecture for neural machine translation. In this work we evaluate the contribution made by individual attention heads in the encoder to the overall performance of the model and analyze the roles played by them. We find that the most important and confident heads play consistent and often linguistically-interpretable roles. When pruning heads using a method based on stochastic gates and a differentiable relaxation of the L 0 penalty, we observe that specialized heads are last to be pruned. Our novel pruning method removes the vast majority of heads without seriously affecting performance. For example, on the English-Russian WMT dataset, pruning 38 out of 48 encoder heads results in a drop of only 0.15 BLEU. 1
translated by 谷歌翻译
语言模型偏见已成为NLP社区的重要研究领域。提出了许多偏见技术,但偏见消融仍然是一个未解决的问题。我们展示了一个新颖的框架,用于通过运动修剪来检查预训练的基于变压器的语言模型的偏见。给定模型和一个偏见的目标,我们的框架找到了与原始模型相比,偏差少的模型子集。我们通过对模型进行修剪来实现我们的框架,同时将其按照歧义目标进行微调。优化仅是修剪分数 - 参数以及模型的权重,该参数充当门。我们尝试修剪注意力头,这是变形金刚的重要组成部分:我们修剪正方形块,并建立了一种修剪整个头部的新方法。最后,我们使用性别偏见证明了我们的框架的用法,并且根据我们的发现,我们提出了对现有辩论方法的改进。此外,我们重新发现了偏见 - 绩效权衡:模型执行越好,其包含的偏见就越多。
translated by 谷歌翻译
稀疏性已成为压缩和加速深度神经网络(DNN)的有前途方法之一。在不同类别的稀疏性中,由于其对现代加速器的有效执行,结构化的稀疏性引起了人们的关注。特别是,n:m稀疏性很有吸引力,因为已经有一些硬件加速器架构可以利用某些形式的n:m结构化稀疏性来产生更高的计算效率。在这项工作中,我们专注于N:M的稀疏性,并广泛研究和评估N:M稀疏性的各种培训食谱,以模型准确性和计算成本(FLOPS)之间的权衡(FLOPS)。在这项研究的基础上,我们提出了两种新的基于衰减的修剪方法,即“修剪面膜衰减”和“稀疏结构衰减”。我们的评估表明,这些提出的方法始终提供最新的(SOTA)模型精度,可与非结构化的稀疏性相当,在基于变压器的模型上用于翻译任务。使用新培训配方的稀疏模型准确性的提高是以总训练计算(FLOP)边际增加的成本。
translated by 谷歌翻译
Transformer-based models have pushed state of the art in many areas of NLP, but our understanding of what is behind their success is still limited. This paper is the first survey of over 150 studies of the popular BERT model. We review the current state of knowledge about how BERT works, what kind of information it learns and how it is represented, common modifications to its training objectives and architecture, the overparameterization issue and approaches to compression. We then outline directions for future research.
translated by 谷歌翻译
深度神经网络(DNN)在解决许多真实问题方面都有效。较大的DNN模型通常表现出更好的质量(例如,精度,精度),但它们的过度计算会导致长期推理时间。模型稀疏可以降低计算和内存成本,同时保持模型质量。大多数现有的稀疏算法是单向移除的重量,而其他人则随机或贪婪地探索每层进行修剪的小权重子集。这些算法的局限性降低了可实现的稀疏性水平。此外,许多算法仍然需要预先训练的密集模型,因此遭受大的内存占地面积。在本文中,我们提出了一种新颖的预定生长和修剪(间隙)方法,而无需预先培训密集模型。它通过反复生长一个层次的层来解决以前的作品的缺点,然后在一些训练后修剪回到稀疏。实验表明,使用所提出的方法修剪模型匹配或击败高度优化的密集模型的质量,在各种任务中以80%的稀疏度,例如图像分类,客观检测,3D对象分段和翻译。它们还优于模型稀疏的其他最先进的(SOTA)方法。作为一个例子,通过间隙获得的90%不均匀的稀疏resnet-50模型在想象中实现了77.9%的前1个精度,提高了先前的SOTA结果1.5%。所有代码将公开发布。
translated by 谷歌翻译
随着培训深度学习模型的越来越大的负担,在许多新兴的深度学习算法中已广泛采用转移学习。诸如BERT之类的变压器模型是自然语言处理的主要参与者,并将转移学习用作事实上的标准培训方法。一些大数据公司发布了经过培训的预培训模型,这些模型已通过一些流行的数据集进行了培训,最终用户和研究人员使用自己的数据集对模型进行了微调。转移学习大大减少了培训模型的时间和精力。但是,这是以安全问题为代价的。在本文中,我们展示了一个新的观察结果,即预先训练的模型和微调模型在权重值上具有很高的相似性。另外,我们证明即使对于同一模型,也存在特定于供应商的计算模式。有了这些新发现,我们提出了一种新的模型提取攻击,该攻击揭示了模型架构和带有特定于供应商的计算模式的黑盒受害者模型使用的预培训模型,然后根据权重值相似性估算整个模型权重在微调模型和预训练模型之间。我们还表明,可以利用重量相似性来通过新颖的重量提取修剪来提高模型提取可行性。
translated by 谷歌翻译
We show for the first time that large-scale generative pretrained transformer (GPT) family models can be pruned to at least 50% sparsity in one-shot, without any retraining, at minimal loss of accuracy. This is achieved via a new pruning method called SparseGPT, specifically designed to work efficiently and accurately on massive GPT-family models. When executing SparseGPT on the largest available open-source models, OPT-175B and BLOOM-176B, we can reach 60% sparsity with negligible increase in perplexity: remarkably, more than 100 billion weights from these models can be ignored at inference time. SparseGPT generalizes to semi-structured (2:4 and 4:8) patterns, and is compatible with weight quantization approaches.
translated by 谷歌翻译
Compared to conventional bilingual translation systems, massively multilingual machine translation is appealing because a single model can translate into multiple languages and benefit from knowledge transfer for low resource languages. On the other hand, massively multilingual models suffer from the curse of multilinguality, unless scaling their size massively, which increases their training and inference costs. Sparse Mixture-of-Experts models are a way to drastically increase model capacity without the need for a proportional amount of computing. The recently released NLLB-200 is an example of such a model. It covers 202 languages but requires at least four 32GB GPUs just for inference. In this work, we propose a pruning method that allows the removal of up to 80\% of experts with a negligible loss in translation quality, which makes it feasible to run the model on a single 32GB GPU. Further analysis suggests that our pruning metrics allow to identify language-specific experts and prune non-relevant experts for a given language pair.
translated by 谷歌翻译
Despite achieving state-of-the-art performance on many NLP tasks, the high energy cost and long inference delay prevent Transformer-based pretrained language models (PLMs) from seeing broader adoption including for edge and mobile computing. Efficient NLP research aims to comprehensively consider computation, time and carbon emission for the entire life-cycle of NLP, including data preparation, model training and inference. In this survey, we focus on the inference stage and review the current state of model compression and acceleration for pretrained language models, including benchmarks, metrics and methodology.
translated by 谷歌翻译