This directory contains models for unsupervised training of word embeddings using the model described in:

(Mikolov, et. al.) Efficient Estimation of Word Representations in Vector Space, ICLR 2013.

Detailed instructions on how to get started and use them are available in the tutorials. Brief instructions are below.

Assuming you have cloned the git repository, navigate into this directory. To download the example text and evaluation data:

curl >
curl >
unzip -p  word2vec/trunk/questions-words.txt > questions-words.txt

You will need to compile the ops as follows (See Adding a New Op to TensorFlow for more details).:

TF_CFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') )
TF_LFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))') )
g++ -std=c++11 -shared -o -fPIC ${TF_CFLAGS[@]} ${TF_LFLAGS[@]} -O2 -D_GLIBCXX_USE_CXX11_ABI=0

On Mac, add -undefined dynamic_lookup to the g++ command. The flag -D_GLIBCXX_USE_CXX11_ABI=0 is included to support newer versions of gcc. However, if you compiled TensorFlow from source using gcc 5 or later, you may need to exclude the flag. Specifically, if you get an error similar to the following: undefined symbol: _ZN10tensorflow7strings6StrCatERKNS0_8AlphaNumES3_S3_S3_ then you likely need to exclude the flag.

Once you've successfully compiled the ops, run the model as follows:

python \
  --train_data=text8 \
  --eval_data=questions-words.txt \

Here is a short overview of what is in this directory.

File What's in it? A version of word2vec implemented using TensorFlow ops and minibatching. Integration test for word2vec. A version of word2vec implemented using C ops that does no minibatching. Integration test for word2vec_optimized. Kernels for the custom input and training ops. The declarations of the custom ops.