liveBook · Manning

FastText

As explained in Natural Language Processing in Action, Second Edition

fastText is a word-representation model that learns from character n-grams and composes representations for words from their subwords.

FastText represents words through character n-grams, or subwords, instead of relying only on complete words. This lets it build useful vectors for rare, misspelled, partial, and previously unseen words. section 6.4.2

Like Word2Vec and GloVe, fastText learns from raw, domain-specific text without labeled examples. A medical corpus can produce embeddings suited to medical users, while Wikipedia or news provides broader coverage. section 6.3.2

Its subword strategy provides three practical advantages:

  • Represents fragments such as the 2- and 3-character grams extracted from “whisper.” section 6.4.2
  • Combines familiar subwords to represent a rare word such as “Superwoman,” reducing generic out-of-vocabulary vectors. section 6.4.2
  • Provides pretrained models for 294 languages, although vocabulary and accuracy vary with the available Wikipedia data. section 6.4.2

Inspecting pretrained vectors

A Python workflow can load pretrained fastText vectors, inspect the embedding table, and retrieve the 300-dimensional vector for “prosocial” with `load_fasttext()` and `df.loc['prosocial']`.

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Explains subword composition and OOV behavior, but stops short of detailing the complete training objective or implementation.
Examples
Uses “whisper” n-grams, “Superwoman” composition, pretrained multilingual models, and Python vector inspection.
What it assumes
Assumes familiarity with word vectors and basic language-model training while grounding the method in raw text and simple examples.
What you can do after
Apply it via pretrained vectors or domain text to represent rare and unseen words more flexibly than whole-word embeddings.
How it connects
Connects word embeddings with Word2Vec, GloVe, unsupervised learning, tokenization, and out-of-vocabulary handling.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.