liveBook · Manning

Out-of-distribution

As explained in Natural Language Processing in Action, Second Edition

An out-of-distribution example is an input whose relevant data-generating conditions differ from those represented in a model's training distribution.

An out-of-distribution example has relevant conditions absent from the training or test data. A name such as Carlana or Cason is unusual because the model has not encountered it in the database. Generalization means extrapolating successfully to such examples. section 5.2.4

Unseen names

A model that predicts likely sex from known names can memorize the most common label for each name, but that strategy cannot handle original names. Character n-grams provide reusable pieces that can represent unfamiliar names. section 5.2.4

A practical approach to handling unfamiliar inputs:

  • Tokenize each name into character n-grams rather than whole-word tokens. section 5.2.4

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Defines the distribution shift, demonstrates its consequence, and stops short of formal distributional analysis.
Examples
Uses original names such as Carlana and Cason, plus character-feature vectors produced by TfidfVectorizer.
What it assumes
Assumes basic supervised learning and text representation, while defining out-of-distribution examples and generalization directly.
What you can do after
Build character n-gram features that let a model represent names absent from its training examples.
How it connects
Connects out-of-distribution inputs with generalization, character n-grams, tokenization, TF-IDF, and logistic regression.

Also explained in

Compare how 2 books explain out-of-distribution →

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.