Giving Words Meaning: From Counting to Meaning Maps to Language Models
TL;DR: You will be able to explain bag-of-words and TF-IDF, embeddings as meaning maps, and language models as next-word predictors, with the book’s own examples.
This article is one Wisdom Nugget from What Is Natural Language Processing? by Trevor Stephenson.
So far we have cleaned text and broken it into tokens. We have words like ‘book’, ‘restaurant’, ‘love’, ‘tonight’ neatly sliced and normalised. But to a computer, these are still just labels. How does a machine know that ‘restaurant’ and ‘cafe’ are similar, while ‘restaurant’ and ‘rocket’ are not? How does it know that ‘love’ and ‘adore’ share positivity, while ‘love’ and ‘hate’ are opposites? This is the problem of representation: How do we turn tokens into a form that captures meaning in a way machines can use?
By the end of this Nugget you will be able to explain bag-of-words and TF-IDF and their three limits, explain embeddings with the meaning map and the king minus man plus woman equals queen example, and explain language models as next-word predictors that learn grammar, facts, and reasoning as a byproduct of prediction.
The core idea
The shift from counting to learning representations based on context is the foundation of embeddings. It moved NLP from ‘words are labels to count’ to ‘words are meanings to map’. Embeddings turned words from discrete labels into continuous meanings. That shift from counting to mapping is what allows modern NLP to handle similarity, analogy, and nuance far better than earlier methods. The journey from counting words to embeddings to language models reflects a progression in how we represent meaning. Counting asked ‘What words appear?’ Embeddings asked ‘What company do words keep?’ Language models ask ‘What word comes next given everything so far?’ Each question builds on the previous and captures more context, more nuance, and more of what makes human language so rich.
How it works
Section 1 (Figure 6.1) covers bag-of-words and TF-IDF, sparsity, loss of order, and inability to capture synonyms, plus the Firth quote. Section 2 (Figure 6.2) covers word embeddings and meaning maps: dense vectors a few hundred numbers long, Word2Vec 2013, GloVe, static versus contextual embeddings, king minus man plus woman equals queen, Paris minus France plus Italy near Rome, and the practical benefits: solving the synonym problem (a search for ‘cafe’ finds ‘coffee shop’ or ‘bistro’), enabling generalisation (a sentiment system trained on ‘I love this’ understands ‘I adore this’ as positive), and making learning more efficient (knowledge about ‘restaurant’ partly transfers to ‘cafe’).
The tools
Tool 1: Start with counting. Bag-of-words represents a document by counting which words appear in it. Imagine you have a bag, you throw all the words of a document into it, shake it up, and count. TF-IDF stands for Term Frequency-Inverse Document Frequency: a word is important to a document if it appears often in that document (term frequency) but rarely in other documents (inverse document frequency). Counting worked surprisingly well for search and topic classification. But counting has three clear limits. First, it treats words as atomic and unrelated: in bag-of-words, ‘car’ and ‘automobile’ are as different as ‘car’ and ‘banana’. Second, it suffers from sparsity: a vocabulary of 50,000 words means each document is a vector with 50,000 numbers, most of them zero. Third, it ignores context and order: ‘Not good’ and ‘good’ look similar if you ignore ‘not’, and ‘I love this’ and ‘I hate this’ differ by only one word, but that word flips the meaning entirely.
Tool 2: Use the meaning map. Instead of representing a word by counting where it appears, represent it by learning from the company it keeps. The idea comes from linguist J.R.
Step by step
The end-of-chapter exercise as a numbered protocol, in order.
- Bag-of-words vs embeddings: show why car and automobile are as different as car and banana in bag-of-words but neighbours in embeddings, using the company they keep idea.
- TF-IDF intuition: in a baking article corpus, why does sourdough get high weight and the get low weight?
- Explain the embedding analogy king minus man plus woman approximately equals queen without maths, using contextual patterns.
- Language model next-word prediction: for The capital of France is ___, I went to the shop to buy some ___, If it rains tomorrow we will ___, list likely words and what knowledge is needed to predict.
- Identify hallucination risk: why might a model invent an affordable space rocket that does not exist in inventory? No time is stated in the book for this exercise.
Worked example
The book’s worked example is the blank test. ‘I went to the shop to buy some ___’ favours milk, bread, and eggs over aeroplane, because you draw on your experience of how people talk about going to shops. A language model learns the same ability from data at a scale no human could match. And the embedding example: ‘king’ minus ‘man’ plus ‘woman’ gives a vector close to ‘queen’, not by magic but because ‘king is to man as queen is to woman’ is a pattern that appears in many contexts.
A real example from the book
Case Study – Chapter 6: ThreadzSearch: From Counting to Meaning Maps. No person age is given. Spectrum Threadz online shop search used bag-of-words: query cheap places to eat returned zero results because product descriptions said affordable restaurants. It also treated car and automobile as unrelated. The team applies Chapter 6 concepts. They move from counting to embeddings. They train Word2Vec on 2 million product descriptions and customer reviews, learning that affordable, cheap, budget-friendly appear in similar contexts, so their vectors become neighbours. Search for cafe now finds coffee shop and bistro because embeddings are close. They implement TF-IDF weighting to highlight distinctive terms like sourdough over the. For the language model, they deploy a neural model predicting the next word to power autocomplete: type oversized hood… suggests hoodie, not aeroplane, because the language model learned likely continuations.
Mistakes to avoid
- Treating ‘car’ and ‘automobile’ as unrelated. Correction: in embeddings they are neighbours because they keep similar company.
- Ignoring sparsity. Correction: a 50,000-word vocabulary makes most document vectors mostly zero, which is inefficient.
- Ignoring word order and ‘not’. Correction: ‘I love this’ and ‘I hate this’ differ by one word that flips meaning.
- Thinking embeddings are a dictionary with definitions. Correction: they are a map built from usage, not definitions.
- Thinking a language model looks up answers in a database. Correction: it predicts likely continuations based on patterns in data.
- Trusting fluent generation without grounding. Correction: ground generation in real data, as ThreadzSearch did with its inventory database, or the model invents products that do not exist.
What not to do
- Do NOT treat synonyms as unrelated just because they are different words.
- Do NOT ignore word order and negation when counting.
- Do NOT mistake an embedding map for a dictionary of definitions.
- Do NOT assume a language model looks up answers or understands like a human.
- Do NOT trust generated text without grounding it in real data.
- Do NOT use a single static vector when context changes the meaning.
Low-energy mode
Name two words that are close in meaning and one that is far away, and say why from the company they keep. That counts.
If you freelance
This is one way to apply the idea, not a passage from the book. A freelancer can use the synonym point on their own shop or site search: if a search for ‘cafe’ misses ‘coffee shop’, the fix is meaning-based matching, not adding more keywords, and generated text must be grounded in real inventory.
How to know it worked
You showed why car and automobile are as different as car and banana in bag-of-words but neighbours in embeddings. You explained why sourdough gets high TF-IDF weight and the gets low weight in a baking corpus. You explained king minus man plus woman approximately equals queen without maths. You listed likely next words for three prompts and the knowledge needed. You named the hallucination risk with the affordable space rocket.
Key takeaways
- You shall know a word by the company it keeps.
- It is not a dictionary with definitions. It is a map built from usage.
- Counting asked ‘What words appear?’ Embeddings asked ‘What company do words keep?’ Language models ask ‘What word comes next given everything so far?’
- They are predicting likely continuations based on patterns in data.
Try it today
Do Exercise – Chapter 6: Representations and Language Models today (no time stated in the book, see Exercise).
End of Chapter Exercise – Chapter 6: Representations and Language Models. No time stated in the book.
- Bag-of-words vs embeddings: show why car and automobile are as different as car and banana in bag-of-words but neighbours in embeddings, using the company they keep idea.
- TF-IDF intuition: in a baking article corpus, why does sourdough get high weight and the get low weight?
- Explain the embedding analogy king minus man plus woman approximately equals queen without maths, using contextual patterns.
- Language model next-word prediction: for The capital of France is ___, I went to the shop to buy some ___, If it rains tomorrow we will ___, list likely words and what knowledge is needed to predict.
- Identify hallucination risk: why might a model invent an affordable space rocket that does not exist in inventory?
Frequently asked questions
Why does trying harder not work here?
Trying harder to count more words fails here, because the chapter’s own point is that counting treats ‘car’ and ‘automobile’ as unrelated and ignores order, so ‘not good’ and ‘good’ look similar. The fix is not bigger counts, it is a different representation: learn from the company words keep, so similar meanings sit near each other on the map.
How do I know it worked?
You showed why car and automobile are as different as car and banana in bag-of-words but neighbours in embeddings. You explained why sourdough gets high TF-IDF weight and the gets low weight in a baking corpus. You explained king minus man plus woman approximately equals queen without maths. You listed likely next words for three prompts and the knowledge needed.
What if it does not work?
If search returns zero results for a query with synonyms, then check whether the system counts words only instead of using embeddings. If a model invents a product, then ground generation in the actual inventory database. If ‘bank’ is misread, then check whether the system uses contextual embeddings or a single static vector.
Get the book
Google Play eBookGoogle Play AudiobookBarnes & Noble
More from What Is Natural Language Processing?
- What Is Natural Language Processing?: A Beginner’s Guide to How Machines Understand Language
- Where to Go Next: Your NLP Future (and From Words to World)
- Ethics, Bias, and Limitations: Using NLP Responsibly
- Opinions, Summaries, and Voice: NLP in Action
- Search, Translation, and Chatbots: How NLP Powers the Web
- The Invisible NLP All Around You: Keyboards, Inboxes, and Voice
- Intent, Entities, and Context: How Machines Follow a Conversation
- Making Text Machine-Readable: Cleaning, Tokenisation, and the Corpus
- The End-to-End Pipeline: Your Map for the Rest of the Book
- From Rules to Statistics to Neural Networks: How NLP Got Here
- Why Language Is Hard: Ambiguity, Three Layers, and the Outside-In Machine
- What NLP Really Is: The One-Sentence Definition and the Family Picture
- Why This Book, Why Now: A Framework You Can Use for Years
- Natural Language Processing Glossary: Key Terms and Concepts in Plain Language
- How to Use What Is Natural Language Processing? for Study Groups, Classrooms, and Teams
- After You Finish the Book: How to Build Projects, Keep a Journal, and Stay Current
- How the NLP Pipeline and Meaning Maps Work, in Plain Language?
- How Natural Language Processing Works in Everyday Life and Work: 5 Scenarios
- Common Misunderstandings About Natural Language Processing and How to Fix Them
- 7 Free Tools If You Loved This NLP Book
- How This NLP Book Was Built: Concept First Method
- NLP Beginner Book FAQ: Formats, Scope, Safety, Work, Answered
- Who Should Read This NLP Beginner Book? Reader Guide
- NLP Book vs Textbook vs Article vs Coding Course vs Doing Nothing
- Read Chapter 1 Free: What Is Natural Language Processing Really?
- How to Run a One Day Autocorrect Detective Check
- What Is the NLP Pipeline? Input Processing Understanding Generation Explained
- Best Natural Language Processing Books in 2026: A Beginner First Pick
