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

16 Downloads

Updated 11 Sep 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 = fastTextWordEmbedding;

% Find the top 10 closest word to “impedance” according to this word embedding
impedanceVec = word2vec(emb,"impedance");
vec2word(emb, impedanceVec,10)

ans =

10×1 string array

"impedance"
"impedances"
"capacitance"
"Impedance"
"resistor"
"impedence"
"inductance"
"voltage"
"S-parameters"
"ohms"

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 R2019b
Platform Compatibility
Windows macOS Linux