Python Chat Bot Tutorial - AI Chatbot with Deep Learning (BONUS)

Tech With Tim · Beginner ·🧠 Large Language Models ·7y ago

Key Takeaways

This video tutorial demonstrates how to build a chatbot using Python and deep learning, with a focus on adding confidence to the bot's responses and handling errors. The tutorial covers topics such as intent recognition, response generation, and confidence thresholds, using tools like Discord and Python.

Full Transcript

hey guys and welcome to part 5 of our AI chat bot series now this is just gonna be a shorter kind of bonus episode that's giving you guys some extra information about the chat bot show you a few examples of how to actually use it some of its limitations and just really a little bit more info for those of you that are interested I don't expect everyone to watch this video but if you are I expect to just kind of understand maybe how to use this in a more advanced way and a little bit more info on kind of how it works and some of the things I feel like I skipped over in the other videos so without further ado let's get started now the first thing I'm gonna show you is just a way that I've decided to use this chat bot so you guys can maybe get an idea of kind of the use that you can use it for so I have this disc word server I think I have like almost a thousand people in here or something now and I get asked the same questions all the time whether that be on my YouTube in the comments section Twitter Instagram whatever but a lot of people ask me these questions on discord so I decided to make an FAQ chat that implements the chat bot model that we just discussed now it's similar to the first chaplain I showed you guys at the beginning but I've added a few more responses and I'll just show you how it works here quickly so you can get idea so for example if I say hello and then I tag the bot we should get a response in a second it says hello if I say like what's up at pot it says creating the singularity just some funny stuff for now but then if I ask questions like what is your age and again we're treating the bot kind of as if it's me responding to you so we'll say at but you see 18 years young if I say like where do you go to school but then you see I'm you in university for computer science so there's just a bunch of different responses for simple questions like that and I don't know it's kind of cool it's fun to see people go on and kind of mess with the chat BOTS and sometimes it makes mistakes and it doesn't have answers for everything but obviously if you see questions that are asked a lot you can go ahead and just add a new intent for that retrain the bots and that's kind of what I've been doing as I go through here I'm trying to think of any other questions that I can show you guys I think some people ask me like when did you start coding I don't know if I program one for this let's see the app but and I've been coding for six years started when I was 12 years old so you guys kind of get the point on that so anyways that is kind of an example of how I decided to use the bots you guys can throw that on discord server Facebook bought whatever you want to use it for but now I just want to show you actually let me show you with this example to is something I've done is sometimes you're gonna get asked a question that doesn't make any sense and rather than just picking the closest answer or like whatever the bot thinks it is we probably want to give the user like ask another question or like I don't quite understand so for example if I say like I don't understand well that's not really a question and I definitely didn't program anything to respond to this so let's just see what we get so I say I don't understand it says I don't quite understand try again or ask a different question if I ask like do you like to use Java at BOTS let's see if we get that - okay so this one was a mistake but like if I ask questions that don't really make any sense the bot doesn't have a high degree of confidence in it should hopefully give us a response that looks like that and that's what I'm gonna show you guys how to do here quickly I want to try to ask another question that will prove this what just say do you know awesome tuts this is just a guy on YouTube that I've been talking to recently so I just said do that and I don't quite understand try again or ask a different questions so since it didn't have a response for that it hopefully picked this one and then said I don't try I don't understand rather than just giving us some gibberish random answer right okay so anyways let's show how we can do that so for those of you that didn't kind of pick up on this before what essentially happens with our chat bot is we returned a list of probabilities and those are the probabilities on like how probable it thinks for example it is the hello intent or the goodbye intent or all those different classes or labels are intense or whatever we call them right so what we can actually do is we can look at the specific value that was returned to us and determine whether or not that is high enough for us to deem an acceptable response so for example we might get a bunch of different probabilities and they might have like one probabilities like 20% ones 10 another 10 and others 10 and others 10 another 10 and the highest probability is only 20% well yes that is the most probable answer for a chatbot but does it make sense probably not and you can tell that because the bot is kind of having a hard time deciding between all of the different responses so let me print this out just to show you guys what I mean by this so if I print results here and I'm just gonna run the kind of console version on my bought which I had before which doesn't actually have all the same responses as before such as activate chat chat but if I spell chat bot correctly it's CD 2 desktop CD 2 simple chat bot coffee and we'll just go Python me and up alright um so now you should see in a second once this loads up and does it this thing and I start typing to it that it asked me what do you call it or it prints out the probabilities for any given response so just give me a second here I don't know what's happening here umm okay so this is retraining the model for some reason anyways we'll wait for that to finish ok so start talking so now if I say like hello you can see that it prints out a list of probabilities now see that we have a probability it's like 1.1 7.0 e to the negative 2 like all these just different numbers and this is the list of probabilities so essentially what we're gonna do is we're gonna look at all these numbers we're gonna find the greatest number and then that's the response that we're going to return and that's exactly what this line has done right results index equals numpy to art Max results we just means pick the index of the largest number in here essentially so now what we're gonna do is actually look at that number and say okay is this above a certain threshold is it above maybe 70% or 80% or whatever it is if it is then we will do the correct response otherwise we'll say you know this doesn't make any sense like asking only question or something better or I don't understand something so that the user feels like the bot is maybe a little bit smarter and it's not just giving us a random answer so let's quit yes if I can get out of that and now what I'm gonna do is actually look at this value and just do a little if statement say you know if whatever so let's do that so what I'm gonna do first actually is I'm gonna change this just to zero so I'm gonna put a zero here which just means like pick the first list cuz it gives us a list of lists for all of our different probabilities and then what I'm gonna do here is I'm going to say if let's say here if results and then results index is greater than 0.7 which means 70% confidence so we get at least 70% as that value then we'll go ahead and we'll print one of those random responses from the appropriate tag otherwise we'll simply print I didn't get that and you can put whatever you want here obviously didn't get that try again or something though right so now this way when we ask a question that the bots not sure of it's gonna say okay well I didn't really get that try again and then the users gonna feel like it makes more sense so let's run this one more time Python maned up hi this usually takes a second to get going here I don't know why it keeps retraining the model anyways I think I like messed up something in the try statement here to make it do that oh I did I just put Tim - up high so we do that every time anyways let's type something so if I type like this makes no sense I didn't get that try again if I go hello then obviously I'm gonna get the answer and you can see that it's kind of how that works so anyways this kind of been like a little bonus video it's not super I don't know crazy but for any of you that wanted to know how to do this to get an error threshold I saw some people asking about it there you go and you know a cool little example of how this FAQ bot works if you want to test it out yourself feel free to join my discord server just come on here go to FAQ and start talking with the bots and obviously you can talk any other channels and talk to me as well so if you guys enjoyed the video please make sure leave a like and subscribe and if you have any ideas for other series that you'd like to see please leave a comment down below and I'll be sure to consider those going forward

