Next Word Predictor

ZHAO JIALIN

Typing on phones? It’s a pain. Let’s fix that.

The problem: Typing on mobile devices is slow and frustrating.

  • People type 40% slower on phones than on keyboards
  • Predictive text saves time and reduces typos
  • Existing solutions are often heavy or opaque

Our solution: A fast, transparent N-gram predictor.

  • Runs on a 4 MB model (loads in under 1 second)
  • Returns predictions in under 50 milliseconds
  • Shows the top 5 candidates with full transparency

Under the hood: a clever N-gram engine

We use an N-gram language model with Katz-style backoff:

  • 4-gram → uses the last 3 words
    e.g. “I love to” → predicts “eat”
  • 3-gram → falls back to the last 2 words
  • 2-gram → falls back to the last 1 word
  • Unigram → final fallback (most frequent word)

Training data: 10% sample of English blogs, news, and tweets
(more than 4 million lines, 10 million words).

Key trick: Pruning n-grams with frequency < 3 keeps the model
small enough for a free Shiny server.

Try it live – it’s fast!

Play with the app: https://adlinehaha.shinyapps.io/NextWordApp/

Shiny App Screenshot

Numbers that matter:

  • Response time: under 50 milliseconds per prediction
  • Top-5 accuracy: about 60% on test phrases
  • Model size: 4 MB, loads in under 1 second
  • Coverage: 107 words cover 50% of all word occurrences

Why you’ll love it (and what’s next)

Why it’s great:

  • Fast: Sub-second loading on a free server
  • Transparent: Shows all 5 candidates, not just one
  • Extensible: Can be upgraded to RNNs or transformers later
  • Practical: Ready for keyboards, autocomplete, writing assistants

Next steps:

  • Train on full corpus for higher accuracy
  • Add smartphone keyboard integration
  • Explore deep learning (LSTM, BERT) for context-aware prediction

Thank you! Questions?