SlideShare a Scribd company logo
Natural Language Processing word to Vec.pdf
Natural Language Processing
(Vectorization Techniques)
Natural Language Processing word to Vec.pdf
CloudKarya
❖ Word Vector
■ one-hot vector
❖ Countvectorizer
■ Bag of Words
■ Term frequency-Inverse Document Frequency(TF-IDF)
❖ SVD(Singular Value Decomposition)
■ Word-Document Matrix
■ window based Co-occurrence Matrix
■ Applying SVD to the cooccurrence matrix
❖ Iterative Method(Word2vec)
How to represent words?
CloudKarya
Let us consider the two sentences -
1. “You can scale your business.”
2. “You can grow your business.”
Word Vectors
Grow: [0,0,0,1,0,0],
Your:[0,0,0,0,1,0],
Business: [0,0,0,0,0,1]
You Can Scale Grow Your Business
} none of these words
has any similarity with
each other
Vocabulary:
You: [1,0,0,0,0,0],
Can: [0,1,0,0,0,0],
Scale: [0,0,1,0,0,0],
CloudKarya
Let us consider the two sentences –
1. ”The cat jumped over the moon."
2. "The cow jumped over the moon."
Countvectorizer
Vocabulary:
The Cat jumped over moon cow
TF-IDF Vectorization:
Sentence 1: [0.3, 0.6, 0.3, 0.3, 0.3, 0]
Sentence 2 :[0.3, 0, 0.3, 0.3, 0.3, 0.6]
BOW Representation:
Sentence 1: [2, 1, 1, 1, 1, 0]
Sentence 2 :[2, 0, 1, 1, 1, 1].
}
none of
these words
has any
similarity
with each
other
This approach disregards the importance of the
specific words and treats all words equally.
CloudKarya
Word2Vec
What is Word2Vec ?
● A two layer neural network to generate word embeddings given a text corpus.
● Word Embeddings — Mapping of words in a vector space.
0.52
0.76
1.21
0.22
-1.36
0.49
-3.69
-0.07
0.73
0.89
-1.67
1.32
0.36
-1.49
2.71
0.05
Man Women
King - Man + Women = Queen
Why Word2Vec ?
Why
Word2Vec
?
Preserves relationship between words.
Deals with addition of new words in the vocabulary.
Better results in lot of deep learning applications.
Working of Word2Vec
● The word2vec objective function causes the words that occur in similar
contents to have similar embeddings.
Example:
● The words kid and child will have similar word vectors due to a similar
context.
The kid said he would grow up to be superman.
The child said he would grow up to be superman.
CloudKarya
CBOW (Continuous Bag of Words)
● Predict the target word from the context.
The quick brown fox over The lazy dog
Jumps
Skip Gram
● Predict the context words from target.
The quick brown fox over The lazy dog
Jumps
CBOW - Working
Hope can set you free.
One hot vector - One bit ‘1’ and all others ‘0’
Vector length = Number of words in language
1
0
0
0
0
0
0
1
0
0
V 5 x 1
, One hot vector
of “Hope”
V 5 x 1
, One hot vector
of “set”
W3x5
W ’
3x5
W3x5
3 nodes in
hidden layer
V5 X1
,
Predicted one hot
Vector of “Can”
0
1
0
0
0
Actual Target
Compare and
Update weights w00 w01 w02 w03 w04
w10 w11 w12 w13 w14
w20 w21 w22 w23 w24
W3x5
Skip Gram - Working
Hope can set you free.
1
0
0
0
0
0
0
1
0
0
V 5 x 1
, One hot vector
of “Can””
W ’
3x5
3 nodes in
hidden layer
V5 X1
, Predicted vector of “set”
0
1
0
0
0
Actual Target
Compare and Update weights
W3x5
W ’
3x5
V5 X1
, Predicted vector of “hope”
Word Emmendings:
w00 w01 w02 w03 w04
w10 w11 w12 w13 w14
w20 w21 w22 w23 w24
w00 w01 w02 w03 w04
w10 w11 w12 w13 w14
w20 w21 w22 w23 w24
x
1
0
0
0
0
=
w00
w10
w20
1
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
0
1
One Hot vector of words V 5 x 1
Hope can set you free
0
0
0
0
1
Weights after training
W 3 x 5
,
Word vector for Hope = W 3 x 5
X V 5 x 1
V 3 x 1
Word Vector for Hope
Reason behind predicting words instead of generating embedding.
The embedding is extracted from the weight matrix.
How to deal with variable length reviews?
● Vector Averaging: It is simply averaging the word vectors in the
given review
● Clustering: This is a of exploiting the similarity of words within a
cluster
○ K-means Clustering
○ Bag of centroids
Thank you

