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 prevailing trend in Natural Language Processing (NLP) has been "bigger is better," with state-of-the-art models often utilizing hundreds of millions or even billions of parameters. While deep recurrent neural networks, such as LSTMs, are highly accurate, they are computationally expensive and memory-intensive. This creates a significant hurdle for "on-device" AI. Mobile phones have limited RAM and processing power; running a massive LSTM for real-time tasks can lead to high latency and excessive battery drain.

This paper demonstrates that small, shallow feed-forward (FF) networks can achieve near state-of-the-art results while being significantly faster and more memory-efficient. The authors aim to find the "sweet spot" where simple architectures provide the best trade-off between accuracy, speed, and memory for resource-constrained environments.

Methodology

The authors utilize a simple architecture: an embedding layer, a single hidden layer with ReLU activation, and a softmax output. To maintain a tiny memory footprint (under 3 MB), they employ four key strategies:

  1. Hashed Character n-grams: Instead of a massive word-based vocabulary, they use character n-grams (sequences of 1–4 characters). A hash function maps these into a fixed, small number of buckets, drastically reducing the embedding matrix size.
  2. Quantization: Compressing 32-bit floating-point weights into 8-bit integers reduces memory usage by 4x with negligible accuracy loss.
  3. Bloom-Mapped Word Clusters: Using "Bloom maps" (a space-efficient probabilistic data structure) to store word cluster IDs allows representing 250,000 word types in just 300 KB.
  4. Transition Systems for Structured Prediction: For tasks like word segmentation and preordering, they use transition-based systems to convert structured problems into classification decisions that a feed-forward network can handle.
Architecture of the small feed-forward network using character n-gram embeddings.

Experimental Evaluation

The approach was evaluated across four distinct NLP tasks using standard benchmarks:

  • Language Identification (Lang-ID): Wikipedia text in 66 languages.
  • Part-of-Speech (POS) Tagging: 13 languages from the Universal Dependency treebanks v1.1.
  • Word Segmentation: Chinese Treebank 6.0.
  • Preordering (for Translation): English-Japanese manual word alignments.

Key Results and Discussion

The feed-forward models achieved an order of magnitude speedup over LSTM-based approaches. For POS tagging, the small FF model used 36x fewer FLOPs than a 4-layer LSTM. All models were kept under a 3 MB budget; for instance, the Lang-ID model was compressed to just 302 KB while maintaining high accuracy. On POS tagging, the best FF model was 0.3% more accurate on average than the much larger "byte-to-span" LSTM model.

Comparison of accuracy, weights, memory (MB), and operations (Ops) for POS tagging.

Key insights from the study include:

  • Shallow is Sufficient: A single hidden layer is often enough to capture necessary patterns if input features like character n-grams are well-designed.
  • The "Free Lunch" of Quantization: It is often better to have a larger embedding dimension with 8-bit precision than a smaller dimension with 32-bit precision. This allows for higher model capacity within the same memory budget.
  • Feature Conjunctions: Explicitly adding feature conjunctions (like character bigrams) provides a significant accuracy boost for a relatively small memory cost, which is critical for small networks.

Conclusion

While massive deep models provide the highest absolute accuracy when resources are unlimited, small FF networks are excellent for budgeted scenarios. This research proves that clever engineering and feature design can bridge the gap between efficiency and performance. Future work may explore how this approach scales to more complex semantic tasks like full Machine Translation, potentially through the use of model pipelines.

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