September 2026

The Problem

Every keyboard we use already tries to guess your next word. It’s one of the most-used pieces of “invisible AI” in our daily lives.

This helps us in

  • Faster typing; fewer keystrokes per message.
  • Better accessibility; crucial for users typing with limited mobility.

It is the same core idea behind auto-complete, smart-reply, and drafting assistants.

This project builds that capability from scratch. No external APIs, no pre-trained language model. The model was trained directly on a real-world corpus of news, blogs, and tweets, and it is as a working, interactive app.

The Algorithm

The model looks at the last few words you typed and asks: “What usually comes next, based on real text?” It checks the most specific pattern it has good evidence for, and falls back to something simpler if it doesn’t have enough data; a technique called “Stupid Backoff”.

5-gram
4-gram
Trigram
Bigram
Unigram

“Seen this exact 4-word pattern enough times before? Use it. If not, back off and try a shorter, more common pattern, all the way down to ‘the single most common word in English’ as a last resort.”

  • The model was trained on 20% of over 4M-line corpus of news, blogs, and Twitter text.
  • Every prediction ranked by real observed frequency, not a guess.

Results

Evaluated on 4,000 held-out examples the model never saw during training; measuring and ascertaining the level of accuracy of the model.

17.5%
Top-1 accuracy
right word, first guess
33.7%
Top-5 accuracy
right word, top 5 guesses

vs. ~5% for always guessing
the single most common word

The model is roughly 2.5x better than blind guessing, and the context-length pattern shows exactly where more training data would help most; a concrete, data-backed next step, not a guess.

Conclusion

This is a working, deployable prototype and not just a proof of concept.

  • Scale up training data: Since the model was trained on 20% of the available corpus; the accuracy-by-context chart shows real headroom here.
  • Workability: The same prediction engine already runs as a live, interactive app (built separately in Shiny), and can sit behind a browser extension, a messaging app, or a customer-support drafting tool
  • Extend the evaluation: Track exactly how often each backoff level fires, to target training data where it moves accuracy the most.

A self-built, fully explainable prediction engine, trained, evaluated, and shipped as a working app with a clear data-backed path to improving it further.