word2vec vs fastText on text8

Two small word-embedding models trained on the same corpus with the same settings, for a class demo comparing word2vec with fastText subword embeddings (Bojanowski et al., 2017).

word2vec fastText
Files w2v_text8.model ft_text8.model + ft_text8.model.wv.vectors_ngrams.npy
Training time (16-thread CPU) ~30 s ~60 s
Size 59 MB 139 MB
Vectors for unseen words No Yes (sum of character n-gram vectors)

Shared settings: skip-gram, 100 dimensions, window 5, min_count 5, 5 negative samples, 5 epochs, seed 42. Vocabulary: 71,290 words. fastText only: character n-grams of length 3–6, 200,000 hash buckets. Corpus: text8 (first 100 MB of cleaned English Wikipedia, ~17M words). Trained with gensim 4.4.0.

Usage

from huggingface_hub import snapshot_download
from gensim.models import Word2Vec, FastText

path = snapshot_download("MrKhawaja/fasttext-vs-word2vec")
w2v = Word2Vec.load(f"{path}/w2v_text8.model")
ft = FastText.load(f"{path}/ft_text8.model")

ft.wv.most_similar("beautifull")   # works: built from subwords
w2v.wv["beautifull"]               # KeyError: word never seen
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support