Approximating Two-Layer Feedforward Networks for Efficient Transformers

Róbert Csordás, Kazuki Irie, Jürgen Schmidhuber
10/16/2023
cs.LGcs.NE

Official code: RobertCsordas/moe_layer (21 stars, MIT, last commit 2024-01-05).

Abstract

How to reduce compute and memory requirements of neural networks (NNs) without sacrificing performance? Many recent works use sparse Mixtures of Experts (MoEs) to build resource-efficient large language models (LMs). Here we introduce several novel perspectives on MoEs, presenting a general framework that unifies various methods to approximate two-layer NNs (e.g., feedforward blocks of Transformers), including product-key memories (PKMs). Leveraging insights from this framework, we propose methods to improve both MoEs and PKMs. Unlike prior work that compares MoEs with dense baselines under the compute-equal condition, our evaluation condition is parameter-equal, which is crucial to properly evaluate LMs. We show that our MoEs are competitive with the dense Transformer-XL on both the WikiText-103 and enwiki8 datasets at two different scales, while being much more resource efficient. This demonstrates that MoEs are relevant not only to extremely large LMs but also to any-scale resource-efficient LMs. Our code is public.

View on arXivView PDF

Code Implementations(1)

MIT

sigma-MoE layer

212Cuda, PythonOct 16, 20232 years agoMIT

Similar Papers

Cite this paper

@article{csords2023approximating,
  title  = {Approximating Two-Layer Feedforward Networks for Efficient Transformers},
  author = {Róbert Csordás and Kazuki Irie and Jürgen Schmidhuber},
  year   = {2023},
  eprint = {2310.10837},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2310.10837v3}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2310.10837.svg)](https://codeofpaper.com/paper/2310.10837)

Discussion