Efficient Language Modeling with Sparse all-MLP

Ping Yu, Mikel Artetxe, Myle Ott, Sam Shleifer, Hongyu Gong, Ves Stoyanov, Xian LiarXiv 2022 · DOI

Abstract

This paper introduces sMLP, a sparsely activated all-MLP architecture designed for efficient language modeling. By incorporating Mixture-of-Experts (MoE) at both the feature and token levels, sMLP overcomes the scaling limitations of dense MLP models. The architecture achieves a 2x training speedup and superior zero-shot performance on downstream tasks compared to state-of-the-art Transformer-based MoEs and dense models like GPT-3, while maintaining computational efficiency.

Introduction

Transformers have long dominated the NLP landscape, but "all-MLP" architectures like gMLP have emerged as simpler alternatives that replace self-attention with linear projections. However, dense all-MLPs often lag in performance when scaled. Scaling these models traditionally is computationally expensive, leading researchers to explore Mixture-of-Experts (MoE) as a way to increase capacity without a proportional increase in FLOPs.

A significant challenge in applying MoE to all-MLP architectures for causal language modeling is "information leakage," where the routing mechanism inadvertently allows current tokens to access information from future tokens. This paper proposes sMLP to address these challenges through novel sparse modules and routing strategies.

The sMLP Architecture

The sMLP architecture introduces sparsity into two core MLP operations: hidden dimension processing and token mixing.

The sMLP architecture featuring sMoE and tMoE modules for sparse feature and token processing.

Sparse Modules

  1. tMoE (Token-wise MoE): This module handles hidden dimension operations by routing individual tokens to different expert MLP blocks, similar to standard MoE in feed-forward layers.
  2. sMoE (Feature-wise MoE): Replacing the Spatial Gating Unit (SGU) in gMLP, the sMoE module chunks the hidden representation (features) and sends different chunks to different experts. This feature-wise routing is a key innovation of the paper.

Routing Strategies for Causal Modeling

To prevent information leakage in autoregressive tasks, the authors propose two routing methods:

  • Deterministic Routing: Hidden dimensions are split into fixed chunks and assigned to experts. This "multi-head" approach to experts ensures that routing is independent of future token information.
  • Partial Prediction: Routing weights for the majority of a sentence are learned using only the initial 20% of the tokens, ensuring the router does not look ahead.

Experimental Setup

The models were pretrained on a 160GB combination of the RoBERTa dataset and the English CC100 corpus. Evaluation was conducted on six representative zero-shot tasks: COPA, PIQA, StoryCloze, Winogrande, HellaSwag, and ReCoRD.

Key Results

The sMLP architecture demonstrates significant improvements in both efficiency and performance.

Training Efficiency

sMLP achieves a 2x training speedup compared to Transformer-based MoEs like GShard and Switch Transformer. As shown in the training curves, sMLP-deterministic reaches lower perplexity levels in significantly less time.

Training efficiency comparison showing sMLP-deterministic achieving a 2x speedup in valid perplexity over training time.

Downstream Performance

On zero-shot evaluations, sMLP (deterministic) achieved an average accuracy of 68.15%. This performance exceeds that of Switch Transformer (67.84%) and matches the reported results for GPT-3 (68.13%), despite sMLP being trained on three times less data.

Conclusion

sMLP represents a significant step forward for all-MLP architectures, showing that sparsity can effectively bridge the performance gap with Transformers. By utilizing feature-wise routing and deterministic strategies, sMLP achieves high parameter efficiency and training speed. Future research will explore sMLP in bidirectional encoder-only settings and further optimize communication overhead for large-scale distributed training.

Summary updated

BibTeX
@misc{yu2022efficient,
  author = {Ping Yu and Mikel Artetxe and Myle Ott and Sam Shleifer and Hongyu Gong and Ves Stoyanov and Xian Li},
  title = {{Efficient Language Modeling with Sparse all-MLP}},
  year = {2022},
  eprint = {2203.06850},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2203.06850},
}
Figure