Natural Language Processing

Part 1A - Introduction to NLP

Artificial Intelligence Machine Learning Deep Learning NLP
Chapter 1

What is NLP?

Natural Language Processing (NLP) is a branch of Artificial Intelligence that enables computers to understand, analyze, interpret and generate human language.

NLP acts as a bridge between Human Language and Computer Language.

Why NLP is Important?

  • Chatbots
  • Voice Assistants
  • Translation Systems
  • Spam Detection
  • Search Engines
  • Sentiment Analysis

NLP Pipeline Visualization

Raw Text
Cleaning
Tokenization
Stopword Removal
Vectorization
ML / DL

AI vs ML vs DL vs NLP

Making machines intelligent. Examples:
  • Robots
  • Self Driving Cars
  • Chess AI

Learning patterns from data.

Neural Network based learning.

Processing and understanding human language.

Applications of NLP

Chatbots
Translation
Search Engines
VECTORIZATION FUNDAMENTALS

Introduction to Text Vectorization

Converting Human Language into Machine Understandable Numbers

Key Idea
Humans understand words and sentences. Computers understand only numbers. Therefore, before applying Machine Learning or Deep Learning, text must be converted into numerical vectors.

Why Do We Need Text Vectorization?

Machine Learning algorithms perform mathematical calculations. They cannot directly process words, sentences, or paragraphs.

Human Understanding
I Love Natural Language Processing
  • Understands Meaning
  • Understands Context
  • Understands Emotion
  • Understands Relationships
Computer Understanding
[0.25, 0.18, 0.79]
  • Understands Numbers
  • Performs Calculations
  • Needs Numerical Input
  • Cannot Read Text Directly
Human Language → Vectorization → Numerical Vectors → Machine Learning

What is Vocabulary?

Vocabulary is the collection of all unique words present in a dataset.

Sentence 1: I Love NLP Sentence 2: NLP is Amazing Sentence 3: AI and NLP are Related
Step 1 : Collect All Words
I, Love, NLP, NLP, is, Amazing, AI, and, NLP, are, Related
Step 2 : Remove Duplicates
[I, Love, NLP, is, Amazing, AI, and, are, Related]

This final collection is called the Vocabulary.

What is Vocabulary Size?

Vocabulary Size is the total number of unique words in a dataset.

Vocabulary Size = Total Unique Words
Vocabulary: [I, Love, NLP, is, Amazing, AI, and, are, Related]
Vocabulary Size = 9

Real World Vocabulary Example

1 Million

Documents

50 Million

Words

250,000

Unique Words

Large Vocabulary Size increases memory consumption and computational cost.

Types of Text Vectorization

Text Vectorization

Traditional Vectorization
  • One Hot Encoding
  • Bag of Words (BoW)
  • Count Vectorizer
  • N-Grams
  • TF-IDF
Semantic Vectorization
  • Word2Vec
  • CBOW
  • Skip-Gram
  • GloVe
  • FastText
  • Embeddings

Traditional vs Semantic Vectorization

Feature Traditional Semantic
Stores Frequency
Understands Meaning
Captures Context
Memory Efficient
Used In Machine Learning Deep Learning

Text Vectorization Roadmap

Text
Vocabulary
Vocabulary Size
One Hot Encoding
Bag of Words
Count Vectorizer
N-Grams
TF-IDF
Word Embeddings

How Does Text Vectorization Work?

Vectorization is the process of converting words into numerical values. The machine cannot directly understand:

I Love NLP

Therefore NLP systems perform a series of steps to convert text into numbers.

Step 1 : Collect Text

The first step is collecting all text documents from the dataset.

Document 1: I Love NLP Document 2: NLP is Amazing Document 3: AI Loves NLP

Step 2 : Create Vocabulary

All unique words are collected. Duplicate words are removed.

Vocabulary [I, Love, NLP, is, Amazing, AI, Loves]

Each word receives a unique position.

Word Index
I 0
Love 1
NLP 2
is 3
Amazing 4
AI 5
Loves 6

Step 3 : Convert Words into Numerical Representation

Once every word receives an index, the NLP algorithm can create vectors.

Word
Index
Vector

Step 4 : Generate Feature Matrix

The final output of vectorization is called a Feature Matrix. Each row represents a document. Each column represents a vocabulary word.

Vocabulary [I, Love, NLP, is, Amazing]
Document I Love NLP is Amazing
Doc1 1 1 1 0 0
Doc2 0 0 1 1 1

Why is Feature Matrix Important?

Machine Learning algorithms cannot learn directly from text. They learn from numerical features.

Text
Vectorization
Feature Matrix
Machine Learning Model
Prediction

Vectorization Hierarchy

Traditional Vectorization focuses on frequency. Modern Vectorization focuses on meaning and context.
Text Vectorization │ ├── Traditional Methods │ ├── One Hot Encoding │ ├── Bag of Words │ ├── Count Vectorizer │ ├── N-Grams │ └── TF-IDF │ └── Semantic Methods ├── Word2Vec ├── GloVe ├── FastText └── Embeddings

Next Step

Now that we understand:

  • Vocabulary
  • Vocabulary Size
  • Feature Matrix
  • Vectorization Workflow

Let's start with the simplest vectorization technique:

One Hot Encoding

PART 1D

One Hot Encoding

The Simplest Text Vectorization Technique

What is One Hot Encoding?

One Hot Encoding is a vectorization technique where each word is represented by a binary vector. Only one position contains 1. All other positions contain 0.

Every word gets its own unique position.

Why One Hot Encoding?

Machines cannot understand words. Therefore we assign a unique vector to every word.

NLP
[0,0,1]

Step 1 : Create Vocabulary

Sentence: I Love NLP
Vocabulary [I, Love, NLP]

Step 2 : Assign Positions

Word Position
I 0
Love 1
NLP 2

Step 3 : Generate Binary Vectors

Word Vector
I [1,0,0]
Love [0,1,0]
NLP [0,0,1]

Visualization

I
[1,0,0]

Love
[0,1,0]

NLP
[0,0,1]

Large Example

Vocabulary [I, Love, NLP, AI, Machine, Learning]
Word Vector
I [1,0,0,0,0,0]
Love [0,1,0,0,0,0]
NLP [0,0,1,0,0,0]
AI [0,0,0,1,0,0]

Advantages

  • Simple to Understand
  • Easy to Implement
  • Works Well for Small Vocabulary
  • Good for Learning Fundamentals

