Natural Language Processing (NLP)
Natural Language Processing (NLP)
A COMPLETE GUIDE TO
Natural Language Processing
Last updated on Jan 11, 2023
TABLE OF CONTENTS
Introduction
What is Natural Language Processing (NLP)
Why Does Natural Language Processing (NLP) Matter?
What is Natural Language Processing (NLP) Used For?
How Does Natural Language Processing (NLP) Work?
Top Natural Language Processing (NLP) Techniques
Six Important Natural Language Processing (NLP) Models
Programming Languages, Libraries, And Frameworks For Natural Language Processing
(NLP)
Controversies Surrounding Natural Language Processing (NLP)
How To Get Started In Natural Language Processing (NLP)
Conclusion
https://www.deeplearning.ai/resources/natural-language-processing/ 1/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
RELEVANT COURSES
Natural Language Processing Specialization
Machine Learning Specialization
Deep Learning Specialization
Introduction
Natural Language Processing (NLP) is one of the hottest areas of artificial intelligence
(AI) thanks to applications like text generators that compose coherent essays,
chatbots that fool people into thinking they’re sentient, and text-to-image programs
that produce photorealistic images of anything you can describe. Recent years have
brought a revolution in the ability of computers to understand human languages,
programming languages, and even biological and chemical sequences, such as DNA
and protein structures, that resemble language. The latest AI models are unlocking
these areas to analyze the meanings of input text and generate meaningful,
expressive output.
https://www.deeplearning.ai/resources/natural-language-processing/ 2/24
Why Does Natural Language Processing (NLP) Matter?
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
NLP is an integral part of everyday life and becoming more so as language technology
is applied to diverse fields like retailing (for instance, in customer service chatbots)
and medicine (interpreting or summarizing electronic health records). Conversational
agents such as Amazon’s Alexa and Apple’s Siri utilize NLP to listen to user queries
and find answers. The most sophisticated such agents — such as GPT-3, which was
recently opened for commercial applications — can generate sophisticated prose on
a wide variety of topics as well as power chatbots that are capable of holding
coherent conversations. Google uses NLP to improve its search engine results, and
social networks like Facebook use it to detect and filter hate speech.
NLP is growing increasingly sophisticated, yet much work remains to be done.
Current systems are prone to bias and incoherence, and occasionally behave
erratically. Despite the challenges, machine learning engineers have many
opportunities to apply NLP in ways that are ever more central to a functioning society.
https://www.deeplearning.ai/resources/natural-language-processing/ 3/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
Toxicity classification is a branch of sentiment analysis where the aim is not just
to classify hostile intent but also to classify particular categories such as threats,
insults, obscenities, and hatred towards certain identities. The input to such a
model is text, and the output is generally the probability of each class of toxicity.
Toxicity classification models can be used to moderate and improve online
conversations by silencing offensive comments, detecting hate speech, or
scanning documents for defamation.
Machine translation automates translation between different languages. The
input to such a model is text in a specified source language, and the output is the
text in a specified target language. Google Translate is perhaps the most famous
mainstream application. Such models are used to improve communication
between people on social-media platforms such as Facebook or Skype. Effective
approaches to machine translation can distinguish between words with similar
meanings. Some systems also perform language identification; that is, classifying
text as being in one language or another.
Named entity recognition aims to extract entities in a piece of text into
predefined categories such as personal names, organizations, locations, and
quantities. The input to such a model is generally text, and the output is the
various named entities along with their start and end positions. Named entity
recognition is useful in applications such as summarizing news articles and
combating disinformation. For example, here is what a named entity recognition
model could provide:
https://www.deeplearning.ai/resources/natural-language-processing/ 4/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
https://www.deeplearning.ai/resources/natural-language-processing/ 5/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
https://www.deeplearning.ai/resources/natural-language-processing/ 6/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
Tokenization splits text into individual words and word fragments. The result
generally consists of a word index and tokenized text in which words may be
represented as numerical tokens for use in various deep learning methods. A
method that instructs language models to ignore unimportant tokens can
improve efficiency.
https://www.deeplearning.ai/resources/natural-language-processing/ 9/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
Inverse Document Frequency: How important is the term in the whole corpus?
IDF(word in a corpus)=log(number of documents in the corpus / number of
documents that include the word)
A word is important if it occurs many times in a document. But that creates a problem.
Words like “a” and “the” appear often. And as such, their TF score will always be high.
We resolve this issue by using Inverse Document Frequency, which is high if the word
is rare and low if the word is common across the corpus. The TF-IDF score of a term
is the product of TF and IDF.
https://www.deeplearning.ai/resources/natural-language-processing/ 10/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
and predicts based on which joint distribution has the highest probability. The naive
assumption in the Naive Bayes model is that the individual words are independent.
Thus:
P(text|label) = P(word_1|label)*P(word_2|label)*…P(word_n|label)
https://www.deeplearning.ai/resources/natural-language-processing/ 12/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
In NLP, such statistical methods can be applied to solve problems such as spam
detection or finding bugs in software code.
Decision trees are a class of supervised classification models that split the
dataset based on different features to maximize information gain in those splits.
Latent Dirichlet Allocation (LDA) is used for topic modeling. LDA tries to view a
document as a collection of topics and a topic as a collection of words. LDA is a
statistical approach. The intuition behind it is that we can describe any topic
using only a small set of words from the corpus.
Hidden Markov models: Markov models are probabilistic models that decide the
next state of a system based on the current state. For example, in NLP, we might
suggest the next word based on the previous word. We can model this as a
Markov model where we might find the transition probabilities of going from
word1 to word2, that is, P(word1|word2). Then we can use a product of these
transition probabilities to find the probability of a sentence. The hidden Markov
model (HMM) is a probabilistic modeling technique that introduces a hidden state
to the Markov model. A hidden state is a property of the data that isn’t directly
observed. HMMs are used for part-of-speech (POS) tagging where the words of
a sentence are the observed states and the POS tags are the hidden states. The
HMM adds a concept called emission probability; the probability of an
https://www.deeplearning.ai/resources/natural-language-processing/ 13/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
observation given a hidden state. In the prior example, this is the probability of a
word, given its POS tag. HMMs assume that this probability can be reversed:
Given a sentence, we can calculate the part-of-speech tag from each word
based on both how likely a word was to have a certain part-of-speech tag and
the probability that a particular part-of-speech tag follows the part-of-speech
tag assigned to the previous word. In practice, this is solved using the Viterbi
algorithm.
https://www.deeplearning.ai/resources/natural-language-processing/ 14/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
Recurrent Neural Network (RNN): Many techniques for text classification that use
deep learning process words in close proximity using n-grams or a window
(CNNs). They can see “New York” as a single instance. However, they can’t
capture the context provided by a particular text sequence. They don’t learn the
sequential structure of the data, where every word is dependent on the previous
word or a word in the previous sentence. RNNs remember previous information
using hidden states and connect it to the current task. The architectures known
as Gated Recurrent Unit (GRU) and long short-term memory (LSTM) are types of
RNNs designed to remember information for an extended period. Moreover, the
bidirectional LSTM/GRU keeps contextual information in both directions, which is
helpful in text classification. RNNs have also been used to generate mathematical
proofs and translate human thoughts into words.
https://www.deeplearning.ai/resources/natural-language-processing/ 15/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
https://www.deeplearning.ai/resources/natural-language-processing/ 16/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
https://www.deeplearning.ai/resources/natural-language-processing/ 17/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
https://www.deeplearning.ai/resources/natural-language-processing/ 18/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
spaCy is one of the most versatile open source NLP libraries. It supports
more than 66 languages. spaCy also provides pre-trained word vectors and
implements many popular models like BERT. spaCy can be used for building
production-ready systems for named entity recognition, part-of-speech
tagging, dependency parsing, sentence segmentation, text classification,
lemmatization, morphological analysis, entity linking, and so on.
Deep Learning libraries: Popular deep learning libraries include TensorFlow
and PyTorch, which make it easier to create models with features like
automatic differentiation. These libraries are the most common tools for
developing NLP models.
Hugging Face offers open-source implementations and weights of over 135
state-of-the-art models. The repository enables easy customization and
training of the models.
Gensim provides vector space modeling and topic modeling algorithms.
R: Many early NLP models were written in R, and R is still widely used by data
scientists and statisticians. Libraries in R for NLP include TidyText, Weka,
Word2Vec, SpaCyR, TensorFlow, and PyTorch.
Many other languages including JavaScript, Java, and Julia have libraries that
implement NLP methods.
https://www.deeplearning.ai/resources/natural-language-processing/ 21/24
How To Get Started In Natural Language Processing
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
(NLP)
If you are just starting out, many excellent courses can help.
COURSE COURSE
Machine Learning Deep Learning
Specialization Specialization
A foundational set of three An intermediate set of five
courses that introduces beginners courses that help learners get
to the fundamentals of learning hands-on experience building and
algorithms. Prerequisites include deploying neural networks, the
high-school math and basic technology at the heart of today’s
programming skills most advanced NLP and other
sorts of AI models.
View Course View Course
COURSE
Natural Language
Processing
Specialization
An intermediate set of four
courses that provide learners with
the theory and application behind
the most relevant and widely used
NLP models.
View Course
If you want to learn more about NLP, try reading research papers. Work through the
papers that introduced the models and techniques described in this article. Most are
easy to find on arxiv.org. You might also take a look at these resources:
https://www.deeplearning.ai/resources/natural-language-processing/ 22/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
The Batch : A weekly newsletter that tells you what matters in AI. It’s the best way
to keep up with developments in deep learning.
NLP News: A newsletter from Sebastian Ruder, a research scientist at Google,
focused on what’s new in NLP.
Papers with Code: A web repository of machine learning research, tasks,
benchmarks, and datasets.
We highly recommend learning to implement basic algorithms (linear and logistic
regression, Naive Bayes, decision trees, and vanilla neural networks) in Python. The
next step is to take an open-source implementation and adapt it to a new dataset or
task.
Conclusion
NLP is one of the fast-growing research domains in AI, with applications that involve
tasks including translation, summarization, text generation, and sentiment analysis.
Businesses use NLP to power a growing number of applications, both internal — like
detecting insurance fraud, determining customer sentiment, and optimizing aircraft
maintenance — and customer-facing, like Google Translate.
Aspiring NLP practitioners can begin by familiarizing themselves with foundational AI
skills: performing basic mathematics, coding in Python, and using algorithms like
decision trees, Naive Bayes, and logistic regression. Online courses can help you build
your foundation. They can also help as you proceed into specialized topics.
Specializing in NLP requires a working knowledge of things like neural networks,
frameworks like PyTorch and TensorFlow, and various data preprocessing techniques.
The transformer architecture, which has revolutionized the field since it was
introduced in 2017, is an especially important architecture.
NLP is an exciting and rewarding discipline, and has potential to profoundly impact
the world in many positive ways. Unfortunately, NLP is also the focus of several
controversies, and understanding them is also part of being a responsible
practitioner. For instance, researchers have found that models will parrot biased
language found in their training data, whether they’re counterfactual, racist, or
hateful. Moreover, sophisticated language models can be used to generate
disinformation. A broader concern is that training large models produces substantial
greenhouse gas emissions.
https://www.deeplearning.ai/resources/natural-language-processing/ 23/24
6/20/24, 10:28 PM Natural Language Processing (NLP) [A Complete Guide]
This page is only a brief overview of what NLP is all about. If you have an appetite for
more, DeepLearning.AI offers courses for everyone in their NLP journey, from AI
beginners and those who are ready to specialize. No matter your current level of
expertise or aspirations, remember to keep learning!
https://www.deeplearning.ai/resources/natural-language-processing/ 24/24