Politecnico of Turin Thesis: "Implementation and Evaluation of an Educational Chatbot based on NLP Techniques"

Overview

THESIS_CAIRONE_FIORENTINO

Politecnico of Turin Thesis: "Implementation and Evaluation of an Educational Chatbot based on NLP Techniques"

GENERATE TOKEN SLACK

NB: REMEMBER TO REGENERATE SLACK TOKENS AND CHANNEL ID IF ARE DISABLE (SEE THESIS PDF)

  • Go on your Slack App ( App Slack )-> select your app or create new -> Settings -> Install App -> (regenerate two tokens) -> Copy Tokens in actions/Constants.py and credentials.yml files.

RASA - LOCAL MODE

Components Installation

  • Writing in Anaconda console this command:
    • conda create --name venv python==3.8.0
    • conda activate venv
    • conda install ujson tensorflow
    • pip install rasa
    • pip install rasa[spacy] for SPACY configuration
    • pip install rasa[trasformers] for BERT configuration
    • rasa init if you want to create new project

MORE INFO: See this video: link

Code Execution

  • First, in TESI_POLI_POBOT directory do the training in anaconda console with venv activate:

    • rasa train --config configs/{file_cofiguration}.yml --fixed-model-name {model_name}
  • After run server rasa:

  • rasa run --connector slack --model {model_name} --debug

  • In an other prompr run server rasa ACTIONS:

  • rasa run actions --action actions --debug

  • If you want,to test locally the intent classification, run in Anaconda console:

    • rasa train --config configs/{file_cofiguration}.yml --fixed-model-name {model_name}
    • rasa shell --model {model_name}

