Abstract
Mobile keyboards require high-accuracy word prediction within strict memory (<10MB) and latency (<10ms) constraints. This paper presents a highly compressed Recurrent Neural Network Language Model (RNN-LM) developed by Samsung researchers. By leveraging knowledge distillation, shared matrix factorization, and low-rank approximation, the model is reduced to 7.4MB with a 6.47ms response time, achieving superior keystroke efficiency compared to leading commercial solutions from Apple and Google.
Introduction
While Recurrent Neural Networks (RNNs) are the gold standard for language modeling due to their ability to track long-range context, they are notoriously resource-intensive. A typical high-performing RNN-LM can exceed 50MB—far too large for the strict constraints of a mobile device. On-device keyboards typically operate within a memory budget of less than 10MB and require a response time under 10ms to ensure a lag-free typing experience. Historically, this forced developers to rely on simpler, less accurate n-gram statistical models. This research addresses how to shrink a massive, compute-intensive RNN so it can run locally on a smartphone without sacrificing its predictive power.
Methodology
The authors propose a multi-stage pipeline to compress the model while maintaining accuracy, as illustrated in the following architecture diagram:
- Knowledge Distillation (KD): A large "teacher" ensemble is used to train a smaller "distilled" student model. Instead of just learning from "hard targets" (the correct next word), the student learns from "soft targets" (the probability distribution of the teacher), which provides richer information about word relationships.
- Shared Matrix Factorization: The authors observe that the embedding layer and the softmax layer perform similar semantic tasks. They force these layers to share a single weight matrix ($W_{shared}$), effectively cutting the parameter count of these layers in half.
- Low-Rank Approximation (SVD): Singular Value Decomposition (SVD) is used to decompose the large shared matrix into two much smaller matrices, assuming the weight matrices are redundant.
- Quantization: Finally, 16-bit quantization is applied to the weights, further halving the memory footprint compared to standard 32-bit floats.
Datasets
The models were trained on a massive corpus of public internet data:
- Reddit: 1.1 billion words (71.2M sentences).
- Twitter: 0.9 billion words (55.2M sentences).
- Evaluation Dataset: A manually curated set of 102 sentences (926 words) representing formal and informal utterances was used to benchmark against commercial competitors.
Key Results and Insights
The proposed method resulted in a model that is roughly 8x smaller than the baseline with only a minor increase in perplexity (from 56.55 to 59.78). The final model size is 7.40 MB with a latency of 6.47 ms, both well within mobile hardware limits.
In terms of performance, the model achieved a Keystroke Saving (KSS) rate of 65.11%, outperforming Apple (64.35%), SwiftKey (62.39%), and Google (58.89%). The Word Prediction Rate (WPR) reached 34.38%, taking the top spot among commercial solutions.
A key insight of this work is the use of Shared Matrix Factorization. By recognizing that input embeddings and output weights inhabit the same semantic space, the authors achieved massive savings with negligible accuracy loss. Furthermore, Knowledge Distillation was used not just for size reduction, but to compensate for the precision lost during subsequent matrix factorization and quantization steps.
Conclusion and Future Work
The primary limitation of the current RNN-LM is personalization. While excellent at general language, the model does not yet adapt to an individual user's unique slang or typing habits. Currently, the system interpolates the RNN-LM with traditional n-gram statistics to handle user-specific words. Future work will focus on directly personalizing the RNN-LM itself, allowing the neural network to learn from local user data without the need for auxiliary n-gram models.
Summary updated