Book Image

fastText Quick Start Guide

By : Joydeep Bhattacharjee
Book Image

fastText Quick Start Guide

By: Joydeep Bhattacharjee

Overview of this book

Facebook's fastText library handles text representation and classification, used for Natural Language Processing (NLP). Most organizations have to deal with enormous amounts of text data on a daily basis, and gaining efficient data insights requires powerful NLP tools such as fastText.  This book is your ideal introduction to fastText. You will learn how to create fastText models from the command line, without the need for complicated code. You will explore the algorithms that fastText is built on and how to use them for word representation and text classification.  Next, you will use fastText in conjunction with other popular libraries and frameworks such as Keras, TensorFlow, and PyTorch.  Finally, you will deploy fastText models to mobile devices. By the end of this book, you will have all the required knowledge to use fastText in your own applications at work or in projects.
Table of Contents (14 chapters)
Free Chapter
1
First Steps
4
The FastText Model
7
Using FastText in Your Own Models

Python 2 and Python 3

fastText works for both Python 2 and Python 3. There are few differences though that you should keep in mind for the particular python version.

  1. print is a statement in Python 2 and a function in Python 3. This would mean that if you are in a Jupyter notebook and trying to see the changes in a variable you will need to pass the appropriate print statement in the corresponding python version.
  2. The fastText handles text as Unicode. Python 3 also handles text as Unicode and hence there is no additional overhead if you code in Python 3. But in case you are developing your models in Python 2, you cannot have your data as a string instance. You will need to have your data as Unicode. Following is an example of text as an instance of the str class and unicode class in Python 2.
>>> text1 = "some text" # this will not work for fastText
>>...