Facebook’s FastText Library is Now Optimized for Mobile Devices
Facebook’s AI Research (FAIR) lab has released an update to fastText, its open-source text classification library. Originally, fastText shipped with pre-trained word vectors for 90 languages. This update expands that to 294 languages. The update also features enhancements to reduce model size and memory requirements.
Text classifiers like fastText are essential tools for developers building applications that rely on language analysis. This includes tasks like flagging clickbait headlines or filtering spam. While initially designed for use across various hardware, fastText required a significant amount of memory, making it impractical for mobile devices.
Through collaboration with the team behind another Facebook open-source project, similarity search (FAISS), the memory requirement has been significantly reduced to just a few hundred kilobytes. This was achieved through several techniques like feature pruning, quantization, hashing, and re-training. The FAISS team’s approach effectively tackled the bottleneck of processing large amounts of data by optimizing the comparison of multi-dimensional vectors. This optimization directly impacted the reduction in memory demands for fastText.

The authors of a December 2016 paper titled “fastText.zip: Compressing Text Classification Models” highlight the ability to create text classification models with sizes as small as 100kB without compromising accuracy or speed. They also suggest that further model size reduction may be possible in the future, acknowledging the challenge of balancing model size and accuracy.