Original Description

This is just a quick bonus video for any of you interested in some of the applications of the chat bot. I show you how I've used it in my discord server and how to add whats known as a confidence for our bots responses. This way when the bot can give an reasonable answer if its not sure what the user is saying. Playlist: https://www.youtube.com/watch?v=wypVcNIH6D4&list=PLzMcBGfZo4-ndH9FoC4YWHGXG5RZekt-Q ◾◾◾◾◾ 💻 Enroll in The Fundamentals of Programming w/ Python https://tech-with-tim.teachable.com/p... 📸 Instagram: https://www.instagram.com/tech_with_tim 🌎 Website https://techwithtim.net 📱 Twitter: https://twitter.com/TechWithTimm ⭐ Discord: https://discord.gg/pr2k55t 📝 LinkedIn: https://www.linkedin.com/in/tim-rusci... 📂 GitHub: https://github.com/techwithtim 🔊 Podcast: https://anchor.fm/tech-with-tim 💵 One-Time Donations: https://www.paypal.com/donate/?token=... 💰 Patreon: https://www.patreon.com/techwithtim ◾◾◾◾◾◾ ⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡ Tags: - Tech With Tim - Python Tutorials - Python AI Chatot - AI chat bot tutorial
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Tech With Tim · Tech With Tim · 0 of 60

