How to find similar words with FastText?

Isbister picture Isbister · Feb 13, 2017 · Viewed 14.4k times · Source

I am playing around with FastText, https://pypi.python.org/pypi/fasttext,which is quite similar to Word2Vec. Since it seems to be a pretty new library with not to many built in functions yet, I was wondering how to extract morphological similar words.

For eg: model.similar_word("dog") -> dogs. But there is no function built-in.

If I type model["dog"]

I only get the vector, that might be used to compare cosine similarity. model.cosine_similarity(model["dog"], model["dogs"]]).

Do I have to make some sort of loop and do cosine_similarity on all possible pairs in a text? That would take time ...!!!

Answer

Snehal picture Snehal · Feb 15, 2017

Use Gensim, load fastText trained .vec file with load.word2vec models and use most_similiar() method to find similar words!