From the course: Hands-On AI: Building Your First Conversational AI Chatbot
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Upgrade 3: Handle uncertain responses with fallback mechanism
From the course: Hands-On AI: Building Your First Conversational AI Chatbot
Upgrade 3: Handle uncertain responses with fallback mechanism
- [Presenter] Chatbot can sometimes get confused. It might generate vague or incomplete replies, like, "I don't know." This usually happens when a model doesn't have enough context. The input is ambiguous, or it simply lacks the knowledge to give an answer. For example, if a user types, "What's the square root of happiness," the bot might freeze or give a non reasonable response. This is where we may consider adding fallback mechanism. A fallback is the safety net. It steps in when a model's output doesn't meet a certain standard. Instead of letting your bot sound broken, you give it a pre-written response that keeps the conversation going. It's like teaching your bot to say, "I'm not sure I got that, can you rephrase?" When it's stuck. Let's look at the code. We start with the usual setup. We store recent messages and conversation history to preserve context and keep it trimmed to the last three exchanges. We tokenize the prompt and send it to the model using ".generate" function…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.