← Previous Next →
1 A* Path Finding Algorithm(Visualization)
A* Path Finding Algorithm(Visualization)
Tech With Tim
2 Python Programming Tutorial #1 - Variables and Data Types
Python Programming Tutorial #1 - Variables and Data Types
Tech With Tim
3 Python Programming Tutorial #2 - Basic Operators and Input
Python Programming Tutorial #2 - Basic Operators and Input
Tech With Tim
4 Python Programming Tutorial #3 - Conditions
Python Programming Tutorial #3 - Conditions
Tech With Tim
5 Python Programming Tutorial #4 - IF/ELIF/ELSE
Python Programming Tutorial #4 - IF/ELIF/ELSE
Tech With Tim
6 Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Tech With Tim
7 Python Programming Tutorial #6 - For Loops
Python Programming Tutorial #6 - For Loops
Tech With Tim
8 Python Programming Tutorial #7 - While Loops
Python Programming Tutorial #7 - While Loops
Tech With Tim
9 Python Programming Tutorial #8 - Lists and Tuples
Python Programming Tutorial #8 - Lists and Tuples
Tech With Tim
10 Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Tech With Tim
11 Python Programming Tutorial #10 - String Methods
Python Programming Tutorial #10 - String Methods
Tech With Tim
12 How to Overclock a NVIDIA GPU
How to Overclock a NVIDIA GPU
Tech With Tim
13 Python Programming Tutorial #11 - Slice Operator
Python Programming Tutorial #11 - Slice Operator
Tech With Tim
14 Python Programming Tutorial #12 - Functions
Python Programming Tutorial #12 - Functions
Tech With Tim
15 Python Programming Tutorial #13 - How to Read a Text File
Python Programming Tutorial #13 - How to Read a Text File
Tech With Tim
16 Python Programming Tutorial #14 - Writing to a Text File
Python Programming Tutorial #14 - Writing to a Text File
Tech With Tim
17 Python Programming Tutorial #15 - Using .count() and .find()
Python Programming Tutorial #15 - Using .count() and .find()
Tech With Tim
18 Python Programming Tutorial #16 - Introduction to Modular Programming
Python Programming Tutorial #16 - Introduction to Modular Programming
Tech With Tim
19 Python Programming Tutorial #17 - Optional Parameters
Python Programming Tutorial #17 - Optional Parameters
Tech With Tim
20 Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Tech With Tim
21 Python Programming Tutorial #19 - Global vs Local Variables
Python Programming Tutorial #19 - Global vs Local Variables
Tech With Tim
22 Python Programming Tutorial #20 - Classes and Objects
Python Programming Tutorial #20 - Classes and Objects
Tech With Tim
23 Cool VBS Script to Prank Your Friends!
Cool VBS Script to Prank Your Friends!
Tech With Tim
24 How to Overclock an AMD GPU
How to Overclock an AMD GPU
Tech With Tim
25 Best GPU'S For Mining Ethereum (2018)
Best GPU'S For Mining Ethereum (2018)
Tech With Tim
26 Recursion and Memoization Tutorial Python
Recursion and Memoization Tutorial Python
Tech With Tim
27 Ethereum Mining Rig - Hardware Guide
Ethereum Mining Rig - Hardware Guide
Tech With Tim
28 Pygame Tutorial #1 - Basic Movement and Key Presses
Pygame Tutorial #1 - Basic Movement and Key Presses
Tech With Tim
29 How to Install Pygame (Windows 8/10)
How to Install Pygame (Windows 8/10)
Tech With Tim
30 How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
Tech With Tim
31 How to Mine Ethereum 2018 - WORKING (Super-Easy)
How to Mine Ethereum 2018 - WORKING (Super-Easy)
Tech With Tim
32 Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Tech With Tim
33 Pygame Tutorial #2 - Jumping and Boundaries
Pygame Tutorial #2 - Jumping and Boundaries
Tech With Tim
34 Pygame Tutorial #3 - Character Animation & Sprites
Pygame Tutorial #3 - Character Animation & Sprites
Tech With Tim
35 Pygame Tutorial #4 - Optimization & OOP
Pygame Tutorial #4 - Optimization & OOP
Tech With Tim
36 OBS Studio Tutorial - Best OBS Settings
OBS Studio Tutorial - Best OBS Settings
Tech With Tim
37 Linear Search Algorithm - Python Example and Code
Linear Search Algorithm - Python Example and Code
Tech With Tim
38 Make Any Mic Sound AMAZING! (WITH OBS)
Make Any Mic Sound AMAZING! (WITH OBS)
Tech With Tim
39 Binary Search Algorithm - Python Example & Code
Binary Search Algorithm - Python Example & Code
Tech With Tim
40 Pygame Tutorial #5 - Projectiles
Pygame Tutorial #5 - Projectiles
Tech With Tim
41 Pygame Game - Mini Golf
Pygame Game - Mini Golf
Tech With Tim
42 Pygame Tutorial - Projectile Motion (Part 1)
Pygame Tutorial - Projectile Motion (Part 1)
Tech With Tim
43 Pygame Tutorial - Projectile Motion (Part 2)
Pygame Tutorial - Projectile Motion (Part 2)
Tech With Tim
44 Pygame Tutorial #6 - Enemies
Pygame Tutorial #6 - Enemies
Tech With Tim
45 Pygame Tutorial #7 - Collision and Hit Boxes
Pygame Tutorial #7 - Collision and Hit Boxes
Tech With Tim
46 Pygame Tutorial #8 - Scoring and Health Bars
Pygame Tutorial #8 - Scoring and Health Bars
Tech With Tim
47 Cloud Mining vs. Hardware Mining - 2018
Cloud Mining vs. Hardware Mining - 2018
Tech With Tim
48 How to Install Pygame on Mac OSX (Fast-Simple)
How to Install Pygame on Mac OSX (Fast-Simple)
Tech With Tim
49 Pygame Tutorial #9 - Sound Effects, Music & More Collision
Pygame Tutorial #9 - Sound Effects, Music & More Collision
Tech With Tim
50 Pygame Tutorial #10 - Finishing Touches & Next Steps
Pygame Tutorial #10 - Finishing Touches & Next Steps
Tech With Tim
51 How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
Tech With Tim
52 How to Create a Button in Pygame [CODE IN DESCRIPTION]
How to Create a Button in Pygame [CODE IN DESCRIPTION]
Tech With Tim
53 Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Tech With Tim
54 Pygame Side-Scroller Tutorial #2 - Random Object Generation
Pygame Side-Scroller Tutorial #2 - Random Object Generation
Tech With Tim
55 Pygame Side-Scroller Tutorial #3 - Collision
Pygame Side-Scroller Tutorial #3 - Collision
Tech With Tim
56 Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Tech With Tim
57 How to Create A Message Box in Python - Tkinter
How to Create A Message Box in Python - Tkinter
Tech With Tim
58 Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Tech With Tim
59 How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
Tech With Tim
60 Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Tech With Tim

