Build FastText Library from Github

Following are the requirements to build FastText successfully :

  • OS : Linux Distribution(like Ubuntu, CentOS, etc.) or MacOS
  • Compiler with C++11 support latest gcc or clang

Check if GCC is installed in your Linux Distribution

Run the command “gcc –version” to check if gcc is installed. If not, install gcc and proceed with the building of FastText.

$ gcc --version
root@arjun-VPCEH26EN:/home/arjun/workspace/fasttext/fastText# gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
ADVERTISEMENT

Build FastText

Open a terminal and run the following commands :

Clone fastText.git project to your local machine using git command.

$ git clone https://github.com/facebookresearch/fastText.git
Git Clone fastText.git - FastText Tutorial - www.tutorialkart.com
Git Clone fastText.git

Open fastText and make the build.

$ cd fastText
$ make
Build FastText - FastText Tutorial - www.tutorialkart.com
Build FastText

Verify the build

To verify if the build is successful and working, run the following command.

$ ./fasttext

“./fasttext” should output the following usage description

root@arjun-VPCEH26EN:/home/arjun/workspace/fasttext/fastText# ./fasttext
usage: fasttext <command></command> 

The commands supported by fasttext are:

  supervised              train a supervised classifier
  quantize                quantize a model to reduce the memory usage
  test                    evaluate a supervised classifier
  predict                 predict most likely labels
  predict-prob            predict most likely labels with probabilities
  skipgram                train a skipgram model
  cbow                    train a cbow model
  print-word-vectors      print word vectors given a trained model
  print-sentence-vectors  print sentence vectors given a trained model
  nn                      query for nearest neighbors
  analogies               query for analogies

root@arjun-VPCEH26EN:/home/arjun/workspace/fasttext/fastText#

We have successfully built FastText.

Conclusion

In this FastText Tutorial, we have learnt to build fastText from github. In our next tutorial, we shall Train and Test Supervised Text Classifier.