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

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

Abstract

Scaling Large Language Models (LLMs) typically involves a proportional increase in computational cost. Sparse Feed-Forward Networks (S-FFNs) offer a solution by increasing total parameters while activating only a small fraction per input token. This paper unifies two prominent S-FFN paradigms—Mixture-of-Experts (MoE) and Sparse Neural Memory—into a single conceptual framework based on memory block size ($g$) and selection methods. We introduce Avg-K, a novel routing technique that represents expert blocks by the average of their internal key vectors. Our experiments on a 112B token corpus demonstrate that smaller block sizes and direct selection methods significantly improve model perplexity. Avg-K outperforms established architectures like Switch Transformer with less than 1% additional computational overhead.

Introduction

Scaling LLMs is essential for performance but often constrained by FLOPs. S-FFNs provide a "free lunch" by decoupling parameter count from active computation. Historically, this has been approached via Mixture-of-Experts (MoE), which uses learned gates to route tokens to full FFN "experts," or Sparse Neural Memory, which treats the FFN as a fine-grained key-value lookup table. This work seeks to identify the fundamental design choices—block size versus selection method—that drive S-FFN performance.

A Unified Framework for S-FFNs

The authors propose that all S-FFNs can be characterized along two primary dimensions:

  1. Memory Block Size ($g$): The number of parameters grouped and activated as a single unit. In MoE, $g$ is typically the size of a full FFN, whereas in neural memory, it can be as small as a single vector ($g=1$).
  2. Selection Method: The mechanism for activating blocks. Direct selection uses the model's actual key-value parameters for matching, while indirect selection (e.g., MoE gates) uses a separate, smaller set of routing parameters.
Conceptual unification of MoE and Sparse Neural Memory within a Transformer layer.

Building on this, we introduce Avg-K. Instead of complex learned gates or expensive cell-level selection, Avg-K represents each block by the average of its internal key vectors and selects the top-$b$ blocks based on the dot product with the input token. This approach retains the expressivity of large key tables while maintaining routing efficiency.

Experimental Setup

Models were pretrained on a 112B token corpus (453GB) including CC100, BookCorpus, Wikipedia, and OpenWebText. Evaluation was conducted on The Pile, a 22-domain dataset, to measure out-of-domain perplexity as a proxy for generalization capability.

Results and Analysis

Our analysis yields several key insights into S-FFN design:

  • Granularity Matters: Reducing the block size ($g$) consistently improves perplexity across all domains. Smaller blocks allow for more diverse parameter combinations, increasing the model's expressive capacity.
  • Direct Selection Advantage: Methods that rely directly on the FFN's key parameters (Direct selection) outperform those using separate gating networks. This suggests that coupling routing decisions with stored knowledge is beneficial.
  • Efficiency and Robustness: Avg-K achieved a perplexity of 14.80 on The Pile, significantly lower than Switch Transformer (16.45). Notably, Avg-K performs well without the complex load-balancing constraints required by traditional MoEs to prevent expert collapse.
Perplexity vs. block size (g) for direct (VanillaM) and indirect (RandomHash) selection methods across different domains.

Conclusion

By unifying S-FFN architectures, we demonstrate that the "memory block size" is a critical hyperparameter for performance. Avg-K provides a simple yet effective routing mechanism that balances expressivity and computational efficiency. Future work will explore scaling these insights to multi-billion parameter models and optimizing communication overhead in distributed environments.

Summary updated

BibTeX
@inproceedings{liu2023towards,
  author = {Zeyu Liu and Tim Dettmers and Xi 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