This video tutorial teaches you how to build a chatbot using Python and deep learning, with a focus on adding confidence to the bot's responses and handling errors. You'll learn how to use tools like Discord and Python to create a chatbot that can answer frequently asked questions and provide reasonable answers when it's not sure what the user means. The tutorial also covers topics such as intent recognition, response generation, and confidence thresholds.

Key Takeaways
  1. Add responses to the chatbot model
  2. Retrain the chatbot model to add new intents and answers
  3. Print the list of probabilities returned by the chatbot
  4. Determine the index of the largest number in the list
  5. Check if the confidence is above a certain threshold
  6. Return a response based on the confidence level
  7. Run the code
  8. Type a question to the chatbot
  9. Check the confidence threshold
  10. Print a default message if the confidence is below the threshold
💡 Using a confidence threshold can help improve the accuracy of a chatbot's responses and prevent it from providing incorrect information.

Related AI Lessons

How We Translate 300-Page Books Using Claude Without Hitting Token Limits
Learn how to translate long documents using Claude without hitting token limits by breaking them into overlapping chunks
Dev.to · 龚旭东
Building HITL Feedback RAG: Embeddings, Retrieval, and Reranking
Learn to build a Human-in-the-Loop (HITL) Feedback RAG system using embeddings, retrieval, and reranking to improve model performance
Medium · AI
Building HITL Feedback RAG: Embeddings, Retrieval, and Reranking
Learn to build a Human-in-the-Loop (HITL) Feedback RAG system using embeddings, retrieval, and reranking to improve LLM performance
Medium · LLM
A simple way to test model fallbacks with RouterBase
Learn to test model fallbacks with RouterBase using a simple fallback wrapper and OpenAI-compatible API surface
Dev.to · routerbasecom
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →