Towards A Unified View of Sparse Feed-Forward Network in Pretraining Large Language Model

Zeyu Liu, Tim Dettmers, Xi Victoria Lin, Veselin Stoyanov, Xian Li

TL;DR

This paper unifies two approaches to sparse feed-forward networks (S-FFNs) in large language models (LLMs) – Mixture-of-Experts (MoE) and sparse neural memory – under a single framework. They introduce a novel, simpler selection method called Avg-K that achieves state-of-the-art perplexity on LLM pretraining, outperforming existing MoE architectures.

What Problem Does This Paper Address?

Scaling up large language models (LLMs) has led to remarkable performance gains, but the computational cost of training these models is immense. Sparse Feed-Forward Networks (S-FFNs) offer a solution by activating only a subset of parameters per input, thus increasing model capacity without a proportional increase in FLOPs. However, existing S-FFN methods, primarily Mixture-of-Experts (MoE) and sparse neural memory, have been treated as distinct approaches. This paper aims to bridge this gap by unifying them under a common framework, analyzing their core design choices, and proposing a more efficient and effective S-FFN architecture.

Methods

The authors propose a unified framework for S-FFNs, viewing them as a form of sparse neural memory. They analyze two key design dimensions: memory block size (how many parameters are grouped and treated as a unit) and memory block selection method (how these blocks are chosen for activation).

Their key contributions include:

  • Unified Framework: They show that MoE and sparse neural memory can be viewed as instances of the same underlying sparse memory mechanism, differing primarily in how memory blocks are defined and selected.
  • Analysis of Design Choices: They systematically study the impact of memory block size and selection methods on perplexity and FLOPs.
  • Avg-K Selection Method: They introduce a novel, simpler selection method called Avg-K. This method averages the key vectors within a block to represent it, and then uses the dot product of the input with these averaged keys to select blocks. This is a hybrid approach, drawing inspiration from both sparse memory (direct key interaction) and MoE (gating mechanism).

Datasets

The models were pretrained on a large corpus comprising six English-only datasets:

  • BookCorpus
  • English Wikipedia
  • CC-News
  • OpenWebText
  • CC-Stories
  • English CC100

For evaluation, they used the validation set from The Pile, a diverse dataset combining data from 22 sources, for out-of-domain perplexity measurements.

Key Insights and Ideas

  • Unifying MoE and Sparse Memory: The paper demonstrates that MoE and sparse neural memory are not fundamentally different but rather different instantiations of a sparse memory concept, differing in block size and selection strategy.
  • Smaller Block Size Improves Perplexity: Counter-intuitively, reducing the memory block size (e.g., expert size) consistently improved perplexity, suggesting that finer-grained activation is beneficial.
  • Gating Methods Offer Better Trade-offs: Selection methods that use a gating function (indirect selection) generally provide a better FLOPs-perplexity trade-off than those that don't (direct selection).
  • Avg-K's Simplicity and Efficacy: The proposed Avg-K method, which uses averaged keys for selection, is simpler than existing MoE gating mechanisms and achieves superior perplexity. It also performs well without explicit load balancing constraints, a common requirement for MoEs.
  • GeLU's Impact: The non-linearity of the GeLU activation function plays a crucial role. It protects VanillaM from extreme negative values, while Avg-K, which operates before GeLU, is more sensitive to these values, leading to different performance characteristics at various block sizes.

Key Results

  • The Avg-K method achieved a perplexity of 14.80 on The Pile validation set, outperforming Switch Transformer (16.45) and HashLayer (15.75).
  • Avg-K achieved this performance with less than 1% additional FLOPs compared to the baseline.
  • Smaller memory block sizes consistently led to improved perplexity in experiments with VanillaM and RandHash.
  • Indirect selection methods (like PKM-FFN and RandHash) showed a better FLOPs-perplexity trade-off than direct methods.
  • The paper found that more dependence on the key table for selection leads to better language modeling performance.

Limitations and Future Work

  • Load Balancing for Avg-K: While Avg-K performs well without explicit load balancing, the authors hypothesize it would perform even better with a standard load balancing loss, especially for smaller numbers of experts where mode collapse is more severe.
  • Communication Cost: Smaller block sizes can increase communication costs in distributed training setups, though this was not directly measured in terms of wall-clock time.
  • Alternative Aggregation: Avg-K's reliance on averaging is a simple choice; future work could explore other aggregation methods or metrics beyond dot products for selection.
  • Theoretical Understanding: Further theoretical work is needed to fully understand the connection between memory block size, selection methods, and training dynamics.
  • ANN Integration: While Approximate Nearest Neighbor (ANN) search is a potential avenue for efficiency, the authors found it challenging to integrate effectively due to data structure updates and potential systematic search errors.

Summary updated

BibTeX
@inproceedings{liu2023towards,
  author = {Zeyu Liu and Tim Dettmers and Xi Victoria Lin and Veselin Stoyanov and Xian Li},
  title = {{Towards A Unified View of Sparse Feed-Forward Network in Pretraining Large Language Model}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.930},
}
Figure