Suggesting Your Next Word

Asher Zafar
May 26, 2018

You took the words right out of my mouth...

  • Sometimes, finding the right word is hard.
  • Typing an entire word out can be time consuming, too.
  • Using big data, this prototype model can suggest your next word to you!

How It Works

To suggest the next word of a phrase, we need a language model that can learn from relevant text. Using a large amount of text from Twitter, internet blogs, and news sites, I trained a model to predict the most likely next word. This includes the following steps:

  1. Creating training data by creating and counting all the tokenized n-grams in the text and calculating the frequency of the last word to occur.
  2. Developing a model which matches the last three words of a user's input to the data and suggests the most frequent next word.
  3. Implementing a “simple backoff” algorithm that looks at shorter n-grams if there is no match.

Using the App

  1. To use the app, enter your text in the labelled box on the left, and click on “Predict Next Word”. Try it here!
  2. The windows on the right will show what you input, the last three words that were used in the model, and the top predictions in order of probability
  3. If there is no match, or your input is too short, the app will ask you to enter more text.

Screenshot of next word suggestion app

Key Features and Roadmap

Current Features:

  • Predicts not just the most likely next word, but the next most likely options, too.
  • Mobile-responsive - works in any browser with no app required.

Future Features:

  • The app could improve its accuracy by using Kat'z Back-Off or other algorithms.
  • New variables could be generated, such as longer n-grams, parts of speech, topics and sentiment. These could be fed into a model such as an SVM or neural network that would provide predictions, though this would require significantly greater computing resources.