Book Deep Read · Generative AI System Design Interview · Ch 2

Gmail Smart Compose: the latency budget moves first, quality fights over what is left

Generative AI System Design Interview · Ch 2 · Ali Aminian, Hao Sheng & Alex Xu · 2024

中文 →

What is this chapter about?

You are typing an email in Gmail. Halfway through a sentence, a line of pale grey text appears after your cursor, finishing exactly the thought you were having. Press Tab and it becomes your own words. This chapter is about how that guess-as-you-type system gets built.

An analogy

Picture an assistant standing behind you. You type a word, they lean in and offer you half a sentence. To be useful they have to do three things at once: guess right, hand it over fast, and know when to keep quiet. The hard one is not the first. It is the second. The gap between your finger going down and coming back up is a fraction of a second. If the assistant needs a moment to think, you have already typed it yourself, and however elegant their phrase, it is wasted breath.

Why the old world struggled

Old-style word prediction only looked at the single word you were mid-way through, matched it against a dictionary, and stopped there. It had no idea what you were writing about. So it could finish "tomor—" into "tomorrow", but it could never produce "tomorrow at ten, does that work for you?" To continue like a human it first has to take in the whole thread: what the subject line says, what the previous email asked, where your half-finished sentence has got to. But taking things in costs time, and time is exactly what this system does not have.

How it pulls that off

Three moves.

One: read the background once and keep it. The subject line and the previous email do not change a single character while you type, so there is no point re-reading them on every keystroke. Read them once, park what you understood, and from then on only process the handful of characters you just added. That alone removes most of the work.

Two: stay small. At equal cleverness, a big model is slow and a small one is fast; when fast is the whole point, you take the slightly dumber one that arrives in time. This is the precise opposite of the usual "bigger is better" instinct.

Three: offer only the few words you are sure of — and stay quiet otherwise. It never tries to write the whole email, just three to five words, and when it is unsure it says nothing at all. Because a wrong offer costs far more than no offer: you have to stop, read it, judge it, dismiss it, and your sentence is gone. Saying nothing merely means you were not helped.

What it costs you

Because it only speaks when it is confident, it is silent most of the time. And because it has seen an enormous amount of polite boilerplate, what it hands you tends to be the most average, most template-shaped version of the sentence — useful, but it slowly sands the personality out of your email.

Remember this

In a guess-as-you-type product, the lead character is not how clever the model is. It is a timeline a few dozen milliseconds long: it decides first how big the model may be, how long it may think, how many words it may say — and only then does quality get to compete for what remains. Plus one piece of product common sense: when being wrong annoys people more than being silent, teach the system to shut up.

Want the mechanisms, the notation and the diagrams? → Switch to the deep read