|
| 1 | +--- |
| 2 | +title: AI Notebooks - Tutorial - Create and train a Rasa chatbot |
| 3 | +slug: notebooks/create-rasa-chatbot |
| 4 | +excerpt: Understand how to create and train a chatbot with AI Notebooks |
| 5 | +section: AI Notebooks - Tutorials |
| 6 | +order: 10 |
| 7 | +updated: 2023-03-20 |
| 8 | +routes: |
| 9 | + canonical: 'https://docs.ovh.com/gb/en/publiccloud/ai/notebooks/create-rasa-chatbot/' |
| 10 | +--- |
| 11 | + |
| 12 | +**Last updated 20th March, 2023.** |
| 13 | + |
| 14 | +## Objective |
| 15 | + |
| 16 | +The aim of the tutorial is to understand how to create and train a chatbot model with AI Notebooks. We will create and train the chatbot with a Visual Studio Code notebook. At the end of the tutorial, we will have a model and we can speak to our chatbot. There is an another tutorial with which you can train your chatbot with the tool `AI Training`: [How to train a chatbot with AI Training](https://docs.ovh.com/de/publiccloud/ai/training/train-rasa-chatbot/). |
| 17 | + |
| 18 | +We will use the famous open source framework [Rasa](https://rasa.community/) to build the chatbot. |
| 19 | + |
| 20 | +## Requirements |
| 21 | + |
| 22 | +- Access to the [OVHcloud Control Panel](https://www.ovh.com/auth/?action=gotomanager&from=https://www.ovh.de/&ovhSubsidiary=de) |
| 23 | +- A Public Cloud project created |
| 24 | +- The ovhai CLI interface installed on your system (more information [here](https://docs.ovh.com/de/publiccloud/ai/cli/install-client/)) |
| 25 | +- A [user for AI Notebooks](https://docs.ovh.com/de/publiccloud/ai/users/) |
| 26 | + |
| 27 | +## Instructions |
| 28 | + |
| 29 | +### Create a token to access your AI services |
| 30 | + |
| 31 | +The first step is to create an AI applicative token. With this token, you will be able to securely access all of your AI services. |
| 32 | + |
| 33 | +To do this, launch this command on the terminal once the ovhai CLI is installed: |
| 34 | + |
| 35 | +``` bash |
| 36 | +ovhai token create -l model=rasabotRW --role operator token-RW-chatbot |
| 37 | +``` |
| 38 | + |
| 39 | +Here is the reference to install the CLI: [CLI Installation](https://docs.ovh.com/de/publiccloud/ai/cli/install-client/). |
| 40 | + |
| 41 | +The token is now created. Don't forget to save the token to use it later. |
| 42 | + |
| 43 | +Now, if you already have trained some Rasa models with AI Training by following [our tutorial](https://docs.ovh.com/de/publiccloud/ai/training/train-rasa-chatbot/), you already have created a container with your trained models. You can skip the next part and go directly [here](#visualstudiocode). |
| 44 | + |
| 45 | +### Understand storage concepts |
| 46 | + |
| 47 | +The obvious goal about using object storage and not the local storage of the AI Notebook is to decorrelate compute and storage, allowing us to stop or delete the notebook while keeping the data safe. |
| 48 | + |
| 49 | +If you want to know more about data storage concept, read this guide: [Create an object container](https://docs.ovh.com/de/storage/object-storage/pcs/create-container/). |
| 50 | + |
| 51 | +For the chatbot, we will create one object storage bucket. This bucket will be filled over time by our trained model output. The container in which the model will be saved does not need to be created. When we will launch our notebook, the container will be automatically created. |
| 52 | + |
| 53 | +Now, let's start to create and train our chatbot. |
| 54 | + |
| 55 | +### Create and train a chatbot with a Visual Studio Code notebook <a name="visualstudiocode"></a> |
| 56 | + |
| 57 | +In order to do it you will need to create a Visual Studio Code notebook. You can attach one volume if you want to save the model created. |
| 58 | + |
| 59 | +Don't forget to put the model inside the folder `trained-models` before stopping your notebook. By doing this, your model will be saved in your object container even if you delete your notebook. Here is the command to run: |
| 60 | + |
| 61 | + |
| 62 | +``` console |
| 63 | +ovhai notebook run conda vscode \ |
| 64 | +--name vscode-ovh-chatbot \ |
| 65 | +--framework-version conda-py39-cuda11.2-v22-4 \ |
| 66 | +--volume <model-output-container>@GRA:/workspace/trained-models:RW \ |
| 67 | +--cpu 10 \ |
| 68 | +--token <token> \ |
| 69 | +--label model=rasabotRO \ |
| 70 | +-s ~/.ssh/id_rsa.pub |
| 71 | +``` |
| 72 | + |
| 73 | +Explanation of each line: |
| 74 | + |
| 75 | +- Launch a notebook with the Python Miniconda framework in a Visual Studio Code editor. |
| 76 | +- Name it "vscode-ovh-chatbot". |
| 77 | +- Specify a version for the conda framework (Python 3.9). |
| 78 | +- Attach 1 data volume to the notebook, as explained previously. |
| 79 | +- Request 10 CPUs. The more we add, the more performant it is. |
| 80 | +- Add the token previously created. |
| 81 | +- Label this notebook "rasabotRO". |
| 82 | +- Optional: The last line is the path to your ssh key on your machine. It is important to set up the key here to connect remotely from VScode. If you don't want to, you can connect directly on the web with the token you created before. |
| 83 | + |
| 84 | +> [!primary] |
| 85 | +> |
| 86 | +> Note that the **GitHub** repository does not have to be added because it is already present when you create an AI Notebook. |
| 87 | +> |
| 88 | +
|
| 89 | +Your notebook is ready, you can access it and log in. |
| 90 | + |
| 91 | +Before training an AI model inside the notebook, you must install all the dependencies of Rasa. Open a terminal and launch this command: |
| 92 | + |
| 93 | +```console |
| 94 | +pip install rasa |
| 95 | +``` |
| 96 | + |
| 97 | +Once you have installed all the dependencies, you can create and train the chatbot with only one command in your terminal. Run it at the root of your directory: |
| 98 | + |
| 99 | +```console |
| 100 | +rasa init |
| 101 | +``` |
| 102 | + |
| 103 | +It will create some folders with basic data for the Rasa chatbot. During the command, you can also train a model and speak with the chatbot at the end. Here is a small example of a conversation with the chatbot. |
| 104 | + |
| 105 | +{.thumbnail} |
| 106 | + |
| 107 | +Here, we train a very simple model with few data. There are some frameworks like [Chatette](https://github.com/SimGus/Chatette) that generate some data and permit to create more powerful models. |
| 108 | + |
| 109 | +## Go further |
| 110 | + |
| 111 | +If you want to use more functionalities of Rasa, please follow this link. We use Rasa Open Source and not Rasa X. |
| 112 | + |
| 113 | +[Rasa Open source](https://rasa.com/docs/rasa/) |
| 114 | + |
| 115 | +If you want to deploy your created model with the chatbot, you can follow this tutorial: |
| 116 | + |
| 117 | +[How to deploy a chatbot](https://docs.ovh.com/de/publiccloud/ai/deploy/deploy-rasa-chatbot) |
| 118 | + |
| 119 | +If you want to train a Rasa chatbot with the tool AI Training, please refer to this tutorial: |
| 120 | + |
| 121 | +[How to train a chatbot with docker and AI Training](https://docs.ovh.com/de/publiccloud/ai/training/train-rasa-chatbot/) |
| 122 | + |
| 123 | +## Feedback |
| 124 | + |
| 125 | +Please send us your questions, feedback and suggestions to improve the service: |
| 126 | + |
| 127 | +- On the OVHcloud [Discord server](https://discord.com/invite/vXVurFfwe9) |
0 commit comments