Abstract
This paper explores the application of Federated Learning (FL) to next-word prediction in mobile keyboards. By training a recurrent neural network (RNN) directly on user devices using the FederatedAveraging algorithm, the researchers demonstrate that models can achieve superior predictive accuracy compared to traditional server-based training. This approach not only improves user experience through higher recall and click-through rates but also significantly enhances privacy by ensuring raw user data never leaves the device.
Introduction
Next-word prediction (NWP) is a critical feature for mobile interfaces, reducing typing effort by suggesting likely continuations of text. Traditionally, these models—ranging from n-grams to neural networks—were trained on central servers using data snippets logged from users. However, this centralized approach faces two major challenges: privacy risks associated with collecting raw keystrokes and a lack of data representativeness, as logged snippets are often truncated and do not capture the full distribution of user typing behavior across various applications.
To address these issues, this work implements a decentralized training pipeline that keeps sensitive data on-device, leveraging the unique characteristics of local user caches to build a more robust language model.
Methodology
The CIFG-RNN Model
The researchers utilized a Coupled Input and Forget Gate (CIFG) architecture, a variant of the Long Short-Term Memory (LSTM) network. By simplifying the gate structure, the CIFG reduces the number of parameters per cell by 25% compared to standard LSTMs. This optimization is vital for mobile deployment, where memory and computational resources are limited. The final model contains 1.4 million parameters and is compressed to 1.4 MB via quantization.
The Federated Learning Pipeline
Training is conducted using the FederatedAveraging algorithm, which orchestrates a decentralized learning process across a massive fleet of mobile devices.
The cycle consists of four main stages:
- Distribution: The server broadcasts the current global model to a subset of eligible devices (idle, charging, and on un-metered Wi-Fi).
- Local Training: Each device computes model updates (gradients) using its local cache of typed text via Stochastic Gradient Descent (SGD).
- Aggregation: Devices transmit only the model updates back to the server, where they are averaged to update the global model.
- Iteration: This process repeats over thousands of rounds to achieve convergence.
Experimental Setup
The study compared two primary data sources: server-hosted logs consisting of ~7.5 billion truncated sentences and client-side caches representing the "ground truth" of on-device typing behavior. Evaluation was performed using both held-out server logs and live production A/B tests with Gboard users.
Results and Discussion
Performance and Convergence
The federated model demonstrated a clear advantage in predictive accuracy. On client-owned data, the Federated CIFG achieved a 15.8% Top-1 recall, outperforming both the baseline n-gram model (13.0%) and the server-trained neural model (15.0%).
The model reached convergence after approximately 3,000 training rounds, involving 1.5 million clients over a period of 4–5 days. In live production environments, the federated model resulted in a roughly 10% increase in the Prediction Click-Through Rate (CTR) compared to the n-gram baseline.
Privacy and Data Quality
A key finding is that Federated Learning avoids the typical "utility trade-off" where privacy-preserving measures degrade performance. Instead, FL improved accuracy because local on-device data provides a higher-quality, more comprehensive representation of typing behavior than the truncated snippets available to central servers.
Conclusion
Federated Learning proves to be a powerful paradigm for mobile keyboard prediction, delivering both better performance and stronger privacy guarantees. Future work will focus on further hardening the system through Secure Aggregation and Differential Privacy, as well as exploring communication compression techniques for larger models.
Summary updated