Limitations

  • Huge Memory Usage
  • Sparse Matrix Problem
  • No Semantic Meaning
  • Cannot Understand Context
  • Cannot Understand Similar Words
One Hot Encoding treats King and Queen as completely unrelated words.

Sparse Matrix Problem

Imagine a vocabulary of 10000 words.

[0,0,0,0,0,0,0,0,0,1,0,0,0...]

Most values are zero. This wastes memory.

Quick Quiz

  1. What is One Hot Encoding?
  2. Why do we use it?
  3. What is a binary vector?
  4. What is a sparse matrix?
  5. What are its limitations?

Interview Questions

  1. Explain One Hot Encoding.
  2. How does One Hot Encoding work?
  3. What is the Sparse Matrix Problem?
  4. Why is One Hot Encoding inefficient?
  5. Difference between One Hot Encoding and Bag of Words?
PART 1E

Bag of Words (BoW)

Counting Words Instead of Just Identifying Them

What is Bag of Words?

Bag of Words (BoW) is one of the most popular text vectorization techniques. Instead of representing a word as a unique binary vector like One Hot Encoding, BoW counts how many times each word appears in a document.

BoW focuses on frequency of words. It ignores grammar and word order.

Why Do We Need Bag of Words?

One Hot Encoding only tells whether a word exists. It does not tell how important that word is.

One Hot Encoding
NLP ↓ [0,0,1]
Bag of Words
NLP NLP NLP AI ↓ [3,1]
BoW captures frequency information.

Step 1 : Create Vocabulary

Document: I Love NLP NLP
Vocabulary [I, Love, NLP]

Step 2 : Count Word Occurrences

Word Frequency
I 1
Love 1
NLP 2

Step 3 : Create Vector

The count of each vocabulary word becomes the vector.

Vocabulary [I, Love, NLP] Vector [1,1,2]

BoW Visualization

I Love NLP NLP
Vocabulary
Count Words
[1,1,2]

BoW for Multiple Documents

Document 1: I Love NLP Document 2: NLP is Amazing Document 3: AI Loves NLP
Vocabulary
[I, Love, NLP, is, Amazing, AI, Loves]

Document-Term Matrix

Each row represents a document. Each column represents a vocabulary word.

Document I Love NLP is Amazing AI Loves
Doc1 1 1 1 0 0 0 0
Doc2 0 0 1 1 1 0 0
Doc3 0 0 1 0 0 1 1

Real World Example

Movie Review: This movie is amazing. Amazing acting. Amazing story.
Word Count
Amazing 3
Movie 1
Story 1
Acting 1
The word "Amazing" appears more frequently, indicating strong positive sentiment.

Major Limitation of BoW

Bag of Words ignores word order.

Sentence 1 I Love NLP
Sentence 2 NLP Love I
Both Generate [1,1,1]
BoW cannot understand sequence or context.

Advantages of Bag of Words

  • Simple to understand
  • Easy to implement
  • Works well with traditional ML algorithms
  • Captures word frequency
  • Fast processing

Disadvantages of Bag of Words

  • Ignores word order
  • Cannot understand meaning
  • Cannot understand synonyms
  • Sparse matrix problem
  • Large vocabulary increases memory usage

One Hot Encoding vs Bag of Words

Feature One Hot Encoding Bag of Words
Stores Frequency
Simple
Captures Importance Partially
Word Order
Context

Python Example

from sklearn.feature_extraction.text import CountVectorizer documents = [ "I love NLP", "NLP is amazing", "AI loves NLP" ] vectorizer = CountVectorizer() X = vectorizer.fit_transform(documents) print(vectorizer.get_feature_names_out()) print(X.toarray())

Quick Quiz

  1. What is Bag of Words?
  2. Why is BoW better than One Hot Encoding?
  3. What is a Document-Term Matrix?
  4. How does BoW represent text?
  5. What is the major limitation of BoW?

Interview Questions

  1. Explain Bag of Words with an example.
  2. How is BoW different from One Hot Encoding?
  3. What is a Document-Term Matrix?
  4. Why does BoW ignore context?
  5. What are the limitations of Bag of Words?
  6. How does CountVectorizer implement BoW?
  7. What is the Sparse Matrix problem?
  8. Can BoW understand semantics?
PART 1F

Count Vectorizer

Automating Bag of Words using Scikit-Learn

What is Count Vectorizer?

Count Vectorizer is a feature extraction technique provided by Scikit-Learn. It automatically converts text documents into a numerical matrix by counting the frequency of words.

Count Vectorizer is essentially an automated implementation of the Bag of Words (BoW) model.

Why Do We Need Count Vectorizer?

Creating a Bag of Words manually becomes difficult when dealing with thousands of documents and vocabulary terms. Count Vectorizer automatically:

  • Creates Vocabulary
  • Assigns Index Values
  • Counts Word Frequencies
  • Generates Feature Matrix
  • Prepares Data for Machine Learning

Count Vectorizer Workflow

Raw Text
Vocabulary Creation
Word Counting
Feature Matrix
Machine Learning

Example Dataset

Document 1: I Love NLP Document 2: NLP is Amazing Document 3: AI Loves NLP

Step 1 : Create Vocabulary

Count Vectorizer scans all documents and collects unique words.

Vocabulary [I, Love, NLP, is, Amazing, AI, Loves]
Word Index
I 0
Love 1
NLP 2
is 3
Amazing 4
AI 5
Loves 6

Step 2 : Create Document-Term Matrix

Count Vectorizer counts occurrences of each word in every document.

Document I Love NLP is Amazing AI Loves
Doc1 1 1 1 0 0 0 0
Doc2 0 0 1 1 1 0 0
Doc3 0 0 1 0 0 1 1

Understanding the Feature Matrix

Each row represents a document. Each column represents a vocabulary word. The values indicate the frequency of occurrence.

Machine Learning algorithms learn patterns from this matrix.

How Count Vectorizer Works Internally

Collect Documents
Tokenize
Build Vocabulary
Count Words
Create Matrix

Important Parameters

Parameter Purpose
max_features Limits vocabulary size
stop_words Removes common words
ngram_range Creates n-grams
lowercase Converts text to lowercase
binary Stores 0/1 instead of counts

Python Example

from sklearn.feature_extraction.text import CountVectorizer documents = [ "I love NLP", "NLP is amazing", "AI loves NLP" ] vectorizer = CountVectorizer() X = vectorizer.fit_transform(documents) print(vectorizer.get_feature_names_out()) print(X.toarray())

