Data entry ops · Production

Google Research launches on-device grammar correction in Gboard on Pixel 6

The problem

Composing longer text on smartphones is cumbersome; grammatical errors frequently creep in and are time-consuming to correct on a small display. Building an on-device grammar correction feature required addressing memory size limitations, latency requirements, and the challenge of handling partial sentences.

Workflow diagram · grounded in source
1
User types in Gboard
trigger
“Gboard sends a request to the on-device grammar model whenever the user has typed more than three words, whether the sentence is completed or not”
2
On-device model corrects grammar
ai_action
“We trained a sequence-to-sequence neural network to take an input sentence (or a sentence prefix) and output the grammatically correct version — if the original text is already grammatically correct, the output of the model is identical …”
3
Extract replacement edits via alignment
ai_action
“we align the original sentence and the corrected sentence by minimizing the Levenshtein distance (i.e., the number of edits that are needed to transform the original sentence to the corrected sentence)”
4
Display grammar suggestions
output
“we underline the grammar mistakes and provide replacement suggestions when the user interacts with them”
Reported outcome

The on-device grammar correction model requires only 20MB of storage and performs inference under 22ms on 60 input characters on the Pixel 6 CPU, processing text entirely on-device to preserve privacy, with hard distillation producing significantly higher quality suggestions than training on the original cloud model data.

Reported metrics
On-device model storage size20MB
Inference latency on 60 input charactersunder 22ms
Suggestion quality vs baseline modelsignificantly higher quality suggestions
Reported stack
GboardTransformer encoderLSTM decoder
Source
https://ai.googleblog.com/2021/10/grammar-correction-as-you-type-on-pixel.html
Read source ↗

Frequently asked questions

What did this team achieve with this AI workflow?

The on-device grammar correction model requires only 20MB of storage and performs inference under 22ms on 60 input characters on the Pixel 6 CPU, processing text entirely on-device to preserve privacy, with hard disti…

What tools did this team use?

Gboard, Transformer encoder, LSTM decoder.

What results were reported?

On-device model storage size: 20MB; Inference latency on 60 input characters: under 22ms; Suggestion quality vs baseline model: significantly higher quality suggestions (source-reported, not independently verified).

How is this data entry ops AI workflow structured?

User types in Gboard → On-device model corrects grammar → Extract replacement edits via alignment → Display grammar suggestions.