Predictive Text Modeling & Next-Word Recommendation Engine

Data Science Capstone — Algorithm & Product Pitch

Divanshu Gautam

The Problem & Value Proposition

Why Predictive Text Matters

  • Mobile and web users expect instant, context-aware autocomplete suggestions with zero typing delay.
  • Heavy neural language models require hundreds of megabytes of RAM, making them slow and expensive to host at scale.

Our Solution

  • Trained on the English HC Corpora dataset (Blogs, News, and Twitter: >100M words).
  • Compresses massive text corpora into lightweight, pre-indexed N-Gram lookup tables delivering sub-10 ms predictions on minimal cloud hardware.

Stupid Backoff Algorithm & Live Code Demo

Hierarchical N-Gram Lookup (4-Gram \(\rightarrow\) 3-Gram \(\rightarrow\) 2-Gram \(\rightarrow\) Unigram)

ng3 <- data.frame(p = c("for the", "going to"), w = c("first", "be"))
ng2 <- data.frame(p = c("the", "to"), w = c("first", "the"))

predict_demo <- function(phrase) {
  words <- unlist(strsplit(tolower(trimws(phrase)), " +"))
  n <- length(words)
  if (n >= 2 && paste(words[(n-1):n], collapse=" ") %in% ng3$p)
    return(ng3$w[ng3$p == paste(words[(n-1):n], collapse=" ")])
  if (n >= 1 && words[n] %in% ng2$p)
    return(ng2$w[ng2$p == words[n]])
  return("the")
}
predict_demo("Thanks for the")
[1] "first"

User Instructions & Shiny App Interface

Live Application: https://gunnu11.shinyapps.io/CapstoneApp/

How to Use the App

  1. Open the App: Navigate to the live shinyapps.io URL above in any desktop or mobile browser.
  2. Enter a Phrase: Type any English phrase into the Enter an English phrase input box (default: “Thanks for the”).
  3. View Real-Time Prediction: The app automatically updates the predicted next word as you type (or when clicking Predict Next Word) and displays the exact N-Gram backoff level matched.

Commercial Potential & Next Steps

Why Invest in This Engine?

  • Low-Cost Scalability: Runs smoothly on free/entry-tier cloud containers with minimal memory footprint.
  • Broad Applicability: Easily adaptable to search-bar autocomplete, support-ticket routing, and custom domain keyboards.

Roadmap