Understanding NLP: How Machines Learn to Read

The Big Picture Before the Code
You've already taught machines to see patterns in numbers. Now comes the harder challenge: teaching them to understand language. Before we write a single line of code, we need to answer a deeper question: how does a machine even begin to process something as messy, ambiguous, and human as text?
This page is your map. We won't build models yet. Instead, we'll walk through the entire landscape of NLP; what it is, why it's hard, how the pipeline works, and what the difference is between an encoding and an embedding. By the end, you'll have the mental model that makes every technique on the next page feel logical rather than arbitrary.
1. What is Natural Language Processing?
Natural Language Processing (NLP) is the field of AI that teaches computers to read, understand, and generate human language.
That sounds simple. It isn't.
Human language is built on a foundation of ambiguity, context, culture, and history. Consider a single sentence:
"I saw the man with the telescope."
Did you use a telescope to see the man? Or did the man have a telescope? A human reader would use context clues to decide. A machine, given only these words, has no idea.
This is the central challenge of NLP: language doesn't have a clean, mathematical structure. The same word can mean different things. The same meaning can be expressed in a thousand different ways. And sarcasm, metaphors, and idioms break every rule a machine might try to learn.
What NLP Powers Today
Despite this challenge, NLP is everywhere:
- Search Engines — understanding what you mean, not just what you typed
- Translation — converting meaning across languages, not just words
- Chatbots & Virtual Assistants — following multi-turn conversations with memory
- Sentiment Analysis — detecting whether a review is positive, negative, or mixed
- Document Summarization — compressing a 50-page report into three sentences
The Professional Logic: NLP is not about teaching machines grammar. It is about teaching machines to find patterns in language the same way we taught them to find patterns in numbers.

2. The NLP Pipeline: Beyond Raw Text to Useful Output
Every NLP system, regardless of how complex, follows the same fundamental journey. Think of it as an assembly line where raw, messy human language enters on one end and clean, structured, machine-readable data exits on the other.

Each stage has a specific job. Skipping or rushing a stage produces a broken product downstream.
Stage 1: Tokenization — Breaking Language into Pieces
Before a model can process text, it needs to know what the units of that text are. Tokenization is the process of splitting a string of text into smaller chunks called tokens.
Tokens can be:
- Words:
"The cat sat"→["The", "cat", "sat"] - Subwords:
"unhappiness"→["un", "happiness"] - Characters:
"cat"→["c", "a", "t"]
The choice of tokenization strategy has a massive impact on model performance. Modern systems like BERT and GPT use subword tokenization, which elegantly handles rare words and typos by breaking them into recognizable pieces.
Stage 2: Normalization — Cleaning the Signal
Raw text is full of noise: capital letters, punctuation, spelling variations, and filler words. Normalization is the process of reducing this noise so the model focuses on signal, not clutter.
Common normalization steps include:
- Lowercasing:
"Apple"→"apple" - Removing punctuation:
"Hello!"→"Hello" - Stop word removal: Dropping words like
"the","is","a"that carry little meaning - Stemming / Lemmatization: Reducing
"running","ran", and"runs"to their root form"run"
A note of caution: Removing stop words or punctuation is not always appropriate. In sentiment analysis,
"not good"is very different from"good". Blindly removing"not"destroys the meaning. Always normalize with intent, not habit.
Stage 3: Encoding — Turning Words into Numbers
This is the stage where language crosses the bridge into mathematics. A computer cannot process the word "cat". It can process the number 27 or the vector [0.2, 0.8, 0.1]. Encoding is the process of mapping words to numerical representations.
This is where the real story begins — and we'll explore it in depth in the next two sections.
Stage 4: The Model — Learning the Pattern
With text now in numerical form, a neural network processes it. Depending on the task, this might be an RNN, an LSTM, a Transformer, or a simpler statistical model.
Stage 5: Output — Answering the Question
The model produces a result that maps back to human language or a human decision: a translated sentence, a sentiment label, a generated reply, or a highlighted answer.
3. The Core Problem: Computers Don't Read
Let's pause and confront the most fundamental challenge in NLP.
Computers only understand numbers. They have no concept of language. They cannot "read" the word "Paris" and know it is a city, or that it is romantic, or that it is the capital of France. All of that is human knowledge encoded in human experience.
So we face a design question with massive consequences:
How do we convert the word "Paris" into a number (or a sequence of numbers) in a way that preserves its meaning?
The naive answer is to just assign every word a unique number. "apple" = 1, "banana" = 2, "Paris" = 3. This is called a label encoding.
The problem? The number 3 implies that Paris is "greater than" banana, and "three times" apple. That makes no mathematical sense. We've introduced false relationships that will confuse the model.
The smarter answer is to use a one-hot vector — a long list of zeros with a single 1 in the position assigned to that word. "Paris" becomes [0, 0, 1, 0, 0, ...]. Now there are no false rankings. But there's a new problem: every word is equally distant from every other word. "Paris" and "London" are just as "different" to the model as "Paris" and "banana".
Neither approach captures meaning. This is the core problem that the entire field of word embeddings was built to solve.

