On-Device Personalized Lexicon Learning for Mobile Keyboard

grammarly · Tech · 2024 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Mobile keyboard personalization

Grammarly needed its iOS keyboard to learn personal vocabulary for autocorrection without sending private user text to the cloud or exceeding tight mobile memory and latency budgets.

Constraints:

Architecture

Grammarly built an on-device lexicon learner using memory-mapped storage, time-based decay, noisy-input filtering, and edit-distance frequency thresholds to validate new personal words.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  keyboard-input-stream["Keyboard Input Stream"]
  noisy-input-filter["Noisy Input Filter"]
  frequency-thresholding["Frequency Thresholding"]
  personal-lexicon-store["Personal Lexicon Store"]
  autocorrection-suggestions["Autocorrection Suggestions"]
  keyboard-input-stream --> noisy-input-filter
  noisy-input-filter --> frequency-thresholding
  frequency-thresholding --> personal-lexicon-store
  personal-lexicon-store --> autocorrection-suggestions
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Keyboard Input Stream Provides candidate personal vocabulary observations. Noisy Input Filter
Noisy Input Filter Filters likely typos before vocabulary learning. Frequency Thresholding
Frequency Thresholding Uses edit distance and frequency to verify new words. Personal Lexicon Store
Personal Lexicon Store Stores learned vocabulary locally using memory-mapped storage and decay. Autocorrection Suggestions
Autocorrection Suggestions Uses the personal lexicon to reduce incorrect corrections. —

Data flow

Keyboard usage provides candidate vocabulary, noisy input filters remove likely typos, edit-distance frequency thresholds validate new words, time-based decay manages vocabulary lifetime, and memory-mapped storage keeps the lexicon small and local.

“The solution involved memory-mapped storage, time-based decay functions for vocabulary management, noisy input filtering, and edit-distance-based frequency thresholding to verify new words.”summary, stated
“learns users' personal vocabulary and provides personalized autocorrection suggestions without sending data to the cloud.”summary, stated

Why this architecture

On-device learning was required to preserve privacy while memory-mapped storage and decay kept the system responsive under strict mobile constraints.

“without sending data to the cloud.”summary, stated
“operating within severe mobile constraints (under 5 MB RAM, minimal latency).”summary, stated

Models used: On-device machine learning model · Memory-mapped storage · Edit-distance frequency thresholding

Scale

Alternatives considered (roads not taken)

Cloud-based personalized vocabulary learning

Rejected because: The design avoided sending personal vocabulary data to the cloud.

“without sending data to the cloud.”summary, stated

Accept every new token as personal vocabulary

Rejected because: The model had to distinguish valid personal words from typos.

“distinguish between valid personal vocabulary and typos”summary, stated

Patterns

agent-memory (personalization)

The keyboard maintains a persistent local personal lexicon that changes future autocorrection behavior.

“learns users' personal vocabulary and provides personalized autocorrection suggestions”summary, stated

safety-policy-enforcement (privacy)

The system keeps personal vocabulary on-device rather than sending it to the cloud.

“without sending data to the cloud.”summary, stated

cost-aware-routing (mobile-efficiency)

Memory-mapped storage and small RAM usage keep the local model practical on mobile devices.

“maintaining minimal memory footprint and responsive performance.”summary, stated

Tradeoffs

Keep learning on-device

Chose Local lexicon learning over Cloud-based personalization.

Rationale: On-device learning protects user text privacy while enabling personalized corrections.

“provides personalized autocorrection suggestions without sending data to the cloud.”summary, stated

Use decay and thresholds

Chose Managed vocabulary lifecycle over Permanent accumulation of all observed tokens.

Rationale: Decay and verification help distinguish true personal vocabulary from noise.

“time-based decay functions for vocabulary management”summary, stated

Gotchas (what bit them)

Personalization can learn typos as vocabulary.

Root cause: Keyboard input includes noisy mistakes alongside real personal words.

Resolution: Use noisy input filtering and edit-distance frequency thresholds.

“noisy input filtering, and edit-distance-based frequency thresholding to verify new words.”summary, stated

Mobile personalization has severe memory and latency limits.

Root cause: Keyboard suggestions must remain responsive on-device.

Resolution: Use memory-mapped storage and a minimal memory footprint.

“operating within severe mobile constraints (under 5 MB RAM, minimal latency).”summary, stated

Evaluation

Grammarly evaluated deployed behavior with reverted suggestion rates, acceptance rates, memory footprint, and responsiveness.

Metrics: Reverted suggestion rate · Suggestion acceptance rate · Memory footprint · Latency/responsiveness

“decreased rates of reverted suggestions and increased acceptance rates”summary, stated

Outcomes

Deployment reached over 5 million iOS keyboard devices under a sub-5 MB RAM constraint.

“Deployed to over 5 million devices, the model demonstrated measurable improvements”summary, stated