Expected Output

Vocabulary ['ai', 'amazing', 'is', 'love', 'loves', 'nlp'] Feature Matrix [[0 0 0 1 0 1] [0 1 1 0 0 1] [1 0 0 0 1 1]]

Advantages of Count Vectorizer

  • Simple to use
  • Automatically builds vocabulary
  • Works well for small and medium datasets
  • Fast implementation
  • Useful for text classification tasks

Limitations of Count Vectorizer

  • Ignores word meaning
  • Cannot understand context
  • Sparse matrix problem
  • Large memory consumption
  • Treats similar words as unrelated
Count Vectorizer knows frequency but does not know semantics. "King" and "Queen" are treated as completely different words.

Bag of Words vs Count Vectorizer

Feature Bag of Words Count Vectorizer
Concept Manual Method Automated Implementation
Vocabulary Creation Manual Automatic
Word Counting Manual Automatic
Feature Matrix Manual Automatic
Scalability Low High

Real World Applications

  • Email Spam Detection
  • News Classification
  • Sentiment Analysis
  • Document Categorization
  • Review Classification

Quick Quiz

  1. What is Count Vectorizer?
  2. How is it related to Bag of Words?
  3. What is a Feature Matrix?
  4. Why do we need Count Vectorizer?
  5. What are its limitations?

Interview Questions

  1. Explain Count Vectorizer.
  2. How does Count Vectorizer work internally?
  3. Difference between BoW and Count Vectorizer?
  4. What is a Document-Term Matrix?
  5. What are important Count Vectorizer parameters?
  6. What is the sparse matrix problem?
  7. Why is Count Vectorizer widely used?
  8. What are the limitations of Count Vectorizer?
PART 1G

N-Grams

Preserving Word Order and Context in Text Vectorization

What are N-Grams?

N-Grams are contiguous sequences of N words extracted from a sentence. Unlike Bag of Words, which treats words independently, N-Grams preserve word order and capture local context.

N = Number of Consecutive Words
N-Gram = Sequence of N Consecutive Words

Why Do We Need N-Grams?

Bag of Words ignores word order. Sometimes word order completely changes the meaning.

Sentence 1 I Love NLP
Sentence 2 NLP Love I

Bag of Words generates the same vector for both sentences. Meaning is lost.
N-Grams preserve word sequence and context.

Types of N-Grams

Unigram
Bigram
Trigram
Four-Gram

1. Unigram (N = 1)

Each individual word is treated as a token.

Sentence: I Love NLP
Generated Unigrams
I Love NLP
Unigrams are identical to Bag of Words tokens.

2. Bigram (N = 2)

Two consecutive words are grouped together.

Sentence: I Love NLP
Generated Bigrams
I Love Love NLP
I Love
Love NLP

3. Trigram (N = 3)

Three consecutive words are grouped together.

Sentence: I Love NLP
Generated Trigram
I Love NLP

Large Example

Sentence: Natural Language Processing is Amazing
Unigrams
Natural Language Processing is Amazing
Bigrams
Natural Language Language Processing Processing is is Amazing
Trigrams
Natural Language Processing Language Processing is Processing is Amazing

N-Gram Generation Visualization

Sentence
Tokenization
Word Sequences
N-Grams

Why N-Grams are Important in Sentiment Analysis?

Consider the sentence:

This movie is not good
Bag of Words View
not good

The model may incorrectly interpret "good" as positive.

Bigram View
not good

The phrase meaning is preserved.

N-Grams help capture sentiment more accurately.

Bigram Feature Matrix

Document 1 I Love NLP Document 2 Love NLP Today
Document I Love Love NLP NLP Today
Doc1 1 1 0
Doc2 0 1 1

Creating N-Grams using Count Vectorizer

from sklearn.feature_extraction.text import CountVectorizer cv = CountVectorizer( ngram_range=(2,2) )

(2,2) → Only Bigrams

cv = CountVectorizer( ngram_range=(1,2) )

(1,2) → Unigrams + Bigrams

Understanding ngram_range

ngram_range Meaning
(1,1) Only Unigrams
(2,2) Only Bigrams
(3,3) Only Trigrams
(1,2) Unigrams + Bigrams
(1,3) Unigrams + Bigrams + Trigrams

Advantages of N-Grams

  • Preserves Word Order
  • Captures Local Context
  • Improves Sentiment Analysis
  • Better than Pure Bag of Words
  • Works Well with Text Classification

Disadvantages of N-Grams

  • Vocabulary grows rapidly
  • Consumes more memory
  • Sparse matrix problem
  • Still cannot understand semantics
  • Computationally expensive for large datasets
Increasing N increases feature space dramatically.

Bag of Words vs N-Grams

Feature Bag of Words N-Grams
Word Frequency
Word Order
Context Partial
Memory Usage Low Higher
Sentiment Analysis Average Better

Applications of N-Grams

  • Sentiment Analysis
  • Machine Translation
  • Spell Checking
  • Text Prediction
  • Language Modeling
  • Speech Recognition
  • Search Engines

Quick Quiz

  1. What is an N-Gram?
  2. What is a Bigram?
  3. What is a Trigram?
  4. Why are N-Grams useful?
  5. What problem of Bag of Words do N-Grams solve?
  6. What does ngram_range=(1,2) mean?
  7. Why are N-Grams useful in sentiment analysis?

Interview Questions

  1. What are N-Grams?
  2. Explain Unigram, Bigram and Trigram.
  3. How do N-Grams preserve context?
  4. What is the limitation of Bag of Words?
  5. How does CountVectorizer generate N-Grams?
  6. What is ngram_range?
  7. Why do N-Grams increase vocabulary size?
  8. What are the applications of N-Grams?
  9. Can N-Grams understand semantic meaning?
  10. Why are N-Grams useful in sentiment analysis?
PART 1H

TF-IDF (Term Frequency - Inverse Document Frequency)

Finding Important Words Instead of Just Counting Words

What is TF-IDF?

TF-IDF is one of the most important feature extraction techniques in Natural Language Processing. While Bag of Words and Count Vectorizer only count words, TF-IDF identifies which words are important within a document.

Not all frequently occurring words are important. TF-IDF assigns importance scores to words.

Why Do We Need TF-IDF?

Suppose we have thousands of documents. Words like:

is the are was have had

appear in almost every document. These words do not help distinguish documents.