Rasa Bot - Slack Connection

  • after training and running the server in Anaconda console (see ## Execution of code paragraph):
    • in BOT_RASA/ngrok directory run this command (in console prompt):
      • ngrok http 5005 to create a tunnel for localhost:5005 address:
      • select the forwarding address choose to ngrok ({address} = http://<number_code>.ngrok.io)
      • in Slack App link save the address (selecting in Features menu):
        • Interactivity & Shortcut > Request URL: ({address}/webhooks/slack/webhook) > Save Changes
        • OAuth & Permissions > Redirect URLs > Add : ({address}/webhooks/slack/webhook) > Save URLs
        • Event Subscriptions > Enable Events (Request URL) > Change: ({address}/webhooks/slack/webhook) > Save Changes
      • expired time of ngrok address: 2 hours. (when we will use a public address, ngrok will become USELESS)
  • tokens bot save as environment variable in PC server (for security issue)
  • Slack bot: link

To Connect also the ACTION Server Rasa:

  • ngrok http 5055 to create a tunnel for localhost:5055
  • In endpoints.yml modify url of action_endpoint: {address}/webhook

RASA X

Components Installation

  • Writing in Anaconda console this command:
    • conda create --name venv python==3.9.0
    • conda activate venv
    • conda install ujson tensorflow
    • pip install rasa[spacy] for SPACY configuration
    • pip install rasa[trasformers] for BERT configuration
    • pip install --upgrade pip==20.0.1 pip3 install rasa-x --extra-index-url https://pypi.rasa.com/simple pip install --upgrade pip

Code Execution

  • First, in TESI_POLI_POBOT directory do the training in anaconda console with venv activate:

    • set PYTHONUTF8=1
    • rasa x --connector slack --config configs/{file_cofiguration}.yml
  • In an other prompt run server rasa ACTIONS:

  • rasa run actions --action actions --debug

Rasa Bot - Slack Connection

  • after training and running the server in Anaconda console (see ## Execution of code paragraph):
    • in BOT_RASA/ngrok directory run this command (in console prompt):
      • ngrok http 5005 to create a tunnel for localhost:5005 address:
      • select the forwarding address choose to ngrok ({address} = http://<number_code>.ngrok.io)
      • in Slack App link save the address (selecting in Features menu):
        • Interactivity & Shortcut > Request URL: ({address}/webhooks/slack/webhook) > Save Changes
        • OAuth & Permissions > Redirect URLs > Add : ({address}/webhooks/slack/webhook) > Save URLs
        • Event Subscriptions > Enable Events (Request URL) > Change: ({address}/webhooks/slack/webhook) > Save Changes
      • expired time of ngrok address: 2 hours. (when we will use a public address, ngrok will become USELESS)
  • tokens bot save as environment variable in PC server (for security issue)
  • Slack bot: link

To Connect also the ACTION Server Rasa:

  • ngrok http 5055 to create a tunnel for localhost:5055
  • In endpoints.yml modify url of action_endpoint: {address}/webhook

To Connect also the ACTION Server Rasa X:

  • ngrok http 5055 to create a tunnel for localhost:5002
  • In credentials.yml modify url of rasa: {address}/api

RASA - DOCKER MODE

Code Execution

If is the first time, run this commands:

docker volume create db-volume
docker-compose up -d
docker-compose down
docker-compose up -d
python rasa_x_commands.py create --update admin me <password_rasa_server> (i.e. password)
docker-compose down
docker-compose up -d

Otherwise, in TESI_POLI_POBOT directory in console run only this command:

  • docker-compose up -d

Rasa Bot - Slack Connection

After all container is in running mode, in web browser go in `http:://localhost:80' and insert the password choose the first time. (i.e. password)

If rasa x server not contain NLU data (possible first time) you can upload the file directly using interface of rasa x server in Training -> NLU data / Stories / Rules / Configuration (copy and paste the content of config choose in TESI_POLI_POBOT directory)

If you want to connect to slack:

  • after training and running the server in Anaconda console (see ## Execution of code paragraph):
    • in BOT_RASA/ngrok directory run this command (in console prompt):
      • ngrok http 80 to create a tunnel for localhost:80 address:
      • select the forwarding address choose to ngrok ({address} = http://<number_code>.ngrok.io)
      • in Slack App link save the address (selecting in Features menu):
        • Interactivity & Shortcut > Request URL: ({address}/core/webhooks/slack/webhook) > Save Changes
        • OAuth & Permissions > Redirect URLs > Add : ({address}/core/webhooks/slack/webhook) > Save URLs
        • Event Subscriptions > Enable Events (Request URL) > Change: ({address}/core/webhooks/slack/webhook) > Save Changes
      • expired time of ngrok address: 2 hours. (when we will use a public address, ngrok will become USELESS)
  • tokens bot save as environment variable in PC server (for security issue)
  • Slack bot: link

RASA - TEST DATA

Test stories in tests directory

  • if you want tests stories with cross-validation:
    • rasa train --config configs/{file_cofiguration}.yml --fixed-model-name {model_name} (if model does not exist)
    • rasa test --config configs/{file_cofiguration}.yml --cross-validation --runs {time_runs} --folds {num_folds} --out {dir_out} --model {model_name}

Test NLU data

  • if you want test only the NLU data splitted:

    • rasa train nlu --nlu train_test_split/training_data.yml --config configs/{file_cofiguration}.yml --fixed-model-name ./models_NLU/{model_name} (if model does not exist)
    • rasa test nlu --nlu train_test_split/test_data.yml --out {dir_out} --model ./models_NLU/{model_name}
  • if you want test only the NLU data totally:

    • rasa train nlu --config configs/{file_cofiguration}.yml --fixed-model-name {model_name} (if model does not exist)
    • rasa test nlu --nlu train_test_split/test_data.yml --out {dir_out} --model {model_name}

Test CORE data

  • if you want test only the CORE data:
    • rasa train --config configs/{file_cofiguration}.yml --fixed-model-name {model_name} (if model does not exist)
    • rasa test core --stories tests/test_stories.yml --out {dir_out} --model {model_name}
You might also like...
Owner
cairone_fiorentino97
cairone_fiorentino97
Code for the bachelors-thesis flaky fault localization

Flaky_Fault_Localization Scripts for the Bachelors-Thesis: "Flaky Fault Localization" by Christian Kasberger. The thesis examines the usefulness of sp

Christian Kasberger 1 Oct 26, 2021
Implementation of the bachelor's thesis "Real-time stock predictions with deep learning and news scraping".

Real-time stock predictions with deep learning and news scraping This repository contains a partial implementation of my bachelor's thesis "Real-time

David Álvarez de la Torre 0 Feb 9, 2022
Implementation of the master's thesis "Temporal copying and local hallucination for video inpainting".

Temporal copying and local hallucination for video inpainting This repository contains the implementation of my master's thesis "Temporal copying and

David Álvarez de la Torre 1 Dec 2, 2022
Bachelor's Thesis in Computer Science: Privacy-Preserving Federated Learning Applied to Decentralized Data

federated is the source code for the Bachelor's Thesis Privacy-Preserving Federated Learning Applied to Decentralized Data (Spring 2021, NTNU) Federat

Dilawar Mahmood 25 Nov 30, 2022
Code for the bachelors-thesis flaky fault localization

Flaky_Fault_Localization Scripts for the Bachelors-Thesis: "Flaky Fault Localization" by Christian Kasberger. The thesis examines the usefulness of sp

Christian Kasberger 1 Oct 26, 2021
Implementation of the bachelor's thesis "Real-time stock predictions with deep learning and news scraping".

Real-time stock predictions with deep learning and news scraping This repository contains a partial implementation of my bachelor's thesis "Real-time

David Álvarez de la Torre 0 Feb 9, 2022
Implementation of the master's thesis "Temporal copying and local hallucination for video inpainting".

Temporal copying and local hallucination for video inpainting This repository contains the implementation of my master's thesis "Temporal copying and

David Álvarez de la Torre 1 Dec 2, 2022
Honor's thesis project analyzing whether the GPT-2 model can more effectively generate free-verse or structured poetry.

gpt2-poetry The following code is for my senior honor's thesis project, under the guidance of Dr. Keith Holyoak at the University of California, Los A

Ashley Kim 2 Jan 9, 2022