word2vec has been disabled : We've intentionally disabled the word2vec function after recognizing it has the potential to produce harmful outputs while using the pre-trained model files included in our examples. We'll consider reenabling the word2vec function along with changes to address these issues in a future release of ml5.js
.
Description : Word2vec is a group of related models that are used to produce word embeddings. This method allows you to perform vector operations on a given set of input vectors.
Quickstart :
// Create a new word2vec method
const wordVectors = ml5.word2vec('data/wordvecs.json', modelLoaded);
// When the model is loaded
function modelLoaded() {
console.log('Model Loaded!');
}
// Find the closest word to 'rainbow'
wordVectors.nearest('rainbow', (err, results) => {
console.log(results);
});
Usage :
Initialize
const word2vec = ml5.Word2Vec(model, ?callback);
Parameters
* model : A string to the path of the JSON model.
* callback : Optional. A callback function that is called once the model has loaded. If no callback is provided, it will return a promise that will be resolved once the model has loaded.