arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2312.17482cs.CLcs.LG
收藏

MosaicBERT:一种针对快速预训练优化的双向编码器

MosaicBERT: A Bidirectional Encoder Optimized for Fast Pretraining

MosaicML;Databricks

Jacob Portes, Alex Trott, Sam Havens, Daniel King, Abhinav Venigalla, Moin Nadeem, Nikhil Sardana, Daya Khudia, Jonathan Frankle

AI总结:

MosaicBERT通过融合FlashAttention、ALiBi、GLU等高效模块并优化训练方案,在保持GLUE得分79.6的同时将BERT预训练成本降至约20美元,实现快速且帕累托最优的预训练。

摘要:

尽管BERT风格的编码器模型在自然语言处理(NLP)研究中被广泛使用,但由于训练成本高昂,许多研究人员并不会从头预训练自己的BERT模型。自BERT首次崭露头角以来的近五年里,其他Transformer架构和训练配置方面已经取得了许多进展,但这些进展尚未被系统地整合到BERT中。在此,我们提出MosaicBERT,这是一种BERT风格的编码器架构和训练方案,经过实证优化以实现快速预训练。这种高效架构将FlashAttention、带线性偏置的注意力(ALiBi)、门控线性单元(GLU)、一个动态移除填充token的模块以及低精度LayerNorm整合到经典的Transformer编码器块中。该训练方案包括针对掩码语言建模(MLM)目标采用30%的掩码比例、bfloat16精度,以及针对GPU吞吐量优化的词汇表大小,此外还采用了RoBERTa和其他编码器模型的最佳实践。当在C4数据集上从头预训练时,该基础模型在8块A100 80GB GPU上仅用1.13小时,以约20美元的成本,在下游GLUE(开发集)平均得分上达到79.6。我们绘制了广泛的准确率与预训练速度的帕累托曲线,并表明与具有竞争力的BERT base和large相比,MosaicBERT base和large始终处于帕累托最优。这种预训练速度的实证提升使研究人员和工程师能够以低成本预训练定制的BERT风格模型,而无需在现有通用模型上进行微调。我们开源了模型权重和代码。

英文摘要:

Although BERT-style encoder models are heavily used in NLP research, many researchers do not pretrain their own BERTs from scratch due to the high cost of training. In the past half-decade since BERT first rose to prominence, many advances have been made with other transformer architectures and training configurations that have yet to be systematically incorporated into BERT. Here, we introduce MosaicBERT, a BERT-style encoder architecture and training recipe that is empirically optimized for fast pretraining. This efficient architecture incorporates FlashAttention, Attention with Linear Biases (ALiBi), Gated Linear Units (GLU), a module to dynamically remove padded tokens, and low precision LayerNorm into the classic transformer encoder block. The training recipe includes a 30% masking ratio for the Masked Language Modeling (MLM) objective, bfloat16 precision, and vocabulary size optimized for GPU throughput, in addition to best-practices from RoBERTa and other encoder models. When pretrained from scratch on the C4 dataset, this base model achieves a downstream average GLUE (dev) score of 79.6 in 1.13 hours on 8 A100 80 GB GPUs at a cost of roughly $20. We plot extensive accuracy vs. pretraining speed Pareto curves and show that MosaicBERT base and large are consistently Pareto optimal when compared to a competitive BERT base and large. This empirical speed up in pretraining enables researchers and engineers to pretrain custom BERT-style models at low cost instead of finetune on existing generic models. We open source our model weights and code.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