rasa-travel-chatbot

Here is my Senior Design Project that I implemented to graduate from Computer Engineering. It is a chatbot made in RASA and helps the user to plan their vacation in the Turkish language. In order to plan the user's vacation, it provides reservations by asking various questions for hotel, flight, or event.

How to Run the Project?

  1. Create a virtual environment of python 3.6 or greater.
  2. Navigate to the rasa directory. Run the command:
    rasa train
  3. After the model is trained, launch the rasa core server:
    rasa run -m models --enable-api
  4. Launch the rasa actions server in another terminal:
    rasa run actions
  5. Navigate to the chatbot/backend. Run the command:
    python route.py
  6. Launch the frontend on the local python http server under the interface directory:
    python -m http.server

Interface

Here is an example conversation for booking an event in Turkish.

Ekran Resmi 2021-06-20 15 00 44

In this figure, the chatbot is trying to learn which event the user wants to go to after the greeting.

Ekran Resmi 2021-06-20 15 00 57

After that the chatbot asks for how many tickets the user wants and tries to make the reservation by asking for an e-mail.

Ekran Resmi 2021-06-20 15 01 06

Finally, the chatbot tells the user how many tickets it has bought and sent to which e-mail address and asks if the user wants to take another action. If the user says no, chatbot finishes the conversation by saying goodbye.

Turkish Dataset

Due to the small number of chatbots in the Turkish language, Turkish datasets are also less. For this reason, we prepared a Turkish dataset from scratch while doing this project. In order to do this, we translated the English datasets into Turkish using the Google API. In the end, we have 93 intents 29 entities in total, and an average of 7 sentences for each intent.

Ekran Resmi 2021-06-20 15 08 45

RASA

Rasa is an open source python library for constructing conversational software with minimal (or no) initial training data. It consists of two parts: Rasa NLU and Rasa Core. Dialogue management problem can be handled as a classification problem. At each iteration, Rasa Core predicts which action to take from a predefined list. On the other hand, Rasa NLU is a tool for natural language understanding. It combines a number of natural language processing and machine learning libraries in a consistent API.

Ekran Resmi 2021-06-20 15 17 46

First a message is received and passed to Rasa NLU to extract the intent, entities, and the other structured information. Then the conversation state saved in the tracker which receives a notification that a new message has been received. In step 3, the policy receives the current state of the tracker and chooses which action to take next. Then chosen action is logged by the tracker and executed. If the predicted action is not ‘listen’, go back to step 3. After the first step all the remaining steps are performed by Rasa Core.

Ekran Resmi 2021-06-20 15 17 46

Here is an example of intent classification and entity extraction for a possible input sentence that chatbot can receive from user in this project.

Ekran Resmi 2021-06-20 15 45 03

Best Configuration

We used pre-trained language model BERT for our pipeline. We compared three different pipeline configurations: a light configuration, a configuration using ConveRT, and a heavy configuration that included BERT. In each case we’re training a DIETClassifier for combined intent classification and entity recognition for 200 epochs, but in the light configuration we have CountVectorsFeaturizer, which creates bag-of-word representations for each incoming message at word and character levels. In the end, we chose config-light as the configuration of the chatbot.

Results of the Configurations

Ekran Resmi 2021-06-20 15 21 16

Ekran Resmi 2021-06-20 15 21 27

In the images below, there are confusion matrices created by each configuration for intent classification and entity extraction in turn.

config-light:

Ekran Resmi 2021-06-20 15 26 15 Ekran Resmi 2021-06-20 15 26 36 Ekran Resmi 2021-06-20 15 27 25 Ekran Resmi 2021-06-20 15 27 46

config-convert:

Ekran Resmi 2021-06-20 15 30 19 Ekran Resmi 2021-06-20 15 30 30 Ekran Resmi 2021-06-20 15 30 42 Ekran Resmi 2021-06-20 15 30 54

config-heavy:

Ekran Resmi 2021-06-20 15 32 01 Ekran Resmi 2021-06-20 15 32 12 Ekran Resmi 2021-06-20 15 32 22 Ekran Resmi 2021-06-20 15 32 32

GitHub

https://github.com/ezgisubasi/rasa-travel-chatbot