TF-IDF reduces the weight of common words and increases the weight of important words.

Real Life Example

Document 1: NLP is Amazing Document 2: AI is Powerful Document 3: NLP is Useful

The word "is" appears in all documents. The word "Amazing" appears in only one document.

"Amazing" should receive a higher importance score than "is".

Term Frequency (TF)

Term Frequency measures how frequently a word appears in a document.

TF = Number of Times Term Appears ÷ Total Number of Terms
Example
Document: NLP NLP AI

Total Words = 3 Frequency of NLP = 2

TF(NLP) = 2 / 3 = 0.67

Document Frequency (DF)

Document Frequency represents the number of documents containing a particular word.

Document 1: NLP is Amazing Document 2: AI is Powerful Document 3: NLP is Useful
Word DF
NLP 2
Amazing 1
is 3

Inverse Document Frequency (IDF)

IDF measures how rare a word is across all documents.

IDF = log( Total Documents ÷ Documents Containing Term )
Example

Total Documents = 3 DF(Amazing) = 1

IDF(Amazing) = log(3 / 1) = 1.09

Final TF-IDF Formula

TF-IDF = TF × IDF

A word receives a high score when:

  • It appears frequently in a document.
  • It appears rarely across all documents.

Complete Worked Example

Document: NLP NLP AI
Step 1 : Calculate TF
TF(NLP) = 2 / 3 = 0.67
Step 2 : Calculate IDF
Total Documents = 3 DF(NLP) = 1 IDF(NLP) = log(3 / 1) = 1.09
Step 3 : Calculate TF-IDF
TF-IDF = 0.67 × 1.09 = 0.73

TF-IDF Workflow

Documents
Calculate TF
Calculate DF
Calculate IDF
TF × IDF
Feature Matrix

TF-IDF Matrix

Document NLP AI Amazing Powerful
Doc1 0.73 0 1.09 0
Doc2 0 1.09 0 1.09

Python Example

from sklearn.feature_extraction.text import TfidfVectorizer documents = [ "I love NLP", "NLP is amazing", "AI loves NLP" ] vectorizer = TfidfVectorizer() X = vectorizer.fit_transform(documents) print(vectorizer.get_feature_names_out()) print(X.toarray())

Advantages of TF-IDF

  • Identifies important words.
  • Reduces common word influence.
  • Improves text classification.
  • Works well with Machine Learning.
  • Simple and efficient.

Limitations of TF-IDF

  • Cannot understand word meaning.
  • Cannot understand context.
  • Cannot understand synonyms.
  • Ignores sentence structure.
  • Still produces sparse matrices.
TF-IDF knows importance but does not know meaning. King and Queen remain unrelated words.

Comparison of Traditional Vectorization Techniques

Technique Frequency Importance Context
One Hot Encoding
Bag of Words
Count Vectorizer
N-Grams Partial
TF-IDF

Traditional NLP Vectorization Journey

One Hot Encoding
Bag of Words
Count Vectorizer
N-Grams
TF-IDF
Word Embeddings

Quick Quiz

  1. What does TF-IDF stand for?
  2. What is Term Frequency?
  3. What is Document Frequency?
  4. What is Inverse Document Frequency?
  5. Why is TF-IDF better than Bag of Words?
  6. Write the TF-IDF formula.
  7. Why do common words get lower scores?
  8. What are the limitations of TF-IDF?

Interview Questions

  1. Explain TF-IDF with an example.
  2. What is the difference between TF and IDF?
  3. Why is TF-IDF important in NLP?
  4. How does TF-IDF improve text classification?
  5. What are the limitations of TF-IDF?
  6. Can TF-IDF understand semantics?
  7. What is the difference between CountVectorizer and TfidfVectorizer?
  8. Why does TF-IDF reduce common word importance?
  9. What is sparse matrix representation?
  10. When should TF-IDF be preferred?
PART 2A

Word Embeddings

Moving from Word Counting to Understanding Meaning

Why Do We Need Word Embeddings?

Traditional Vectorization techniques such as:

  • One Hot Encoding
  • Bag of Words
  • Count Vectorizer
  • N-Grams
  • TF-IDF

focus mainly on counting words. They do not understand:

  • Meaning
  • Context
  • Relationships
  • Synonyms
  • Semantic Similarity
Traditional NLP knows frequency. Modern NLP understands meaning.

Problem with Traditional Vectorization

Words
King Queen Man Woman
TF-IDF View
King → 0.54 Queen → 0.63 Man → 0.21 Woman → 0.72

The model knows these are different words. But it does not know their relationships.

What is Semantic Understanding?

Semantic Understanding means understanding the meaning of words and their relationships.

King ≈ Queen Doctor ≈ Physician Car ≈ Automobile Dog ≈ Puppy

Humans naturally understand these relationships. Word Embeddings help machines learn them.

What is a Word Embedding?

A Word Embedding is a dense numerical vector that represents the meaning of a word.

King
[0.21, 0.85, 0.44, 0.91]

Queen
[0.24, 0.83, 0.48, 0.89]
Similar words receive similar vectors.

Sparse Vectors vs Dense Vectors

Feature Traditional NLP Word Embeddings
Vector Type Sparse Dense
Memory Usage High Low
Understands Meaning No Yes
Captures Context No Yes
Semantic Similarity No Yes

Word Embedding Visualization

King ● Queen ● Prince ● Princess ● Doctor ● Hospital ●

Words with similar meanings appear close together in vector space.

Embedding Space = Mathematical Representation of Meaning

How Word Embeddings Work

Text Corpus
Learn Context
Generate Vectors
Capture Meaning

The model observes which words frequently appear together.

Context Learning Example

The King rules the Kingdom The Queen rules the Kingdom The Prince lives in the Palace

The model notices:

  • King and Queen appear in similar contexts
  • Kingdom appears near both words
  • Prince appears in related contexts
Therefore the vectors become similar.

Famous Word Embedding Analogy

King − Man + Woman = Queen

Word Embeddings can learn relationships mathematically.

Types of Word Embeddings

Word Embeddings

Word2Vec

Google

GloVe

Stanford

FastText

Facebook

Introduction to Word2Vec

Word2Vec is one of the most popular embedding algorithms. It learns word meanings based on surrounding context.

Word
Context
Vector
The next chapter focuses entirely on Word2Vec.

Applications of Word Embeddings

  • ChatGPT
  • Machine Translation
  • Question Answering
  • Search Engines
  • Recommendation Systems
  • Sentiment Analysis
  • Speech Recognition
  • Text Summarization

