Build your own chatbot
using Python
muhammadaaniq100@[Link]
8RUWBI2DF5
Anirudh Rao
Great Learning
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Session Takeaways
Build your own chatbot using Python
● Introduction to chatbots
muhammadaaniq100@[Link]
8RUWBI2DF5
● Types of chatbots
● Top applications of chatbots
● Architecture of chatbots
● How does a chatbot work?
● Practical demonstration in Python
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Did you know?
Python is the world’s most popular programming language!
8RUWBI2DF5 ● Popular streaming
muhammadaaniq100@[Link]
services make use of Python extensively.
● The name Python is derived from a TV show.
● Very popular for Natural Language Processing (NLP)
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Introduction to
muhammadaaniq100@[Link]
8RUWBI2DF5 Chatbots
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Introduction to Chatbots
What are chatbots?
muhammadaaniq100@[Link]
8RUWBI2DF5
● Chatbots are simulations which can understand human language, process it
and interact back with humans while performing specific tasks.
● The first chatbot was created by Joseph Wiesenbaum in 1966, named Eliza.
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Introduction to Chatbots
History of chatbots
muhammadaaniq100@[Link]
8RUWBI2DF5
“ Can machines think like humans? ”
- Alan Turing
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Introduction to Chatbots
History of chatbots
Eliza – 1966
muhammadaaniq100@[Link]
8RUWBI2DF5 Parry – 1972
A.L.I.C.E – 1995
Smarter Child – 2001
SIRI – 2010
Google Now – 2012
Alexa - 2015
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
muhammadaaniq100@[Link]
8RUWBI2DF5 Types of Chatbots
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Types of Chatbots
Important types:
muhammadaaniq100@[Link]
8RUWBI2DF5
Text-based chatbots Voice-based chatbots
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Types of Chatbots
Chatbots are designed using these approaches:
Rule-based
muhammadaaniq100@[Link] Chatbot: Bot answers questions based on some rules on which
8RUWBI2DF5
it is trained on. The rules defined can be very simple to very complex.
Self-learning Chatbot: Bot that learns how to communicate using the result
of a machine learning model to learn and assess current situation.
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
muhammadaaniq100@[Link]
Top applications
of chatbots
8RUWBI2DF5
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Top applications of chatbots
Hundreds of applications today
muhammadaaniq100@[Link]
8RUWBI2DF5
Helpdesk assistant Email distributor Home assistant
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Top applications of chatbots
Hundreds of applications today
muhammadaaniq100@[Link]
8RUWBI2DF5
Operations assistant Phone assistant Entertainment assistant
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
muhammadaaniq100@[Link]
Architecture
of chatbots
8RUWBI2DF5
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Architecture of chatbots
A typical chatbot architecture should consist of:
muhammadaaniq100@[Link]
8RUWBI2DF5
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
How does a chatbot work?
muhammadaaniq100@[Link]
8RUWBI2DF5
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
How does a chatbot work?
Very important steps:
1. Import corpus
muhammadaaniq100@[Link]
8RUWBI2DF5 2. Preprocess the data
3. Text case handling
4. Tokenization
5. Stemming
6. Bag of Words (BOW)
7. One hot encoding
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
How does a chatbot work?
Corpus:
muhammadaaniq100@[Link]
8RUWBI2DF5
● Corpus is the training data needed for the chatbot to learn.
● Without a corpus, it is impossible for a chatbot to learn and reply
something useful back to the user.
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
How does a chatbot work?
Data preprocessing - text case handling:
muhammadaaniq100@[Link]
8RUWBI2DF5
● Convert all the data coming as an input to either upper or lower case.
● This will avoid misrepresentation and misinterpretation of words if
spelt under lower or upper cases.
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
How does a chatbot work?
Tokenization:
muhammadaaniq100@[Link]
8RUWBI2DF5
Tokenization is the structured process of converting
a sentence into individual collection of words.
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
How does a chatbot work?
Stemming:
muhammadaaniq100@[Link]
8RUWBI2DF5
Stemming is a process of finding similarities
between words with the same root words.
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
How does a chatbot work?
Generating Bag Of Words (BOW):
muhammadaaniq100@[Link]
8RUWBI2DF5
Process of converting words into numbers by generating
vector embeddings from the tokens generated.
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
How does a chatbot work?
One hot encoding:
muhammadaaniq100@[Link]
8RUWBI2DF5
One hot encoding is a process by which categorical variables
are converted into a form that ML algorithms use.
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.
Practical demonstration
muhammadaaniq100@[Link]
using Python
8RUWBI2DF5
Proprietary
This file iscontent.
meant © Great Learning. Alluse
for personal Rights
byReserved. Unauthorized use or distribution prohibited.
muhammadaaniq100@[Link] only.
Sharing or publishing the contents in part or full is liable for legal action.