More Related Content

PDF
Word Embeddings, why the hype ?
PPTX
Natural language processing unit - 2 ppt
PPTX
Word_Embedding.pptx
PPTX
A Panorama of Natural Language Processing
PDF
Word2Vec
PPTX
Vectorization In NLP.pptx
PDF
Word2vec ultimate beginner
PPTX
CVDL Unit-5.pptx this is relates to computer vision
Word Embeddings, why the hype ?
Natural language processing unit - 2 ppt
Word_Embedding.pptx
A Panorama of Natural Language Processing
Word2Vec
Vectorization In NLP.pptx
Word2vec ultimate beginner
CVDL Unit-5.pptx this is relates to computer vision

Similar to Natural Language Processing word to Vec.pdf (20)

PPTX
Word_Embeddings.pptx
PPTX
Deep Learning Bangalore meet up
PPTX
DLBLR talk
PPTX
Word embeddings
PPT
Word 2 vector
PPTX
Word2vec slide(lab seminar)
PPTX
Word2 vec
PPTX
NLP WORDEMBEDDDING TECHINUES CBOW BOW.pptx
PDF
Language Modelling in Natural Language Processing-Part II.pdf
PPTX
Pycon ke word vectors
PDF
Deep learning for nlp
PDF
Yoav Goldberg: Word Embeddings What, How and Whither
PPTX
Word embeddings
PPTX
PDF
Lda2vec text by the bay 2016 with notes
PDF
Bijaya Zenchenko - An Embedding is Worth 1000 Words - Start Using Word Embedd...
PPTX
Embedding for fun fumarola Meetup Milano DLI luglio
PPTX
Text features
PPTX
DL-CO2 -Session 3 Learning Vectorial Representations of Words.pptx
PPTX
word vector embeddings in natural languag processing
Word_Embeddings.pptx
Deep Learning Bangalore meet up
DLBLR talk
Word embeddings
Word 2 vector
Word2vec slide(lab seminar)
Word2 vec
NLP WORDEMBEDDDING TECHINUES CBOW BOW.pptx
Language Modelling in Natural Language Processing-Part II.pdf
Pycon ke word vectors
Deep learning for nlp
Yoav Goldberg: Word Embeddings What, How and Whither
Word embeddings
Lda2vec text by the bay 2016 with notes
Bijaya Zenchenko - An Embedding is Worth 1000 Words - Start Using Word Embedd...
Embedding for fun fumarola Meetup Milano DLI luglio
Text features
DL-CO2 -Session 3 Learning Vectorial Representations of Words.pptx
word vector embeddings in natural languag processing
Ad

Recently uploaded (20)

PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Complications of Minimal Access Surgery at WLH
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Institutional Correction lecture only . . .
PDF
Computing-Curriculum for Schools in Ghana
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Pharma ospi slides which help in ospi learning
PDF
Classroom Observation Tools for Teachers
PPTX
Cell Structure & Organelles in detailed.
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Cell Types and Its function , kingdom of life
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Complications of Minimal Access Surgery at WLH
Anesthesia in Laparoscopic Surgery in India
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Final Presentation General Medicine 03-08-2024.pptx
Institutional Correction lecture only . . .
Computing-Curriculum for Schools in Ghana
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
A systematic review of self-coping strategies used by university students to ...
102 student loan defaulters named and shamed – Is someone you know on the list?
Pharma ospi slides which help in ospi learning
Classroom Observation Tools for Teachers
Cell Structure & Organelles in detailed.
O7-L3 Supply Chain Operations - ICLT Program
Microbial diseases, their pathogenesis and prophylaxis
human mycosis Human fungal infections are called human mycosis..pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Microbial disease of the cardiovascular and lymphatic systems
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Cell Types and Its function , kingdom of life
Ad

