November 2026

The Problem and the Product

People type billions of messages a day on phones, where every keystroke is slow. Suggesting the next word before it is typed saves time and reduces errors.

The product: a web app that reads the phrase you have typed and instantly suggests the most likely next word, plus alternatives.

The Algorithm: N-grams with Stupid Backoff

  1. Clean the text: lower case, remove numbers, punctuation and links, and split it into sentences.
  2. Count phrases: build tables of 2-, 3- and 4-word phrases (“n-grams”) and record which word usually comes next.
  3. Trim the model: drop rare phrases, keep only the top 5 next words per phrase, and filter out profanity.
  4. Predict: look up the last 3 words typed. If that phrase was never seen, back off to the last 2 words, then the last word, then the most common English words. Each step down is discounted by a factor of 0.4.


Example: “thank you for the” → seen in the 4-word table → suggests follow (common on Twitter)

Stupid Backoff (Brants et al., 2007) was chosen because it is simple, very fast, and performs close to more complex methods on large text collections.

How to Use the App

  1. Open the app and type a phrase of any length in the text box.
  2. The predicted next word appears in large text as you type. You can also press Predict next word.
  3. Other suggestions are shown as buttons. Click one to add it to your sentence and keep going.
  4. A note below the prediction says which phrase table the answer came from (4-, 3- or 2-word phrase, or most common word).
  5. Clear resets the box.

The app always returns a prediction, even for unusual input, because the backoff ends at the most common words.

Performance and Next Steps

Tested on 3,000 phrases from text the model never saw during training:

Source Correct on 1st guess Correct within top 3
Blogs 15.9% 26.9%
News 16.7% 26.4%
Twitter 16.5% 26.4%
Overall 16.4% 26.6%
  • Speed and size: 3.7 ms per prediction, with a 3.5 MB model. About 1 in 4 times, one of the three suggestions is exactly the word the user wanted.

Next steps: train on the full dataset with Kneser-Ney smoothing, learn from each user’s own typing, and run the model directly on a phone keyboard.