October 22, 2026

1. Introduction & Business Problem

  • Modern mobile interfaces demand intelligent, real-time text completion to reduce typing effort and cognitive load.
  • Goal: Develop an accurate, ultra-low latency predictive text engine capable of running seamlessly on web and mobile environments.
  • Value Proposition:
    • Sub-millisecond response times.
    • Zero heavy server dependencies.
    • Scalable statistical Natural Language Processing (NLP) architecture.

2. Text Corpus & Preprocessing Pipeline

  • Training Corpus: English text sourced from SwiftKey (en_US.blogs.txt, en_US.news.txt, en_US.twitter.txt) totaling > 4 million lines.
  • Cleaning Strategy:
    • Tokenization, lower-casing, URL removal, and punctuation stripping.
    • Removal of profanity and low-frequency sparse tokens.
  • Corpus Characteristics:
Source Lines Words
Blogs 899,288 37.3 M
News 1,010,242 34.4 M
Twitter 2,360,148 30.3 M

3. Algorithm: Simplified Katz’s Back-Off

The predictive engine employs an \(N\)-gram language modeling approach with back-off fallback:

  1. Trigram Match (\(N=3\)): Given the last two typed words \((w_{i-2}, w_{i-1})\), search for the candidate \(w_i\) maximizing \(P(w_i \mid w_{i-2}, w_{i-1})\).
  2. Bigram Fallback (\(N=2\)): If no matching trigram exists, back off to \((w_{i-1})\) to find the most probable \(w_i\).
  3. Unigram Fallback (\(N=1\)): If an unseen term is entered, default to the corpus mode (e.g., “the”).
  4. Pruning: Frequency matrices were pruned by removing singleton occurrences, reducing RAM usage by > 85%.

4. Shiny Web Application Interface

  • Features: Clean UI, instant reactive prediction, and algorithmic transparency explaining which \(N\)-gram rule resolved the query.

5. Conclusion & Product Roadmap

  • Demonstrated Strengths: High out-of-sample accuracy on common phrases with negligible latency.
  • Future Enhancements:
    • Semantic context weighting via word embeddings (Word2Vec / GloVe).
    • Adaptive user vocabulary personalization based on local browser cache.
  • Live Links:
    • Shiny App: https://jramirezgen.shinyapps.io/next_word_predictor/
    • GitHub Code: https://github.com/jramirezgen/