0
$\begingroup$

I am trying to make a chatbot using a deep neural network in python using keras. The problem I am having is that for the deep neural network to work, the input dimension has to be fixed. So my question is, how can I map a sequence of words (sentence of different lengths) to a fixed vector so I am able to feed this through a deep neural network?

$\endgroup$
  • $\begingroup$ Look up "sentence embedding", word2vec, and paragraph2vec. $\endgroup$ – Emre Jan 6 '17 at 3:45
0
$\begingroup$

A recurrent neural network (RNN) is probably what you want to look into. It has exactly that capability of dealing with variable length input sequence. In fact, currently some of the most successful applications of RNN are in the NLP area, where the inputs are sentences of varying size. Just google recurrent neural network LSTM and you will find lots of tutorials.

$\endgroup$
0
$\begingroup$

There is a lot of research going on in this field of generating fixed length sentence vectors. Here are some of the ways.

  1. Train/Download vectors(https://code.google.com/archive/p/word2vec/). Add the word_vectors in the sentence to get the fixed length sentence vector. Surprisingly it gives decent results.
  2. If you have a huge corpus. One popular algorithm and used for various baselines is "Quoc Le & Tomáš Mikolov: “Distributed Representations of Sentences and Documents”. The gensim implementation can be found here. https://rare-technologies.com/doc2vec-tutorial/
  3. You may also download pretrained sentence vectors. Here are some of the sources.https://github.com/jhlau/doc2vec
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.