Back office ops · Production

Grammarly builds a compact on-device spelling and grammar correction model (~1B parameters)

The problem

Grammarly's writing assistance goes offline when internet is unavailable because its corrections rely on multiple large models that cannot run on a user's device due to limited memory and processing capabilities.

First attempt

T5, an encoder-decoder model evaluated as a base model candidate, failed the tokenization requirement by converting nonstandard spaces to regular spaces, making it unsuitable.

Workflow diagram · grounded in source
1
User writes in real time
trigger
“Users expect Grammarly to provide real-time suggestions as they write”
2
Llama tokenizes input
ai_action
“accurately tokenize user input without making meaning-altering changes”
3
Model corrects spelling and grammar
ai_action
“identify and appropriately correct common spelling and grammar mistakes”
4
Suggestions delivered inline
output
“return quality suggestions that actually improve the user's writing”
5
Human annotator evaluation
validation
“evaluated it using publicly available datasets and human annotators”
6
Small-user-set feedback rollout
feedback_loop
“roll out this model to a small set of users to get feedback and continue iterating on the experience”
Reported outcome

A compact ~1B parameter model achieves ~210 tokens/second on an M2 Mac with a 70% reduced memory footprint, enabling real-time on-device spelling and grammar corrections without loss in quality.

Reported metrics
On-device processing speed~210 tokens/second
Memory footprint reduction from quantization70%
Performance threshold for real-time correction50 tokens per second
Model parameter count~1B parameters
Reported stack
LlamaT5MLXGQA
Source
https://www.grammarly.com/blog/engineering/efficient-on-device-writing-assistance/
Read source ↗

Frequently asked questions

What did this team achieve with this AI workflow?

A compact ~1B parameter model achieves ~210 tokens/second on an M2 Mac with a 70% reduced memory footprint, enabling real-time on-device spelling and grammar corrections without loss in quality.

What tools did this team use?

Llama, T5, MLX, GQA.

What results were reported?

On-device processing speed: ~210 tokens/second; Memory footprint reduction from quantization: 70%; Performance threshold for real-time correction: 50 tokens per second; Model parameter count: ~1B parameters (source-reported, not independently verified).

What failed first in this deployment?

T5, an encoder-decoder model evaluated as a base model candidate, failed the tokenization requirement by converting nonstandard spaces to regular spaces, making it unsuitable.

How is this back office ops AI workflow structured?

User writes in real time → Llama tokenizes input → Model corrects spelling and grammar → Suggestions delivered inline → Human annotator evaluation → Small-user-set feedback rollout.