liveBook · Manning

Continuous Bag of Words

As explained in Natural Language Processing in Action, Second Edition

Continuous bag-of-words is a word-embedding training approach that predicts a target word from nearby context words in a sliding window.

Continuous bag-of-words (CBOW) trains word embeddings by predicting a target word from nearby context words. Unlike document-level bag-of-words, it uses a continuously sliding window, producing many small training examples from each document. section 6.3.2

A CBOW training set is built by:

  • Taking raw domain text as the corpus. section 6.3.2
  • Moving a window through each document to form many tiny synthetic documents. section 6.3.2
  • Using nearby words as inputs and the central target word as output. section 6.3.2

Choosing a corpus

A medical application can learn from medical journals, while a general-purpose embedding can use Wikipedia or online news. Each corpus shapes the word representations available to the model. section 6.3.2

Figure 6.4 CBOW neural network architecture
figure

Inspect the CBOW neural-network architecture alongside the sliding-window prediction process. section 6.3.2

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Explains the prediction task and sliding-window dataset construction, but does not detail optimization or implementation code.
Examples
Uses medical journals, Wikipedia, online news, and sliding-window synthetic documents as training examples.
What it assumes
Assumes familiarity with documents and words while distinguishing document-level bag-of-words from sliding-window CBOW vectors.
What you can do after
Build it from scratch by turning a corpus into sliding-window context-target examples for embedding training.
How it connects
Connects word embeddings with bag-of-words and contrasts CBOW with skip-gram.

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.