Next Word Predictor

Your Name
julio 17, 2026

Predict what your users type next — before they finish typing it

  • Capstone project built on the SwiftKey (blogs / news / twitter) corpus
  • A lightweight, fast, deployable Shiny app
  • This deck: the algorithm, the product, and why it's ready to ship

The Problem & The Approach

Problem: mobile keyboards need to suggest the next word instantly, with no server-side heavy lifting and no lag.

Approach: Stupid Backoff n-gram model (Brants et al., 2007)

  • Built 1-, 2-, 3-, and 4-word sequences (“n-grams”) from ~1.5M lines of real-world text
  • Given a typed phrase, look up what most often follows the last 3 words; if unseen, back off to the last 2 words, then 1, each time discounting the score by a factor of 0.4
  • Nearly matches the accuracy of far more expensive smoothing methods (e.g. Kneser-Ney) at a fraction of the memory and compute cost — which is exactly what a free-tier hosted app needs

How It Works, Step by Step

  1. User types a phrase into the text box
  2. Text is cleaned (lowercased, punctuation/URLs/handles stripped)
  3. The last 1-3 words become the lookup context
  4. The model checks, in order: 4-gram table → 3-gram table → 2-gram table → most frequent overall word
  5. The highest-scoring next word is returned, along with two runner-up suggestions
"I love to eat" -> looks up "to eat" -> "eat pizza" (top match)

The App: Try It Yourself

Live app: your-shinyapps-url-here

  • Type any phrase in English into the text box
  • Click Predict next word (or press Enter)
  • The top prediction appears instantly, with two alternatives below
  • No login, no setup — works on desktop or mobile browser

Example: type “how are” → predicts “you”

Why This Is Ready to Ship

  • Fast: predictions return in well under a second — no noticeable lag
  • Lightweight: pruned n-gram tables keep the whole model under the free-tier memory limit on shinyapps.io
  • Accurate: validated against held-out phrases from real tweets and news headlines
  • Extensible: same architecture scales to personalized models, additional languages, or on-device deployment

Next steps: A/B test against users' actual typing behavior and expand training data to boost coverage on rare phrasing.