Reputation: 21
How do I train Glove embeddings in gensim from scratch? Can I use gensim for this?
Upvotes: 2
Views: 1788
Reputation: 54173
Gensim doesn't implement the GLoVe algorithm. But it does offer the very-similar word2vec algorithm, which also creates a "dense embedding" (aka high-dimensional vector with many varied nonzero values) for individual words. See:
https://radimrehurek.com/gensim/models/word2vec.html
And, the FastText algorithm which, for some languages & purposes, can offer better-than-random guess-vectors for words it's never seen before, based on substrings within those words:
https://radimrehurek.com/gensim/models/fasttext.html
Gensim's KeyedVectors
class can also load sets of GLoVe vectors that were trained elsewhere, for applying those vectors to other tasks:
from gensim.models import KeyedVectors
glove_kv = KeyedVectors.load_word2vec_format(GLOVE_FILE, binary=False, no_header=True)
print(glove_kv['apple'])
Upvotes: 2