File Exchange

image thumbnail

Text Analytics Toolbox Model for fastText English 16 Billion Token Word Embedding

Pre-trained English Word Embedding Model for Machine Learning and Deep Learning with Text

41 Downloads

Updated 20 Mar 2019

This Add-on provides a pre-trained word embedding and sentence classification model using FastText for use in machine learning and deep learning algorithms. FastText is an open-source library which provides efficient and scalable libraries for text analytics. For more information on the pre-trained word vector model see : https://fasttext.cc/docs/en/english-vectors.html

Opening the fasttext.mlpkginstall file from your operating system or from within MATLAB will initiate the installation process for the release you have.
This mlpkginstall file is functional for R2018a and beyond.
Usage Example:
% Load the trained model
emb = fasttextenglishembedding()

% Convert the words king, man, and woman to vectors using word2vec
king = word2vec(emb,"king");
man = word2vec(emb,"man");
woman = word2vec(emb,"woman");

% Compute the vector given by king - man + woman
vec = king - man + woman

Find the closest words in the embedding to vec using vec2word
word = vec2word(emb,vec)

Comments and Ratings (4)

@Peter,
To add words to the embedding vocabulary, follow the steps below to create a new embedding object after reading it in:
>> emb = fasttextenglishembedding();
>> vocab = emb.Vocabulary;
>> mat = word2vec(emb,vocab);
>> newvocab = [vocab "sample 1" "sample 2"];
>> newmat = [mat ; randn(2,300)];
>> newemb = wordEmbedding(newvocab,newmat);

Is it possible to add additional words to the pretrained vocabulary? If so, how is this done?

MATLAB Release Compatibility
Created with R2018a
Compatible with R2018a to R2019a
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.


Learn About Live Editor