Applied Federated Learning: Improving Google Keyboard Query Suggestions

Timothy Yang, Galen Andrew, Hubert Eichner, Haicheng Sun, Wei Li, Nicholas Kong, Daniel Ramage, Françoise BeaufaysarXiv 2018

Introduction

Virtual keyboards like Gboard must balance providing highly relevant, real-time suggestions—such as GIFs, stickers, or web searches—with the imperative of user privacy and device performance. Traditional machine learning typically requires aggregating user data on central servers. However, typing data is highly sensitive, and users expect it to remain local. Furthermore, the "ground truth" for suggestion quality—whether a user clicks or ignores a suggestion—is only available on the device. This paper addresses the challenge of learning from local interactions to improve global model quality without compromising raw data privacy.

System Architecture

The researchers employ Federated Learning (FL), a decentralized training paradigm where the server distributes a "training task" (model and metadata) to eligible devices rather than collecting data. The system utilizes a two-stage architecture:

  1. Baseline Model: A server-side model trained on traditional corpora (using Knowledge Graphs and LSTMs) that generates potential query candidates.
  2. Triggering Model: A lightweight, on-device model trained via FL that acts as a gatekeeper, deciding whether to display a suggestion to the user.
The Gboard FL architecture separates on-device inference and training from centralized aggregation.

The triggering model initially utilized Logistic Regression to predict click probability based on features such as time of day, historical user interactions, and the baseline model's score. Training was conducted using the Federated Averaging algorithm, where devices compute local weight updates and upload only these "deltas" for server-side aggregation.

Data Management

In this FL application, no centralized training dataset exists for the triggering model. Instead, data is handled through:

  • On-Device Training Cache: Each device maintains a local SQLite database of feature-label pairs derived from real-time user interactions (e.g., "clicked" vs. "ignored").
  • Baseline Training: The initial baseline model was trained on an offline corpus of chat data to detect query candidates.
  • Proxy Data: Synthetic data was used during development to validate the architecture and select initial hyperparameters.

Training Dynamics and Challenges

Training progress in a production FL environment is non-linear due to device availability constraints. Devices typically only participate when they are idle, charging, and connected to Wi-Fi. This leads to diurnal training cycles, where the number of completed rounds and available training examples fluctuate significantly every 24 hours.

Furthermore, these constraints introduce population skew. The training population is naturally biased toward higher-end devices and specific geographic regions compared to the broader user base. Debugging also requires new techniques; without access to raw data, researchers must inspect learned model weights directly to identify issues, such as feature scaling problems.

Experimental Results

The FL-trained triggering model significantly outperformed the baseline in live deployments. Key metrics include:

  • CTR Improvement: The final iteration, which incorporated an LSTM-based featurizer, achieved a +51.49% relative increase in click-through rate (CTR) compared to the baseline.
  • High Precision: The model effectively filtered low-quality suggestions, retaining 82.01% of clicks while substantially reducing total impressions.
  • Convergence: Despite the decentralized and intermittent nature of training, the system successfully completed thousands of rounds, with evaluation loss showing a steady downward trend.
Train and evaluation loss over 4,000 rounds of federated training.

Conclusion and Future Work

This work demonstrates the first large-scale production deployment of FL for keyboard suggestions. While successful, challenges remain, including a slight "metric delta" between federated evaluation and live performance due to population skew, and the need to manage model drift as user behavior evolves. Future research will focus on narrowing these gaps and exploring more complex on-device architectures.

Summary updated

BibTeX
@misc{yang2018applied,
  author = {Timothy Yang and Galen Andrew and Hubert Eichner and Haicheng Sun and Wei Li and Nicholas Kong and Daniel Ramage and Françoise Beaufays},
  title = {{Applied Federated Learning: Improving Google Keyboard Query Suggestions}},
  year = {2018},
  eprint = {1812.02903},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1812.02903},
}
Figure