Smart autocomplete with tensorflow.js

May 04, 2019, at 1:30 PM

Is it possible to build some sort of autocomplete select which suggests values based on previous inputs?
Let’s say I have airport select with 5k items. I would like give user top 5 values to select based on his previous preferences.

Answer 1

Deep learning approach:

Basically what you want is an RNN powered word-level prediction model. Such models are used in text generation. You can refer to one example here.

These models specifically take in a word ( t ) and predict the next word ( t1 ). Then taking t1 it predicts t2. This cycle goes on until the max number of words is reached.

If I had to train such an RNN model on a single sentence like

Hello world from TensorFlow

Then the feature-label pairs would look like:

X, Y
Hello, World
World, from
from, TensorFlow

These sentences could be trained from the user's previous inputs.

Things you will require in building such a model:

  1. Lots of user data.
  2. A ranking algorithm to get the top N predictions
  3. Probably, a GPU or TPU. CPUs might prove to be very slow and might take days.

Non-Deep learning approach:

You can Bayes Theorem or simply check which word has the highest probability after a specific word. The word "morning" will have the highest probability after the word "good".


  • Mostly, you will also need to handle custom user words which you may not add in your dictionary. It could be the name of a person. So while collecting data, you need to tag such words into a common word like .
Rent Charter Buses Company
GXT HandlerManager Bus Memory Leak

GXT HandlerManager Bus Memory Leak

I'm search for a memory leak in a GWT applicationI started with Chrome to create HeapDumps and to compare them after certain actions

How to use pdf.js library in a firefox addon

How to use pdf.js library in a firefox addon

I'm making a Firefox add-on extension to insert a pdf document in the translated page of Google and I want to use pdfjs

How to integrate pdf viewer in website and customize it [on hold]

How to integrate pdf viewer in website and customize it [on hold]

Hello friends I'm working on website projects which needs to integrate PDF viewer and I also wanted to customize such that users can't use right click and download button will disabledand also suggest me if we want to see eBook which format will be suitable

loop returning the same value (Angular)

loop returning the same value (Angular)

I need to replace a template array with values from another array and push it to the final resultThis is what I have tried, the problem is that I get the same value when I loop