4. Encodings vs. Embeddings: The Crucial Distinction
This is the most important conceptual divide in all of NLP. Get this right and everything else becomes clear.
Encodings: The Mechanical Lookup Table
An encoding is a fixed, rule-based mapping from a word to a number. It does not learn anything. It does not understand anything. It is simply a lookup table built by a human before training begins.
Think of it like a phone book: every name has a number, but knowing someone's phone number tells you nothing about who they are or how they relate to other people.
Examples of encodings:
- Label Encoding:
"cat"→3 - One-Hot Encoding:
"cat"→[0, 0, 0, 1, 0, 0, ...] - ASCII / Unicode:
"A"→65
The key property: Two similar words get completely unrelated numbers. The encoding has no awareness of meaning.
Embeddings: The Learned Map of Meaning
An embedding is a learned, dense vector that places words in a multi-dimensional space based on how they are used in language. Words that appear in similar contexts end up close together in this space.
Think of it like a city map: similar neighborhoods are geographically close to each other. A model that knows where "hospital" is on the map can reasonably guess that "clinic" and "pharmacy" are nearby, even without being told directly.
| Property | Encoding | Embedding |
|---|---|---|
| How it's made | Human-defined rules | Learned from data |
| Captures meaning? | No | Yes |
| Vector size | Often large and sparse | Small and dense |
| Similar words close? | No | Yes |
| Example | One-hot | Word2Vec, GloVe |
The Professional Logic: Encodings answer "What number is this word?" Embeddings answer "What does this word mean, relative to all other words?" This is the difference between a phone book and a map.

5. The Semantic Gap: Teaching Machines That Words Have Relationships
Once we have embeddings, words placed on a mathematical map, something extraordinary becomes possible. We can do arithmetic with meaning.
The most famous example in all of NLP:
This is not a coincidence or a party trick. It is evidence that the embedding space has learned to encode relationships, not just identities. The relationship between "king" and "man" (royalty + masculinity) is the same geometric direction as the relationship between "queen" and "woman".
This is called semantic structure, and it emerges naturally when a model is trained on enough text.
The Geometry of Meaning
In a well-trained embedding space:
- Similar words are close together:
"dog"and"puppy"are neighbors - Analogies form parallelograms:
"Paris : France :: Berlin : Germany"forms a perfect geometric pattern - Categories cluster: all country names, all colors, all verbs of movement appear in distinct regions of the space
The Gap We're Bridging
The semantic gap is the distance between how humans understand language (through experience, context, and culture) and how machines process it (through pure mathematics). Embeddings are our best tool for closing that gap.
They are not perfect. An embedding trained on news articles will not understand medical slang. An embedding trained in 2010 won't know what "tweet" means as a verb. Embeddings inherit the biases and blind spots of the text they were trained on. But they are a revolutionary step beyond encodings.
The Professional Logic: The goal of every representation technique in NLP — from Bag of Words to ELMo — is to close the semantic gap a little more. Each technique you'll learn on the next page is an answer to the limitations of the one before it.
6. The Big Picture: A Map of NLP Representations
Before diving into the individual techniques, it helps to see them on a single spectrum — from the simplest and most naive to the richest and most powerful.
Simpler ◄──────────────────────────────────────────────► More Powerful
Bag TF-IDF N-grams Word2Vec GloVe fastText ELMo
of Words (CBOW / (Co- (Subword) (Context-
Skip-gram) occurrence) aware)
Each step in this spectrum solves a problem introduced by the previous one:
- Bag of Words ignores word order entirely — TF-IDF fixes the importance problem
- TF-IDF still ignores order — N-grams fix the sequence problem
- N-grams still use sparse vectors — Word2Vec fixes the density and meaning problem
- Word2Vec gives every word one fixed meaning — ELMo fixes the context problem (the word
"bank"means different things in different sentences)
This is the story arc of the next page. Each technique is not just a new tool — it is an answer to a specific limitation.
Professional Takeaway: You don't always need the most powerful technique. A TF-IDF model with a simple classifier will outperform a poorly-tuned neural embedding on a small dataset. Understand your data, your constraints, and your baseline before reaching for the most complex tool.
Glossary
1. Language & Linguistics
- Token: The basic unit of text a model processes — could be a word, subword, or character.
- Tokenization: Splitting raw text into tokens.
- Normalization: Cleaning and standardizing text (lowercasing, stemming, stop word removal).
- Stop Words: Common words like
"the","is", and"a"that often carry little semantic meaning. - Stemming: Reducing a word to its base root, even if the result isn't a real word (
"running"→"run"). - Lemmatization: Reducing a word to its dictionary form (
"better"→"good").
2. Representations
- Encoding: A fixed, rule-based mapping from a word to a number. Carries no learned meaning.
- One-Hot Encoding: A vector of all zeros except a single
1at the word's index position. - Embedding: A dense, learned vector that places words in a space where similar words are geometrically close.
- Sparse Vector: A vector that is mostly zeros. One-hot vectors are sparse.
- Dense Vector: A vector where most values are non-zero real numbers. Embeddings are dense.
3. Semantic Concepts
- Semantic Gap: The distance between human understanding of language and a machine's mathematical representation of it.
- Semantic Similarity: A measure of how related two words or phrases are in meaning.
- Semantic Structure: The property of an embedding space where word relationships are encoded as geometric directions (e.g., gender, royalty, location).
- Distributional Hypothesis: The linguistic theory underlying all embeddings — "a word is known by the company it keeps." Words that appear in the same contexts tend to have similar meanings.
4. Pipeline
- NLP Pipeline: The end-to-end sequence of steps from raw text to model output.
- Feature Extraction: The process of converting raw input into numerical features a model can learn from.
- Vocabulary: The complete set of unique tokens a model knows about.
- Out-of-Vocabulary (OOV): A word the model has never seen before and has no representation for — a key weakness of simple embedding approaches.
What's Next: Now that you have the map, it's time to explore the territory. On the next page, we'll break down every representation technique on that spectrum — from the simplicity of Bag of Words to the context-awareness of ELMo — and understand exactly when and why to use each one.