Traditional NLP vs Modern NLP

Feature Traditional NLP Word Embeddings
Counts Words
Meaning
Context
Relationships
Semantic Search

Quick Quiz

  1. What is a Word Embedding?
  2. Why are embeddings better than TF-IDF?
  3. What is semantic understanding?
  4. What is a dense vector?
  5. Why are King and Queen close in embedding space?
  6. Name three embedding techniques.
  7. What is context learning?

Interview Questions

  1. What are Word Embeddings?
  2. Why do we need embeddings?
  3. Difference between TF-IDF and Word Embeddings?
  4. What are dense vectors?
  5. What is semantic similarity?
  6. Explain the King-Man+Woman=Queen analogy.
  7. What are the types of embeddings?
  8. How do embeddings capture meaning?
  9. Why are embeddings important for LLMs?
  10. What is embedding space?
PART 2B

Word2Vec

Learning Word Meaning from Context

What is Word2Vec?

Word2Vec is a Deep Learning based Word Embedding algorithm introduced by Google in 2013. It converts words into dense vectors while preserving semantic meaning.

Words appearing in similar contexts receive similar vector representations.

Why Was Word2Vec Introduced?

Traditional techniques such as:

  • One Hot Encoding
  • Bag of Words
  • Count Vectorizer
  • TF-IDF

cannot understand relationships between words.

King ≠ Queen Car ≠ Automobile Doctor ≠ Physician
Traditional NLP sees different words. Word2Vec understands related words.

Main Idea Behind Word2Vec

Words that appear in similar contexts usually have similar meanings.

The King rules the kingdom The Queen rules the kingdom

Since King and Queen appear in similar surroundings, Word2Vec learns that they are related.

How Word2Vec Works

Large Text Corpus
Context Learning
Neural Network
Dense Vectors

Understanding Context

Word2Vec learns from neighboring words.

I Love Natural Language Processing
Target Word Context Words
Natural Love, Language
Language Natural, Processing

Word2Vec Architectures

Word2Vec
CBOW
Skip-Gram

Word2Vec has two architectures: 1. CBOW (Continuous Bag of Words) 2. Skip-Gram

CBOW (Continuous Bag of Words)

CBOW predicts the target word using surrounding context words.

I Love _____ Processing

Using: I, Love, Processing Predict: Natural

Context Words
Predict Target Word

Skip-Gram

Skip-Gram does the opposite. It predicts surrounding words using the target word.

Target Word: Natural

Predict: Love Language

Target Word
Predict Context Words

CBOW vs Skip-Gram

Feature CBOW Skip-Gram
Input Context Words Target Word
Output Target Word Context Words
Training Speed Faster Slower
Small Datasets Better Average
Rare Words Average Better

Window Size

Window Size determines how many neighboring words are considered as context.

I Love Natural Language Processing

Window Size = 2

Target Context
Natural Love, Language

Generated Word Vectors

King [0.23, 0.87, 0.45, 0.91] Queen [0.25, 0.84, 0.47, 0.89]

Notice how both vectors are very similar.

Semantic Relationships Learned by Word2Vec

King − Man + Woman = Queen

Paris − France + Italy = Rome

Word2Vec Training Process

Corpus
Tokenization
Context Extraction
Neural Network
Embeddings

Python Example using Gensim

from gensim.models import Word2Vec sentences = [ ["i","love","nlp"], ["nlp","is","amazing"], ["ai","uses","nlp"] ] model = Word2Vec( sentences, vector_size=100, window=5, min_count=1 ) print(model.wv["nlp"])

Advantages of Word2Vec

  • Captures semantic meaning
  • Dense vectors
  • Memory efficient
  • Understands word relationships
  • Works well with NLP applications

Limitations of Word2Vec

  • Same word always gets same vector
  • Cannot handle multiple meanings effectively
  • Needs large corpus
  • Context understanding is limited
The word "Bank" (river bank vs financial bank) gets the same vector.

Applications of Word2Vec

  • Search Engines
  • Recommendation Systems
  • Chatbots
  • Machine Translation
  • Sentiment Analysis
  • Question Answering Systems

Quick Quiz

  1. What is Word2Vec?
  2. Why was Word2Vec introduced?
  3. What is CBOW?
  4. What is Skip-Gram?
  5. What is Window Size?
  6. Why are King and Queen close in vector space?
  7. What are the advantages of Word2Vec?

Interview Questions

  1. Explain Word2Vec.
  2. How does Word2Vec learn word meanings?
  3. Difference between CBOW and Skip-Gram?
  4. What is Window Size?
  5. Why are embeddings dense vectors?
  6. Explain the King − Man + Woman = Queen analogy.
  7. What are the limitations of Word2Vec?
  8. Why is Word2Vec better than TF-IDF?
  9. What is semantic similarity?
  10. How is Word2Vec trained?
PART 2C

CBOW (Continuous Bag of Words)

Predicting a Word Using Its Surrounding Context

What is CBOW?

CBOW (Continuous Bag of Words) is one of the two architectures of Word2Vec. Its goal is simple:

Use surrounding words (context words) to predict the missing target word.

CBOW learns word meanings by observing neighboring words.

Real Life Intuition

Humans can often guess a missing word using surrounding words.

I Love _____ Processing

Most people will predict:

Natural

CBOW trains a neural network to perform exactly this task.

Main Idea Behind CBOW

Context Words
Neural Network
Target Word

Input: I Love Processing Output: Natural

Example Sentence

I Love Natural Language Processing

Assume:

Target Word = Natural Context Words = Love, Language

Understanding Window Size

Window Size determines how many neighboring words are used as context.

I Love Natural Language Processing
Window Size = 1
Love Language
Window Size = 2
I Love Language Processing
Larger Window Size captures more context.

CBOW Architecture

Input Layer
Hidden Layer
Output Layer

Input Layer

The Input Layer receives context words.

Sentence: I Love Natural Language Processing Target: Natural Input: Love Language

Context words are converted into vectors.

Hidden Layer

The Hidden Layer learns relationships between words.

This layer gradually learns:

  • Semantic Meaning
  • Word Relationships
  • Context Information
  • Word Similarities
This layer creates the word embeddings.

Output Layer

The Output Layer predicts the most probable target word.

Input: Love, Language Output: Natural

Complete CBOW Workflow

Sentence
Extract Context
Feed Neural Network
Predict Word
Learn Embeddings

