GLaM: Efficient Scaling of Language Models with Mixture-of-Experts

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 P. Bosma, Zongwei Zhou, Tao Wang, Yu Emma Wang, Kellie Webster, Marie Pellat, Kevin Robinson, Kathleen S. Meier-Hellstern, Toju Duke, Lucas Dixon, Kun Zhang, Quoc V. Le, Yonghui Wu, Zhifeng Chen, Claire Cui

Introduction

Scaling language models with more data, compute, and parameters has driven significant progress in natural language processing, enabling models like GPT-3 to achieve strong zero-shot and few-shot learning capabilities. However, standard models are "dense," meaning every parameter is activated for every prediction. Scaling these dense models to hundreds of billions of parameters requires astronomical amounts of compute, time, and energy, resulting in massive financial costs and carbon footprints.

To address this, researchers developed GLaM (Generalist Language Model), a 1.2 trillion parameter language model that uses a sparsely activated Mixture-of-Experts (MoE) architecture. GLaM achieves state-of-the-art few-shot performance while drastically cutting compute costs by only activating a small fraction of its neural network for any given word.

Methodology

To break the linear relationship between model size and compute cost, GLaM employs a decoder-only architecture built on a Mixture-of-Experts (MoE) framework.

  • Sparse Activation: Instead of a standard feed-forward network, every other Transformer layer in GLaM is replaced by an MoE layer containing 64 independent "expert" sub-networks.
  • Dynamic Routing: For every single token passed into the model, a learned gating network evaluates the token and routes it to only the top 2 most relevant experts out of the 64.
  • The Result: While the largest GLaM model boasts a staggering 1.2 trillion parameters, it only activates 96.6 billion parameters (about 8%) during any given prediction because it only uses 2 experts per token.

The authors also utilized a highly optimized 2D sharding algorithm (GSPMD) to efficiently distribute the massive memory requirements of these experts across a cluster of TPU-v4 chips.

Datasets

GLaM was trained on a massive 1.6 trillion token corpus. The authors heavily emphasized data quality, building a custom classifier to filter out low-quality web pages. The final training mix consisted of Filtered Webpages (42%), Conversations (28%), Books (20%), Wikipedia (6%), News (2%), and Forums (2%).

For evaluation, the model was tested on 29 standard public NLP benchmarks spanning Natural Language Understanding (NLU) and Generation (NLG), including well-known datasets like TriviaQA, SQuADv2, SuperGLUE, LAMBADA, and ANLI.

Key Insights and Results

GLaM successfully demonstrates that it is possible to decouple a model's capacity from its computational cost. By building a massive "brain" to store world knowledge but only using the relevant "lobes" for specific tasks, MoE architectures offer a path to sustainable scaling in AI. Furthermore, ablation studies proved that filtering web data for quality drastically improves downstream performance, showing that data quality often trumps sheer quantity.

Performance and cost comparison between GLaM and GPT-3.

The largest GLaM model outperforms GPT-3 (175B) on average across the 29 evaluated tasks:

  • Zero-shot: 62.7% vs 56.9% (+10.2% relative improvement)
  • One-shot: 65.5% vs 61.6% (+6.3% relative)
  • Few-shot: 68.1% vs 65.2% (+4.4% relative)

Crucially, these performance gains come with massive efficiency improvements. GLaM consumed only 456 MWh of energy to train—roughly one-third of GPT-3's 1287 MWh. Inference is also significantly cheaper, requiring 180 GFLOPs per token prediction compared to GPT-3's 350 GFLOPs.

GLaM also exhibited incredible knowledge retrieval capabilities. On the open-domain TriviaQA task, GLaM's one-shot performance (75.8%) beat previous fine-tuned state-of-the-art models (69.8%) and even surpassed GPT-3's 64-shot performance (71.2%). Additionally, it achieved state-of-the-art results on the WinoGender benchmark, suggesting that larger, sparsely activated models might rely less on superficial statistical biases than their dense counterparts.

Limitations and Future Work

Despite its computational efficiency per token, GLaM's 1.2 trillion parameters require a massive memory footprint just to host the model weights. This limits accessibility for smaller teams and increases serving costs, especially during periods of low server traffic. Furthermore, like other large language models, GLaM remains susceptible to toxicity degeneration; if prompted with toxic text, it is highly likely to generate toxic continuations.

The authors suggest that MoE architectures should be considered a primary candidate for future language model scaling and encourage further research into automated methods for curating high-quality pretraining data.

Summary updated

BibTeX
@inproceedings{du2022glam,
  author = {Nan Du and Yanping Huang and Andrew M. Dai and Simon Tong and Dmitry Lepikhin and Yuanzhong Xu and Maxim Krikun and Yanqi Zhou and Adams Wei Yu and Orhan Firat and Barret Zoph and Liam Fedus and Maarten P. Bosma and Zongwei Zhou and Tao Wang and Yu Emma Wang and Kellie Webster and Marie Pellat and Kevin Robinson and Kathleen S. Meier-Hellstern and Toju Duke and Lucas Dixon and Kun Zhang and Quoc V. Le and Yonghui Wu and Zhifeng Chen and Claire Cui},
  title = {{GLaM: Efficient Scaling of Language Models with Mixture-of-Experts}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
  url = {https://openreview.net/forum?id=tTSbDRi53He},
}
Figure