AI Foundations
NLP - Natural Language Processing
PRESENTED BY:- SOMIL AGRAWAL
What is NLP ?
NLP stands for "Natural Language Processing," which is a subfield of Artificial Intelligence (AI) that focuses on enabling computers to understand and generate human language, utilizing techniques from both Machine Learning (ML) and Deep Learning (DL) to achieve this goal
What are the prerequisites ?
NLP Pipeline
Data Acquisition
Text Processing
I am - i m
You - u
laughing out loud - lol 😂
Text Processing
Basic Processing
Text Processing
Advanced Processing
[ I ] wrote scripts for most of [ my ] plays.
Stemming vs Lemmatization
POS Tagging (part-of-speech)
Synatctic Analysis
Feature Engineering
How to engineer features ?
Examples..
Word Embedding
Text Processing
Common Terms
Corpus -> Whole dataset
Vocabulary -> All the unique words in the corpus
Document -> Piece of text in the corpus, maybe a sentence. Usually a single training example
Word -> each group of letters in document, i.e a normal word.
One Hot Vector
One Hot Vector
Bag Of Words
N-Grams
Instead of treating each word separate, what if we treat them in a group of 2, 3 or N
TF-IDF
Word2Vec
CBOW (Continuous Bag of Words)
google dream company software engineer
-> google dream company
-> dream company software
-> company software engineer
Skip-gram
google dream company software engineer
-> google dream company
-> dream company software
-> company software engineer
Where are the embeddings ?
Other Embeddings
Playing With Embedding
Modelling
Naive Bayes Classifier
Bayes Theorem (Mathematics)
Naive Bayes Classifier
Email ID | Free | Win | Money | BUY | Spam ? |
1 | Yes | Yes | Yes | No | Spam |
2 | No | Yes | No | Yes | Not-Spam |
3 | Yes | No | Yes | No | Spam |
4 | No | No | No | Yes | Not-Spam |
5 | No | Yes | No | No | Spam |
Naive Bayes Classifier
Email ID | Free | Win | Money | BUY | Spam ? |
1 | Yes | Yes | Yes | No | Spam |
2 | No | Yes | No | Yes | Not-Spam |
3 | Yes | No | Yes | No | Spam |
4 | No | No | No | Yes | Not-Spam |
5 | No | Yes | No | No | Spam |
Naive Bayes Classifier
New Sentence. “Win Free Money”
Naive Bayes Classifier
New Sentence. “Win Free Money”
Naive Bayes Classifier
RNN (Recurrent Neural Network)
RNN (Recurrent Neural Network)
Meant to be worked with sequential data, for example textual data, time-series data, or speech, etc.
Why ?
-> We lose sequence information in ANN
-> Unnecessary padding is done to maintain the input size to the ANN model - Thus computation wasted
-> Bad at prediction for sequential information.
Input to RNN :-
Input to RNN is of the form, (timestamp, features)
e.g. Text - My name is Somil
Is of size (4,d) where d is the no. of dimension in the embedding vector.
RNN (Recurrent Neural Network)
RNN (Recurrent Neural Network)
New Sentence. “Everybody(x1) Loves(x2) Chocolate(x3)”
RNN (Recurrent Neural Network)
Problems:-
-> Forgets long context
-> Vanishing Gradients during
backpropagation
Variations:-