public class Word2Vec
extends java.lang.Object
Word2vec can utilize either of two model architectures to produce a distributed representation of words: continuous bag-of-words (CBOW) or continuous skip-gram. In the continuous bag-of-words architecture, the model predicts the current word from a window of surrounding context words. The order of context words does not influence prediction (bag-of-words assumption). In the continuous skip-gram architecture, the model uses the current word to predict the surrounding window of context words. The skip-gram architecture weighs nearby context words more heavily than more distant context words. According to the authors' note, CBOW is faster while skip-gram is slower but does a better job for infrequent words.
Modifier and Type | Field and Description |
---|---|
smile.data.DataFrame |
vectors
The vector space.
|
java.lang.String[] |
words
The vocabulary.
|
Constructor and Description |
---|
Word2Vec(java.lang.String[] words,
float[][] vectors)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
float[] |
apply(java.lang.String word)
Returns the vector embedding of a word.
|
int |
dimension()
Returns the dimension of vector space.
|
float[] |
get(java.lang.String word)
Returns the vector embedding of a word.
|
static Word2Vec |
of(java.nio.file.Path file)
Loads a pre-trained
word2vec model from binary file of ByteOrder.LITTLE_ENDIAN.
|
static Word2Vec |
of(java.nio.file.Path file,
java.nio.ByteOrder order)
Loads a pre-trained
word2vec model from binary file.
|
public final java.lang.String[] words
public final smile.data.DataFrame vectors
public Word2Vec(java.lang.String[] words, float[][] vectors)
words
- the vocabulary.vectors
- the vectors of d x n, where d is the dimension
and n is the size of vocabulary.public int dimension()
public float[] get(java.lang.String word)
public float[] apply(java.lang.String word)
public static Word2Vec of(java.nio.file.Path file) throws java.io.IOException
java.io.IOException
public static Word2Vec of(java.nio.file.Path file, java.nio.ByteOrder order) throws java.io.IOException
java.io.IOException