Ranjeet Kumar
August 2026
Data Science Capstone — Johns Hopkins University / SwiftKey
Typing, with the next word already suggested.
Typing on a phone is slow. Every keystroke saved is time returned to the user — which is why every major mobile keyboard predicts the next word.
What was built
The engineering constraint
The raw corpus cannot ship. The finished model must fit in the memory of a free shinyapps.io instance and respond fast enough to feel instant — so the real work was making it small, not just accurate.
N-gram counting with stupid backoff.
Why stupid backoff: it needs no expensive normalisation, and for ranking the top few candidates it performs comparably to full Kneser-Ney smoothing at a fraction of the cost. A prediction is always returned — the unigram fallback guarantees it, even for words the model has never seen.
Use it in one step: type a phrase. The prediction appears as you type.
| Element | What it does | |—|—| | Text box | Accepts any phrase, any length | | Big blue word | The single most likely next word | | Chips below | Alternative suggestions | | Table | Score, and which n-gram produced the answer | | Slider | Show 1–5 candidates | | Example links | One click to try a sample phrase |
No submit step is required, though a Predict button is provided. Punctuation, capitalisation, URLs and hashtags are handled automatically, and profanity is filtered from the training data so it is never suggested.
| Measure | Result | |—|—| | Training data | 35% of the corpus — 1.5 M lines | | Model in memory | 63 MB (7 MB on disk) | | Median response time | 11 ms (95th pct: 17 ms) | | Top-1 accuracy | 14.4% | | Top-3 accuracy | 21.7% |
Measured on 2,000 phrases the model never saw in training. For context, a random guess from a 300,000-word vocabulary is right about once in 300,000 attempts — this is right roughly once every five keystrokes, in the time between keypresses.
Where it goes next: learning from each user's own typing, and swapping counts for a small neural model where memory allows.
Try it
https://ranjeetk25.shinyapps.io/capstone_app/
A model trained on a hundred million words, answering in the time it takes to press the next key.