#torch-word-emb Load your word embeddings (Word2Vec and GloVe) into Torch tensor.
Torch 7 required.
luarocks install torch-word-emb
or
git clone https://github.com/iamalbert/torch-word-emb
cd torch-word-emb && luarocks make
local wordemb = require 'wordemb'
read word2vec binary-format model from path
.
returns a table of two fields.
vec
is a torchFloatTensor
of sizeV x D
, whereV
is the vocabulary size andD
is the dimension of word2vec.words
is a table of (word,offset) pairs, each of which represents the corresponding index of such word invec
.
local w2v = wordemb.load_word2vec_bin("/path/to/word2vec/model.bin")
print(w2v.vec:size())
print(w2v.vec[ w2v.words["apple"] ] )
read word2vec text-format model from path
.
read GloVe text-format model from path
.