Natural Language Processing word to Vec.pdf

  • 4. CloudKarya ❖ Word Vector ■ one-hot vector ❖ Countvectorizer ■ Bag of Words ■ Term frequency-Inverse Document Frequency(TF-IDF) ❖ SVD(Singular Value Decomposition) ■ Word-Document Matrix ■ window based Co-occurrence Matrix ■ Applying SVD to the cooccurrence matrix ❖ Iterative Method(Word2vec) How to represent words?
  • 5. CloudKarya Let us consider the two sentences - 1. “You can scale your business.” 2. “You can grow your business.” Word Vectors Grow: [0,0,0,1,0,0], Your:[0,0,0,0,1,0], Business: [0,0,0,0,0,1] You Can Scale Grow Your Business } none of these words has any similarity with each other Vocabulary: You: [1,0,0,0,0,0], Can: [0,1,0,0,0,0], Scale: [0,0,1,0,0,0],
  • 6. CloudKarya Let us consider the two sentences – 1. ”The cat jumped over the moon." 2. "The cow jumped over the moon." Countvectorizer Vocabulary: The Cat jumped over moon cow TF-IDF Vectorization: Sentence 1: [0.3, 0.6, 0.3, 0.3, 0.3, 0] Sentence 2 :[0.3, 0, 0.3, 0.3, 0.3, 0.6] BOW Representation: Sentence 1: [2, 1, 1, 1, 1, 0] Sentence 2 :[2, 0, 1, 1, 1, 1]. } none of these words has any similarity with each other This approach disregards the importance of the specific words and treats all words equally.
  • 8. What is Word2Vec ? ● A two layer neural network to generate word embeddings given a text corpus. ● Word Embeddings — Mapping of words in a vector space. 0.52 0.76 1.21 0.22 -1.36 0.49 -3.69 -0.07 0.73 0.89 -1.67 1.32 0.36 -1.49 2.71 0.05 Man Women King - Man + Women = Queen
  • 9. Why Word2Vec ? Why Word2Vec ? Preserves relationship between words. Deals with addition of new words in the vocabulary. Better results in lot of deep learning applications.
  • 10. Working of Word2Vec ● The word2vec objective function causes the words that occur in similar contents to have similar embeddings. Example: ● The words kid and child will have similar word vectors due to a similar context. The kid said he would grow up to be superman. The child said he would grow up to be superman.
  • 12. CBOW (Continuous Bag of Words) ● Predict the target word from the context. The quick brown fox over The lazy dog Jumps
  • 13. Skip Gram ● Predict the context words from target. The quick brown fox over The lazy dog Jumps
  • 14. CBOW - Working Hope can set you free. One hot vector - One bit ‘1’ and all others ‘0’ Vector length = Number of words in language 1 0 0 0 0 0 0 1 0 0 V 5 x 1 , One hot vector of “Hope” V 5 x 1 , One hot vector of “set” W3x5 W ’ 3x5 W3x5 3 nodes in hidden layer V5 X1 , Predicted one hot Vector of “Can” 0 1 0 0 0 Actual Target Compare and Update weights w00 w01 w02 w03 w04 w10 w11 w12 w13 w14 w20 w21 w22 w23 w24 W3x5
  • 15. Skip Gram - Working Hope can set you free. 1 0 0 0 0 0 0 1 0 0 V 5 x 1 , One hot vector of “Can”” W ’ 3x5 3 nodes in hidden layer V5 X1 , Predicted vector of “set” 0 1 0 0 0 Actual Target Compare and Update weights W3x5 W ’ 3x5 V5 X1 , Predicted vector of “hope”
  • 16. Word Emmendings: w00 w01 w02 w03 w04 w10 w11 w12 w13 w14 w20 w21 w22 w23 w24 w00 w01 w02 w03 w04 w10 w11 w12 w13 w14 w20 w21 w22 w23 w24 x 1 0 0 0 0 = w00 w10 w20 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 One Hot vector of words V 5 x 1 Hope can set you free 0 0 0 0 1 Weights after training W 3 x 5 , Word vector for Hope = W 3 x 5 X V 5 x 1 V 3 x 1 Word Vector for Hope Reason behind predicting words instead of generating embedding. The embedding is extracted from the weight matrix.
  • 17. How to deal with variable length reviews? ● Vector Averaging: It is simply averaging the word vectors in the given review ● Clustering: This is a of exploiting the similarity of words within a cluster ○ K-means Clustering ○ Bag of centroids Thank you