Hi, in this lesson and the next few lessons, you will use the Hugging Face Transformers library to perform various natural language processing tasks. In this lesson, you will build your own chatbot using an open-source model built by Meta. Let's get started. We talked about natural language processing, but what is the definition? NLP is a field of linguistic and machine learning, and it is focused on everything related to human language. We saw significant progress in this field thanks to the transformer architecture from the well-known paper Attention is All You Need in 2017. And since then, this architecture is now the core of many state-of-the-art machine learning models nowadays. In this lesson, we will be using the Transformers library and, in particular, the Pipeline function. So, as you can see, I just imported the pipeline function from the Transformers library. For this classroom, the libraries have already been installed for you. If you're running this on your own machine, you can install the transformer's library by running the following. We don't need to actually run this command, so we can comment it out. Now we have everything we need to create our own chatbot. As you can see, we created the conversational pipeline using a model from Facebook called BlenderBox. We decided to use this model because the model is very small and performs quite well. We only need 1.6 gigabytes to load it. We can't use Llama 2 or any other big models since we won't be able to load it. The function, pipeline takes as the first argument the task. As you can see, we've put conversational. And for the second argument, we need to pass the model. We can't use any other big model such as Llama 2 because it will exceed the 4 gigabytes that's available in this classroom. Now that the chatbot is loaded, let's pass a user message. I will ask the chatbot what are some fun activities I can do in the winter. To pass the user message inside the chatbot, we need first to put it into a conversation object. So let's import this object. You just need to pass the user message inside the conversation object and you need everything now to pass the conversation to the chatbot. And as you can see, the assistant responded, I like snowboarding and skiing. What do you like to do in winter? Feel free to change the user message, asking for example ideas about a birthday, things to do during the summer, anything you ever wantd to ask a chatbot Now let's step back and review what other NLP tasks you can perform with open source model. You will also see how you can search the Hugging Face Hub for a suitable model for various tasks. NLP has many applications. You must have heard about ChatGPT, the OpenAI chatbot, or the open source equivalent Hugging Chat, which lets the user select any open source language model such as Llama 2 or Mistral, and converse with it. NLP is also present in many tools we use every day. We can think about auto-completion in documents, translation tools, or even spam filters. NLP has many tasks. You will go through a few of them in the next few lessons, but feel free to try the rest on your own. You will go through the text generation task to build the chatbot, sentence similarity, summarization, and machine translation. One question remains, which model should we choose? There are so many open source models. To browse the model, you can use the Hugging Face Hub. I will show you how I decided to select the Facebook model for our conversational pipeline. We go to the Hugging Face Hub on the model section. We can add filters. So we will choose the conversational task right here. Conversational task is the task of generating conversational text, that is relevant, coherent, and knowledgeable given a prompt. This model has applications in chatbots and as a port of voice assistants. As you can see right now, the models are sorted by trending. We can change that to the most liked. As you can see, we have so many different models. Since in the classroom, we can only fit four gigabytes, we need to choose a smaller model. The second model seems to be a great choice because it's quite small since it only has 400 million parameters. We see that it was downloaded a lot of times and it has a lot of likes. So let's check this one. We can go to the files. You can see that the model is only 730 megabytes. Now we can just click using transformers to learn how to load it. And this comment should be pretty familiar with you. As you can see, he's telling us to use the pipeline object to use the conversational task and load the model by putting the name of the model here. For example, let's ask the chatbot, what else do you recommend? And as you can see, the assistant answer has nothing to do with winter activities. It doesn't remember the earlier conversation. The right way to do that is to add a message to the conversation. LLMs don't naturally keep a memory of your previous messages, but when you're using transformer object, you can add follow up messages and the conversation object will keep your previous prompt as well as the LLM's response so that the LLM will converse with you as if it remembers your earlier conversation. Let's try that. As you can see, we've added a new input to our conversation. What else do you recommend to the earlier conversation? Now let's pass this conversation to our chatbot. As you can see, the assistant's answer shows some memory of the previous conversation about winter activities. The response may not be very insightful because the model is very small. There are many state-of-the-art open source models that can do quite well if you have the hardware to run them. Let's take a look at some of these on Hugging Face Hub. At Hugging Face, we have the open LLM leaderboard that enables users, companies to evaluate open source LLMs and chatbots. So let's see what are the most performing chatbots. We will only select the pre-trained ones first. The pre-trained models are models that are trained from scratch. Most of the models that you will see at the top of the leaderboard are coming from large companies since not everyone has the compute capability to train those big models. As you can see, you can see some familiar names with, for example, the new Mixtral models, the Falcon model, the Yi model, and the Qwen model. There's a lot of debate surrounding this leaderboard. People are skeptical if the benchmark we choose are representative of the performance of the models. We know that they are not perfect, but we will be adding more and more benchmarks so that we are able to evaluate fairly all the models. But if you want to have a look at another leaderboard, you can take a look at the LMSYS chatbot arena. This leaderboard collected over 200,000 human preferences votes to rank LLMs with the ELO ranking system. We have proprietary models such as GPT-4, Bard, or Claude. But as you can see in this list, we also have open source models which are quite... catching quite fast the proprietary models. As you can see here in the list, we have the Mixtral model, which has an Apache 2.0 license. What it means is that it allows you to use, modify, and distribute the models. You can commercialize it, use it everywhere. In the next lesson, we'll learn how to summarize long documents and translate text from English to French. Let's go on to the next lesson.