Natural Language Processing with Small Feed-Forward Networks

Jan A. Botha, Emily Pitler, Ji Ma, Anton Bakalov, Alex Salcianu, David Weiss, Ryan T. McDonald, Slav Petrov

Abstract

We show that small and shallow feed-forward neural networks can achieve near state-of-the-art results on a range of unstructured and structured language processing tasks while being considerably cheaper in memory and computational requirements than deep recurrent models. Motivated by resource-constrained environments like mobile phones, we showcase simple techniques for obtaining such small neural network models, and investigate different tradeoffs when deciding how to allocate a small memory budget.

Introduction

In recent years, the field of Natural Language Processing (NLP) has trended toward increasingly large and deep recurrent neural networks, such as LSTMs. While these models offer high accuracy, they present significant challenges for deployment in resource-constrained environments like mobile devices. Specifically, they demand substantial memory for parameter matrices and suffer from high latency due to sequential processing. For instance, a two-layer LSTM might only process 8.8 words per second on a standard mobile device, which is insufficient for real-time applications.

This research explores the viability of tiny, shallow feed-forward networks (FFNs) as a high-performance, low-cost alternative. By focusing on models under 3MB, we demonstrate that it is possible to achieve near state-of-the-art results while being over 10x faster than recurrent counterparts.

Methodology

The core approach utilizes simple feed-forward networks with a single hidden layer. To maximize the utility of these small models, several compression and feature engineering strategies are employed:

  • Hashed Character n-grams: To avoid the memory overhead of large word vocabularies, the model uses character n-grams (e.g., "the" represented as "th", "he", "the"). These are mapped into a fixed number of buckets via a hashing trick, drastically reducing the embedding table size.
  • Quantization: Embedding weights are stored with lower precision (fewer bits). This allows for higher-dimensional vectors within the same memory budget, which often yields better performance than high-precision, low-dimension vectors.
  • Bloom-Mapped Word Clusters: Word-level information is incorporated using Bloom filters to map words to clusters (e.g., POS categories) with 15x less space than standard lookup tables.
  • Transition Systems: For structured tasks like word segmentation, the FFN acts as a classifier within a state-machine, predicting the next discrete "action" rather than modeling entire sequences.
Architecture of the small feed-forward network using character n-gram embeddings.

Experimental Setup

The models were evaluated across four distinct NLP tasks to test their versatility:

  1. Language Identification (Lang-ID): Classification of Wikipedia text across 66 languages.
  2. Part-of-Speech (POS) Tagging: Evaluated on Universal Dependency treebanks v1.1 across 13 languages.
  3. Word Segmentation: Chinese Treebank 6.0.
  4. Preordering for Translation: English-Japanese manual word alignments.

Key Results and Insights

The experiments demonstrate that for small models, explicit feature engineering—such as adding character bigrams or compressed word clusters—is more effective than increasing network depth.

On the POS tagging task, the best FFN model achieved 95.56% accuracy, outperforming a much larger LSTM baseline (95.06%). Crucially, this was achieved with 6x fewer parameters and 36x fewer floating-point operations (FLOPs). In terms of raw speed, the Lang-ID model processed 4,450 documents per second on a single CPU core, while the segmentation model reached 39k tokens per second.

Performance comparison on POS tagging, showing the efficiency of small feed-forward models.

Key insights from the budget allocation study include:

  • Precision vs. Dimension: For tasks like Lang-ID, it is preferable to have more dimensions with lower precision (quantization) than fewer dimensions with high precision.
  • Efficiency Gains: Adding compressed word clusters to a vanilla FFN resulted in a 15% relative reduction in error for POS tagging with minimal memory increase.

Conclusion

Small feed-forward networks prove to be highly effective for "shallow" NLP tasks, offering a compelling trade-off between accuracy and efficiency. While these models may not yet replace deep architectures for complex natural language understanding tasks like full machine translation, they are ideal for on-device applications where memory and latency are critical. Future work may focus on more unified approaches to budgeted learning and mitigating the impact of hashing collisions in character-heavy languages.

Summary updated

BibTeX
@inproceedings{botha2017natural,
  author = {Jan A. Botha and Emily Pitler and Ji Ma and Anton Bakalov and Alex Salcianu and David Weiss and Ryan T. McDonald and Slav Petrov},
  title = {{Natural Language Processing with Small Feed-Forward Networks}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2017},
  url = {https://openreview.net/forum?id=Hkbh7MGdZr},
}
Figure