Training Example

Sentence: The Cat Drinks Milk
Context Words Target Word
The, Drinks Cat
Cat, Milk Drinks
Drinks Milk

Mathematical View

CBOW attempts to maximize:

P(Target Word | Context Words)

Meaning: Probability of Target Word given the surrounding Context Words.

CBOW Visualization

Love Language ↓ Neural Network ↓ Natural

The model learns that these context words frequently surround "Natural".

Why CBOW Works

Words appearing in similar contexts often have similar meanings.

The King rules the Kingdom The Queen rules the Kingdom

Since King and Queen appear in similar surroundings, their embeddings become similar.

Advantages of CBOW

  • Fast Training
  • Efficient on Large Datasets
  • Good General Embeddings
  • Less Computational Cost
  • Works Well for Frequent Words

Limitations of CBOW

  • Poor for Rare Words
  • Uses Fixed Context Window
  • Cannot Handle Multiple Meanings Well
  • Context Understanding is Limited
The word "Bank" still receives one vector, even if it means river bank or financial bank.

CBOW vs Skip-Gram

Feature CBOW Skip-Gram
Input Context Words Target Word
Output Target Word Context Words
Training Speed Fast Slow
Frequent Words Better Good
Rare Words Weak Better

Python Example using Gensim

from gensim.models import Word2Vec sentences = [ ["i","love","nlp"], ["nlp","is","amazing"], ["ai","uses","nlp"] ] model = Word2Vec( sentences, vector_size=100, window=2, min_count=1, sg=0 ) print(model.wv["nlp"])

Important Note

sg = 0 → CBOW sg = 1 → Skip-Gram

Applications of CBOW

  • Search Engines
  • Recommendation Systems
  • Document Classification
  • Chatbots
  • Machine Translation
  • Question Answering Systems

Quick Quiz

  1. What is CBOW?
  2. What does CBOW predict?
  3. What is Window Size?
  4. What is the role of the Hidden Layer?
  5. What does sg=0 mean?
  6. Why is CBOW faster than Skip-Gram?
  7. What are the limitations of CBOW?

Interview Questions

  1. Explain CBOW architecture.
  2. How does CBOW work?
  3. What is the difference between CBOW and Skip-Gram?
  4. What is Window Size?
  5. Why is CBOW faster?
  6. How are embeddings learned in CBOW?
  7. What does sg=0 represent?
  8. What are the advantages of CBOW?
  9. What are the limitations of CBOW?
  10. When should CBOW be preferred?
PART 2D

Skip-Gram Architecture

Predicting Context Words Using the Target Word

What is Skip-Gram?

Skip-Gram is one of the two architectures of Word2Vec. Unlike CBOW, which predicts a target word from context words, Skip-Gram predicts surrounding context words using the target word.

Target Word → Predict Context Words

Real Life Intuition

Suppose we know the word:

Natural

We can often predict nearby words such as:

Love Language Processing

Skip-Gram trains a neural network to perform this prediction.

Main Idea Behind Skip-Gram

Target Word
Neural Network
Context Words

Input: Natural Output: Love, Language

Example Sentence

I Love Natural Language Processing

Assume:

Target Word = Natural Context Words = Love, Language

Understanding Window Size

Window Size determines how many neighboring words are predicted.

I Love Natural Language Processing
Window Size = 1
Love Language
Window Size = 2
I Love Language Processing
Larger windows capture broader context.

Skip-Gram Architecture

Input Layer
Hidden Layer
Output Layer

Input Layer

The Input Layer receives the target word.

Target Word: Natural

The target word is converted into a numerical vector.

Hidden Layer

The hidden layer learns semantic relationships among words.

  • Word Meaning
  • Word Similarity
  • Context Information
  • Relationships
This layer generates the final word embeddings.

Output Layer

The Output Layer predicts nearby context words.

Input: Natural Output: Love Language

Training Example

Sentence: The Cat Drinks Milk
Input (Target) Output (Context)
Cat The
Cat Drinks
Drinks Cat
Drinks Milk

Complete Skip-Gram Workflow

Sentence
Target Word
Predict Context
Learn Embeddings

Mathematical View

Skip-Gram tries to maximize:

P(Context Words | Target Word)

Meaning: Probability of observing surrounding words given a target word.

How Skip-Gram Learns Meaning

The King rules the Kingdom The Queen rules the Kingdom

The model notices:

  • King appears near rules and kingdom
  • Queen appears near rules and kingdom
Therefore King and Queen receive similar vectors.

Why Skip-Gram is Better for Rare Words?

Each target word generates multiple training examples.

Target: Natural Context: Love Language Processing

This helps the model learn rare words more effectively.

Skip-Gram performs better than CBOW on rare vocabulary.

CBOW vs Skip-Gram

Feature CBOW Skip-Gram
Input Context Words Target Word
Output Target Word Context Words
Training Speed Fast Slower
Rare Words Average Excellent
Large Datasets Good Excellent
Accuracy Good Higher

CBOW vs Skip-Gram Visualization

CBOW

Love + Language ↓ Natural

Skip-Gram

Natural ↓ Love + Language

Python Example using Gensim

from gensim.models import Word2Vec sentences = [ ["i","love","nlp"], ["nlp","is","amazing"], ["ai","uses","nlp"] ] model = Word2Vec( sentences, vector_size=100, window=2, min_count=1, sg=1 ) print(model.wv["nlp"])

Important Note

sg = 0 → CBOW sg = 1 → Skip-Gram

Advantages of Skip-Gram

  • Learns better embeddings
  • Handles rare words effectively
  • Captures semantic relationships
  • Produces high-quality vectors
  • Suitable for large corpora

Limitations of Skip-Gram

  • Slower training
  • Requires more computation
  • Needs large datasets
  • Cannot fully understand sentence meaning
Skip-Gram still produces one vector per word. Different meanings of the same word are not separated.

Applications of Skip-Gram

  • Search Engines
  • Recommendation Systems
  • Machine Translation
  • Chatbots
  • Text Classification
  • Question Answering Systems
  • Semantic Search

Quick Quiz

  1. What is Skip-Gram?
  2. How is Skip-Gram different from CBOW?
  3. What does Skip-Gram predict?
  4. What is Window Size?
  5. Why is Skip-Gram better for rare words?
  6. What does sg=1 mean?
  7. What are the advantages of Skip-Gram?

