View all files | ||||
wego is the implementations from scratch for word embeddings (a.k.a word representation) models in Go.
Word embeddings make words' meaning, structure, and concept mapping into vector space with a low dimension. For representative instance:
Like this example, the models generate word vectors that could calculate word meaning by arithmetic operations for other vectors.
The following models to capture the word vectors are supported in wego:
Word2Vec: Distributed Representations of Words and Phrases and their Compositionality [pdf]
GloVe: Global Vectors for Word Representation [pdf]
LexVec: Matrix Factorization using Window Sampling and Negative Sampling for Improved Word Representations [pdf]
Also, wego provides nearest neighbor search tools that calculate the distances between word vectors and find the nearest words for the target word. "near" for word vectors means "similar" for words.
Please see the Usage section if you want to know how to use these for more details.
Inspired by Data Science in Go @chewxy
Use go command to get this pkg.
wego provides CLI and Go SDK for word embeddings.
word2vec, glove and lexvec executes the workflow to generate word vectors:
query and console are the commands which are related to nearest neighbor searching for the trained word vectors.
query outputs similar words against a given word using sing word vectors which are generated by the above models.
e.g. wego query -i word_vector.txt microsoft:
wego does not reproduce word vectors between each trial because it adopts HogWild! algorithm which updates the parameters (in this case word vector) async.
console is for REPL mode to calculate the basic arithmetic operations (+ and -) for word vectors.
It can define the hyper parameters for models by functional options.
The models have some methods:
As training word vectors wego requires the following file formats for inputs/outputs.
Input corpus must be subject to the formats to be divided by space between words like text8.
After training wego save the word vectors into a txt file with the following format (N is the dimension for word vectors you given):