Home › Glossary › NLP › Bag of words

Beginner · NLP

Bag of words

Visual diagram · (in preparation) · Math · (in preparation) · Worked example · 3 difficulty levels.

TL;DR. A text representation that ignores grammar and word order, focusing only on word frequency within a document.

Technical Definition

A text representation that ignores grammar and word order, focusing only on word frequency within a document.

How it works

The bag-of-words (BoW) model is a common way to represent text data for machine learning. It describes the occurrence of words within a document, disregarding grammar and context, and treating each word as an independent feature. Typically, it involves creating a vocabulary of all unique words and then representing each document as a vector indicating the count or presence of each word.

Related Concepts

  • Feature Extraction — Deriving informative numerical signals from raw data for use as model inputs.
  • Natural language processing (NLP) — A field of AI enabling computers to understand, interpret, and generate human language.

Further Reading

  • Google ML Glossary