Interview Questions

  1. Explain Skip-Gram architecture.
  2. How does Skip-Gram work?
  3. Difference between CBOW and Skip-Gram?
  4. Why is Skip-Gram better for rare words?
  5. What is Window Size?
  6. What does sg=1 represent?
  7. How are embeddings learned in Skip-Gram?
  8. What are the advantages of Skip-Gram?
  9. What are the limitations of Skip-Gram?
  10. When should Skip-Gram be preferred?
PART 2E

GloVe (Global Vectors for Word Representation)

Combining Global Statistics with Semantic Understanding

What is GloVe?

GloVe (Global Vectors for Word Representation) is a word embedding technique developed by Stanford University. It creates meaningful word vectors by analyzing how frequently words appear together across an entire corpus.

Word2Vec learns from local context. GloVe learns from both local context and global statistics.

Why Was GloVe Introduced?

Word2Vec is excellent at learning local context. However, it does not fully utilize the overall statistics of the corpus.

King appears with: royal queen palace Queen appears with: royal king palace

GloVe studies these global relationships across the entire dataset.

Main Idea Behind GloVe

Words that frequently occur together should have similar vector representations.

Word Co-occurrence Matrix
Matrix Factorization
Word Embeddings

What is a Co-occurrence Matrix?

A Co-occurrence Matrix stores how often words appear together.

Sentence: I Love NLP NLP Loves AI
Word I Love NLP AI
I 0 1 1 0
Love 1 0 1 0
NLP 1 1 0 1
AI 0 0 1 0

Local Context vs Global Context

Feature Word2Vec GloVe
Local Context
Global Statistics
Corpus Wide Learning Limited Strong
Semantic Relationships Good Excellent

Matrix Factorization

The Co-occurrence Matrix can become extremely large. GloVe compresses this information into smaller dense vectors.

Huge Matrix
Factorization
Dense Embeddings

GloVe Mathematical Formula

wᵢᵀ wⱼ + bᵢ + bⱼ ≈ log(Xᵢⱼ)

Where:

  • wᵢ = Word Vector
  • wⱼ = Context Vector
  • bᵢ = Word Bias
  • bⱼ = Context Bias
  • Xᵢⱼ = Co-occurrence Count

Simple Explanation of the Formula

The formula tries to ensure:

Words that appear together frequently ↓ Should have similar vectors

The model continuously adjusts vectors until the mathematical relationship matches real-world word co-occurrences.

Example: Learning Relationships

King → Royal, Palace, Queen Queen → Royal, Palace, King Doctor → Hospital, Patient Nurse → Hospital, Patient

Because these words appear in similar contexts, their vectors become similar.

GloVe automatically learns semantic similarity.

Famous GloVe Analogy

King − Man + Woman = Queen

Paris − France + Italy = Rome

These relationships emerge naturally from word co-occurrence statistics.

GloVe Training Process

Large Corpus
Build Co-occurrence Matrix
Matrix Factorization
Generate Embeddings

Embedding Space Visualization

King ● Queen ● Prince ● Princess ● Doctor ● Nurse ● Hospital ●

Words with similar meanings cluster together.

Word2Vec vs GloVe

Feature Word2Vec GloVe
Learning Method Prediction Based Count Based
Uses Context Local Global + Local
Co-occurrence Matrix
Semantic Quality High Very High
Training Speed Fast Moderate

Using Pretrained GloVe Embeddings

import gensim.downloader as api glove = api.load("glove-wiki-gigaword-100") print( glove.most_similar("king") )

Advantages of GloVe

  • Captures semantic meaning
  • Uses global corpus statistics
  • Produces high-quality embeddings
  • Learns word relationships
  • Efficient for large datasets
  • Excellent for NLP applications

Limitations of GloVe

  • Cannot handle unseen words
  • Static embeddings
  • One word = One vector
  • Cannot handle multiple meanings effectively
  • Requires large training corpora
Bank (financial) Bank (river) ↓ Same vector

Applications of GloVe

  • Chatbots
  • Machine Translation
  • Search Engines
  • Recommendation Systems
  • Question Answering Systems
  • Text Classification
  • Sentiment Analysis
  • Information Retrieval

GloVe Summary

Corpus
Co-occurrence Matrix
Factorization
Dense Embeddings
Semantic Understanding

Quick Quiz

  1. What does GloVe stand for?
  2. What is a Co-occurrence Matrix?
  3. Why was GloVe introduced?
  4. How is GloVe different from Word2Vec?
  5. What is Matrix Factorization?
  6. Why are King and Queen close in vector space?
  7. What are the limitations of GloVe?

Interview Questions

  1. Explain GloVe Embeddings.
  2. How does GloVe work?
  3. What is a Co-occurrence Matrix?
  4. Difference between Word2Vec and GloVe?
  5. What is Matrix Factorization?
  6. Why does GloVe produce better semantic vectors?
  7. What are the advantages of GloVe?
  8. What are its limitations?
  9. Explain the King − Man + Woman = Queen analogy.
  10. When would you use GloVe instead of Word2Vec?
PART 2F

FastText

Solving the Out-Of-Vocabulary (OOV) Problem using Subword Information

What is FastText?

FastText is a Word Embedding algorithm developed by Facebook AI Research (FAIR). It improves Word2Vec by learning not only complete words but also parts of words called subwords.

Word2Vec learns from words. FastText learns from words + character patterns.

Why Was FastText Introduced?

Word2Vec and GloVe have a major limitation.

Known Word: computer Unknown Word: computers computerized computerization

Traditional embeddings treat these as completely different words.

Unknown words cannot be represented properly. This is called the OOV Problem.

What is OOV (Out Of Vocabulary)?

OOV words are words that were never seen during training.

Training Vocabulary cat dog car Testing Word cats

Word2Vec: ❌ Cannot generate embedding FastText: ✔ Can generate embedding

Main Idea Behind FastText

FastText breaks words into smaller character-level chunks called N-Grams.

Word
Character N-Grams
Embeddings

Character N-Grams

Consider the word:

Computer

FastText generates character N-Grams.

<co com omp mpu put ute ter er>

< and > represent beginning and ending boundaries.

Word Construction Visualization

Computer
Subwords
Embeddings
Final Vector

Example: Unknown Word Handling

Suppose the model has seen:

play playing player played

Now a new word appears:

playfulness

FastText can still understand it because it recognizes:

pla lay ayf yfu ful ness

FastText Architecture

Input Word
Character N-Grams
Neural Network
Word Embedding

