Today we are going to discuss 3
broad category of techniques that are
used to solve any NLP problem.
Before we continue with today's
conversation there are few prerequisites
that you need to follow, and if you know
those then it will become easier to
understand today's conversation. Now it
seems like there is just a lot to learn
in terms of prerequisites. So if you
still want to continue with this
playlist continue.
And as we
go through more videos in each of the
videos I will tell you if some of those
prerequisites is a must or not.
The first one is obviously Python
knowledge. So if you go to youtube search
for Codebasics Python tutorial. In this
related playlist you need to follow
first
I would say 16 or 17 videos. The second
one is machine learning.
In youtube search codebasics machine
learning this is one of the popular
playlist on youtube
and
you can pretty much follow all the
videos till let's say 17 or 18 videos.
And after that
I have some projects so don't worry too
much about projects. If you do project of
course it's going to help you. But
in terms of prerequisites for NLP those
many videos are good enough.
Search for Codebasics deep learning in
youtube again I have a deep learning
playlist
where I talked about various deep
learning concepts. So what you can do is
you can start from the beginning and
follow all the video till
let's say till 15.
You can skip Tensorflow, GPU bench-marking
and all of this
and then
you can also skip computer vision videos
because these are specific to the
computer vision problem.
And
at some point I start talking about
recurrent neural network that is related
to
NLP and natural language processing. So
you can follow from RNN till
Word2Vec here.
This this one you can skip
and then then
BERT and BERT classification these two
are important. So if you see
if you have seen
all these videos, it will help you in
this NLP playlist. But if you don't have
time to go through lot of this content,
still you can hang on this series and in
individual video if there is a
prerequisite which which is a must, I
will mention that. We will look at some
concrete example to understand those
three broad categories.
Here is the email where I booked a
flight ticket of my mother-in-law
and when
gmail detected
this flight ticket in the email,
what they did is
they did information extraction. So one
of the
problem areas in NLP world is
information extraction.
And what I mean by that is you see this
summary at the top, so when you open this
email
Google provides a nice summary when is
the flight,
destination source, flight duration,
confirmation number.
How did it do that? Well we looked at
regular expression in our last video if
you remember. So if you go to youtube
Codebasics NLP Regex tutorial, I'm
talking about this video,
they use regular expression.
For example to get confirmation number,
you can look for a string such as
booking ref and anything that follows
that
should be a confirmation number most
likely.
So regular expression is a very
effective, very accurate way of
doing information extraction.
Google might be using some other
techniques, but I'm just saying that
regular expression
is one of the techniques that you can
use
for information extraction. The other
problem that we looked at was
if you search for Elon Musk
on the right hand side it shows you the
all that information and the key
information.
This is also
using a regular expression and we looked
at this particular use case in in this
particular video. So if you have not seen
this video, please see it.
And the regular expression approach
is basically
Rules and Heuristic.
So that's a first technique.
This doesn't involve any machine
learning, deep learning, nothing. It's just
basically rules and heuristic that you
solve,
that you use to solve a given problem.
The other popular use case in NLP is
text classification which is spam
detection.
So here is another a real email from my
gmail
where
you know someone sent me an email saying
that there is 55 million dollar lying in
an account and I should claim it.
And they
detect some keywords. Here say you see
urgent business assistance.
Then usd 55 million,
no one is giving you 55 million for free
and the email comes from some personal
gmail address. And these are the
indication that it could be a spam.
And the way
the spam detection can work in a
primitive way is you take the text from
your email,
you convert it to
a number vector because machine learning
models don't understand text. You have to
convert it to number and count
vectorizer is one of the techniques. Now
if you don't know about count vectorizer,
don't worry!
I have a video for it. So if you go to
youtube
and
search for Codebasics Naive bayes,
you'll find my two videos and if you
look at the second video, I have talked
about
uh the count vectorizer. So you see, you
take each of the words and you count or
the occurrence of those words in a given
document.
Again if you don't understand don't
worry about it. Just think in your head
that there is some way to convert text
into numbers okay?
And you feed that to a Naive Bayes
classifier. So Naive Bayes classifier is
a statistical
machine learning technique
that can be used for classification
purpose. And in that particular video, I
use count vectorizer and Naive Bayes
classifier for doing spam detection.
Now if you look at the pipeline of this
approach, you have Raw Text, then you
have Number Vector, and you use
Statistical Machine Learning. So here
this pipeline that you're seeing is
called like NLP pipeline. So in natural
language processing pipeline
usually you will have raw text and
you will do some post
pre-processing.
There are things like lemmatization,
removing punctuations
TDF-IDF, the TF-IDF uh
vectorization technique. There are so
many techniques and we'll cover them all
all of them one by one. So don't worry
don't worry about these jargons too much.
For now just understand that
in this approach there is some way to
convert text into numbers, and there is
some other way of doing classification
by using this Naive Bayes classifier.
So that's technique number two, which is
machine learning or or you can call it
statistical
machine learning.
Now the problem with this approach
would be that the problem with the
simple count vectorizer approach would
be that
in your training sample,
let's say you have samples like this:
hurry up for an offer to win cash, the
second sentence is you won a laptop
because when you train machine learning
model you feel lot of training samples.
And after machine learning model is
trained
let's say now you give this new sentence
for prediction,
rush for this great deal to win money,
now it might not have seen all these
words rush,
money,
deal all these words,
and if you just use count vectorizer it
might not work because
then for this new text it will not
produce that number vector in accurate
way.
So you can use a deep learning technique
called sentence embedding or a word
embedding,
and we'll go over those techniques in
the future videos as well. But if you're
just curious, um I did another series on
deep learning
where I explain
about
BERT
which is Google's
transformer model,
a language model which can be used for
generating
sentence embedding. So if you look at
what is BERT if it's Google you will
find my video. I will explain
uh how this BERT works,
and then there is another video
follow-up video. So if you see those 2
videos, 46 and 47 video you will get a
good understanding of
how BERT can be used to generate
sentence embedding. And the beauty is the
way it generates sentence embedding, look
at these two centers embedding they look
kind of similar. See here is 5, here is
5.1 Here is 9 it's 9
10 10
0.3 So the numbers are
they're kind of close you know that
concept is called cosine similarity.
These 2 are cosine similar
and I have given just a dummy example so
that you understand. But the idea is you
take 2 sentences and using the
sentence embedding approach,
the numbers, the number vector you
generate is very similar. And now if you
use these 2 these vectors
into your Naive Bayes classifier,
it will accurately predict the new
sentences.
Like the accurately predict a new
sentence that it has not seen during the
training phase.
So I'm gonna
give you
a demo of hugging face.
So if you just Google
hugging face sentence transformer and if
you go here
and if you look at all the sentence
transformer, let's say I'm going to sort
it by most likes
and this is the first string
this is the first thing that I see. So
what I'm gonna do is
basically I put all this text here okay?
So
let me put this text.
I'm just gonna do the whole thing again
so that you kind of get an idea.
I love baby yoda! My baby!
Okay so
when you say compute what it is doing, it it
will
compute the sentence embedding for the
first one and then it will compute the
sentence embedding for these 3. We
are comparing these 3 with the first
one and then it will say how similar
they are. It uses a concept of cosine
similarity
and if you don't know about cosine
similarity, you can search
codebasics cosine similarity.
I have explained in a very simple
language as if like a high school
student can understand it easily, what is
cosine similarity.
So now here look at this
what this is saying is hurry up for an
offer to win cash is kind of matching
with this. See there is 70%
similarity between these 2 sentences.
But I love baby yoda, Me coming to India
right? Like I
love paratha
let's see.
I love paratha, oh my god 0.006
There is no similarity between
paratha and winning cash and hurry up.
Oh by the way if you win cash, you can
buy a lot of paratha. But anyways you get
an idea.
So these sentence
embedders
are based on deep learning techniques. So
that's the
third technique. Okay so just to
summarize there are three broad category
of techniques to solve any NLP problem.
Rules and Heuristics, Machine Learning and
Deep learning. Hope you like this video.
If you did please give it a thumbs up.
I I have taken a lot of inspiration for
this series from my friend Anuj Gupta's
book,
The Practical
Natural Language Processing and I'm
gonna provide a link of that book in a
video description below. I will see you
in the next video.