Gmail Smart Compose (Text Autocomplete)
Goal: suggest the rest of the sentence as the user types an email; suggestions must be fast (< ~100 ms per keystroke), useful, and safe.
context: subject + previous email (if reply) + text typed so far + (opt.) locale, time
-> tokenizer -> small transformer LM (decoder, or encoder for context + decoder)
-> beam search, few tokens, stop at phrase boundary -> confidence threshold -> show grey suggestion
user presses Tab = accept (positive) / keeps typing = reject (negative)
- Model: a compact language model trained on (de-identified) email text; latency dominates → small model, quantization, caching per-keystroke state (KV cache / incremental decoding), run on TPU/GPU servers or on device.
- Decoding: beam search for short, high-probability completions; only show when confidence is high (bad suggestions annoy more than none).
- Personalization: user-level adaptation (e.g. a lightweight personalized n-gram/adapter blended with the global model).
- Safety & privacy: never memorize/leak private data (differential privacy, de-duplication, filtering rare sequences), filter offensive or biased suggestions (e.g. gendered pronoun assumptions).
- Metrics: offline perplexity, exact-match@k on held-out emails; online acceptance rate, characters saved per email, latency p99.