Training Process

  1. Collect Text Corpus
  2. Tokenize Text
  3. Generate Character N-Grams
  4. Train Neural Network
  5. Learn Subword Embeddings
  6. Combine Subwords into Final Word Vector

Word2Vec vs GloVe vs FastText

Feature Word2Vec GloVe FastText
Word Embeddings
Context Learning
Character Information
Handles OOV Words
Morphological Understanding

Morphological Understanding

Morphology refers to the structure of words.

teach teacher teaching teaches

FastText understands that all these words are related because they share similar character patterns.

FastText Embedding Example

computer [0.45, 0.76, 0.23, 0.89] computerized [0.44, 0.75, 0.25, 0.87]

Notice that both vectors remain very similar.

Python Example

from gensim.models import FastText sentences = [ ["i","love","nlp"], ["nlp","is","amazing"], ["ai","uses","nlp"] ] model = FastText( sentences, vector_size=100, window=5, min_count=1 ) print(model.wv["nlp"])

Real World Applications

  • Chatbots
  • Search Engines
  • Spell Correction
  • Machine Translation
  • Text Classification
  • Question Answering
  • Recommendation Systems
  • Multilingual NLP

Advantages of FastText

  • Handles OOV Words
  • Uses Character-Level Information
  • Captures Word Structure
  • Better for Rare Words
  • Works Well on Small Datasets
  • Excellent for Morphologically Rich Languages

Limitations of FastText

  • Larger Model Size
  • More Memory Usage
  • Slower Training than Word2Vec
  • Still Produces Static Embeddings
  • Cannot Fully Understand Sentence Meaning
FastText improves word understanding, but it still generates one embedding per word.

Evolution of Word Embeddings

Word2Vec
GloVe
FastText
Transformers

Quick Quiz

  1. What is FastText?
  2. Why was FastText introduced?
  3. What is OOV?
  4. What are Character N-Grams?
  5. How does FastText handle unknown words?
  6. Difference between Word2Vec and FastText?
  7. What is morphology?
  8. What are the advantages of FastText?

Interview Questions

  1. Explain FastText.
  2. What is the OOV problem?
  3. How does FastText solve OOV?
  4. What are Character N-Grams?
  5. Difference between Word2Vec, GloVe and FastText?
  6. What is morphological understanding?
  7. Why is FastText useful for rare words?
  8. What are the limitations of FastText?
  9. How does FastText generate embeddings?
  10. When should FastText be preferred?
PART 3A

Contextual Embeddings & Transformers

From Static Word Embeddings to Modern Large Language Models

The Next Evolution in NLP

We have already studied:

One Hot
BoW
TF-IDF
Word2Vec
GloVe
FastText

These methods improved NLP significantly. However they still have a major limitation.

A word always receives the same vector, regardless of the sentence.

Problem with Traditional Embeddings

Consider the word:

Bank

Sentence 1 I deposited money in the bank.

Sentence 2 Children are playing near the river bank.

Humans understand that "bank" has different meanings.

Word2Vec, GloVe and FastText generate the SAME vector.

Polysemy Problem

Polysemy means:

One Word ↓ Multiple Meanings

Word Meaning 1 Meaning 2
Bank Financial Institution River Side
Bat Animal Cricket Bat
Apple Fruit Technology Company

Static vs Contextual Embeddings

Feature Static Embeddings Contextual Embeddings
One Vector per Word
Context Awareness
Handles Polysemy
Sentence Understanding Limited Excellent
Used in LLMs

What are Contextual Embeddings?

Contextual Embeddings generate different vectors for the same word depending on the sentence.

Bank (Money Context) ↓ [0.45, 0.21, 0.87]

Bank (River Context) ↓ [0.12, 0.94, 0.32]
Same word Different meanings Different vectors

Introduction to Transformers

Transformers are Deep Learning architectures introduced by Google in 2017. They completely changed NLP.

Paper: Attention Is All You Need (2017)

Almost all modern NLP systems use Transformers.

Why Transformers Replaced RNNs and LSTMs?

Problem RNN/LSTM Transformer
Sequential Processing Slow Fast
Long Context Difficult Excellent
Parallel Processing
Training Speed Slow Fast

Attention Mechanism

Attention helps the model focus on important words while processing a sentence.

The cat sat on the mat.

When processing:

cat

the model gives more attention to:

sat mat

Self-Attention

Self-Attention allows every word to look at every other word in the sentence.

Word 1
Word 2
Word 3
Word 4

Every word understands its relationship with every other word.

Self-Attention Example

The animal didn't cross the street because it was tired.

Question: Who was tired?

it → animal

Self-Attention helps identify such relationships.

Transformer Architecture

Input Text
Embedding Layer
Self-Attention
Feed Forward
Output

Encoder and Decoder

Encoder

  • Reads Input
  • Understands Context
  • Creates Representation

Decoder

  • Generates Output
  • Creates Sentences
  • Predicts Next Words

Transformer Family

Model Architecture Main Purpose
BERT Encoder Understanding Text
GPT Decoder Generating Text
T5 Encoder + Decoder Both Tasks

BERT

BERT stands for:

Bidirectional Encoder Representations from Transformers

BERT reads sentences in both directions.

Excellent for understanding language.

GPT

GPT stands for:

Generative Pre-trained Transformer

GPT predicts the next word repeatedly to generate text.

Artificial Intelligence is ↓ changing ↓ the ↓ world

Modern LLMs

Modern Large Language Models are built using Transformer architectures.

  • GPT-4
  • GPT-5
  • Gemini
  • Claude
  • Llama
  • Mistral
Transformers are the foundation of Generative AI.

Evolution of NLP

TF-IDF
Word2Vec
GloVe
FastText
Transformers
LLMs

Quick Quiz

  1. What are Contextual Embeddings?
  2. What is Polysemy?
  3. Why do static embeddings fail?
  4. What is a Transformer?
  5. What is Attention?
  6. What is Self-Attention?
  7. Difference between BERT and GPT?
  8. Why are Transformers important?

Interview Questions

  1. Explain Contextual Embeddings.
  2. Difference between static and contextual embeddings?
  3. What problem do Transformers solve?
  4. What is Self-Attention?
  5. Why are Transformers faster than RNNs?
  6. Explain Encoder and Decoder.
  7. Difference between BERT and GPT?
  8. What is Polysemy?
  9. How do LLMs use Transformers?
  10. Why did Transformers revolutionize NLP?