April 2026

The Problem & Our Solution

Why predictive text matters

  • The average person types 40 words per minute on a phone
  • Predictive keyboards can reduce keystrokes by 30-40%
  • Saves time, reduces errors, improves accessibility

What we built

A next-word prediction engine that:

  • Suggests the top 5 most likely words as you type
  • Runs in a web browser via a Shiny app — no install needed
  • Loads in under 3 seconds with a 10 MB model

Think of it as autocomplete — trained on 640,000 real sentences from blogs, news, and Twitter.

How the Algorithm Works

4-Gram Interpolated Backoff

The model combines four levels of word patterns:

Level Example Weight
4-gram “I want to go 45%
Trigram “want to go 25%
Bigram “to the 20%
Unigram the” (most common) 10%

Each level votes on the next word. Longer patterns get more weight because they capture more context.

Key design choices: Vocabulary: 52,000 words (covers 95%+ of English text) | Trained on 15% sample (~640K lines) from HC Corpora | Integer-encoded for compact storage (14 MB RAM)

Quantitative Performance

Accuracy on 20,000 held-out predictions

Metric Score What it means
Top-1 16.6% Correct word is the #1 suggestion
Top-3 27.3% Correct word in top 3 suggestions
Top-5 32.7% Correct word in top 5 suggestions

Speed & Efficiency

Metric Value
Model on disk 10 MB
RAM usage 14 MB
Prediction speed < 150 ms
Vocabulary 52,404 words

1 in 3 times, the correct word appears in the suggestion bar — competitive with early smartphone keyboards.

The App in Action

Live demo — type a phrase, get instant predictions:

Input:  "I want to"

  [be]   [go]   [do]   [see]   [get]
   36%    18%    17%    16%     12%

Features:

  • Click a suggestion → it appends to your text and triggers new predictions
  • Confidence bars show how certain the model is about each word
  • Works on mobile — clean, responsive design
  • Self-contained — loads in under 3 seconds, runs in any browser

Next steps: Train on full corpus for higher accuracy | Add user-adaptive learning | Deploy as a REST API