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.
Generating responses with Transformers model
From the course: Hands-On AI: Building Your First Conversational AI Chatbot
Generating responses with Transformers model
- [Narrator] In this video, we are going to complete our chat bot by generating the model's response, and then converting it back into a human readable form. Up to this point, we've handled user input, tokenized it, and kept track of chat history. Now we are going to use that input to ask the model to generate a reply. Here's the code. Chat history IDs = model.generate bot input IDs max length equals 1,000 path token ID equals tokenizer.eos token ID. Let's break it down. We are calling the generate method on a model. This is a built-in method provided by Hugging Faces Transformers Library. It's a very powerful function because it handles the core process of generating natural language based on an input sequence. Essentially, the model looks at the tokens we provided, which represent our current conversation, including past messages, if any, and predicts what tokens or words should come next. The generate method outputs a list of token IDs, which is the model's version of a response…
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.