Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
wiki:software:beuthbot:rasa:training [22.07.2020 19:24] Lukas Danckwerth angelegt |
wiki:software:beuthbot:rasa:training [22.07.2020 19:39] (aktuell) Lukas Danckwerth |
||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
===== Rasa Training ===== | ===== Rasa Training ===== | ||
+ | ==== Overview ==== | ||
+ | == Training Input Data == | ||
+ | |||
+ | Trining input data files are `.chatito` | ||
+ | |||
+ | > This is the place where to provide new functionality for the BeuthBot. | ||
+ | |||
+ | == Training Dataset == | ||
+ | |||
+ | Trining dataset files are `.json` | ||
+ | |||
+ | == Training Model == | ||
+ | |||
+ | Trining model files generated by Rasa are `.tar.gz` | ||
+ | |||
+ | < | ||
+ | $ make update-model | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ==== Step-by-Step Guide ==== | ||
+ | |||
+ | This guide explains how to create a new training model for Rasa. The following image gives you an overview of the files and steps to do. `*.chatito` files places in the `training/ | ||
+ | |||
+ | <uml> | ||
+ | @startuml | ||
+ | package Rasa { | ||
+ | |||
+ | folder training/ | ||
+ | artifact FILE1.chatito | ||
+ | artifact FILE2.chatito | ||
+ | } | ||
+ | |||
+ | card " | ||
+ | |||
+ | folder training/ | ||
+ | artifact FILE1.json | ||
+ | artifact FILE2.json | ||
+ | } | ||
+ | |||
+ | card " | ||
+ | |||
+ | folder training/ | ||
+ | artifact " | ||
+ | } | ||
+ | |||
+ | TI --> C1 | ||
+ | C1 --> TD | ||
+ | TD --> C2 | ||
+ | C2 --> M | ||
+ | |||
+ | } | ||
+ | @enduml | ||
+ | </ | ||
+ | |||
+ | === 1 - Provide new input training data === | ||
+ | |||
+ | Modify or add `*.chatito` files in the `training/ | ||
+ | |||
+ | == 1.1 - Generate training datasets == | ||
+ | |||
+ | We created a `docker-compose.yml` which defines a container which generates the datasets. To use it type the following command in the `training` directory. | ||
+ | |||
+ | < | ||
+ | # change into `training` directory (if you are not still there) | ||
+ | $ cd training | ||
+ | |||
+ | # runs the dataset generation container | ||
+ | $ docker-compose -f docker-compose.generate-data.yml up | ||
+ | |||
+ | # .. or use the convenient make target | ||
+ | $ make generate-data | ||
+ | </ | ||
+ | |||
+ | === 2 - Create model with Rasa === | ||
+ | |||
+ | There are two ways of generating models from training data. Either with a local Rasa installation or with withing a Docker container. The preferred way is to use the Docker container. | ||
+ | |||
+ | Furthermore Rasa NLU is configurable and is defined by pipelines. These pipelines define how the models are generated with the training data and which entities are extracted. For this, a preconfigured pipeline with " | ||
+ | |||
+ | > Check the `config.yml` for configuration of Rasa pipeline (how the trained model is generated). | ||
+ | |||
+ | == 2.1 - Create model with local Rasa installation == | ||
+ | |||
+ | Create training model with local `rasa` command. For furher information and an installation guide for a local Rasa installation see this [link](https:// | ||
+ | |||
+ | < | ||
+ | $ rasa train nlu | ||
+ | </ | ||
+ | |||
+ | == 2.2 - Create model with Rasa Docker container == | ||
+ | |||
+ | Build and run the training Docker container which generates the model file. | ||
+ | |||
+ | < | ||
+ | # runs the train model container | ||
+ | $ docker-compose -f docker-compose.train-model.yml up | ||
+ | |||
+ | # .. or use the convenient make target | ||
+ | $ make train-model | ||
+ | </ | ||
+ | |||
+ | > For a fast convenient way to [[# | ||
+ | < | ||
+ | # runs both the dataset generation and train model container | ||
+ | docker-compose -f docker-compose.yml up | ||
+ | |||
+ | # .. or simply | ||
+ | docker-compose up | ||
+ | </ | ||
+ | |||
+ | === 3 - Check generated file === | ||
+ | |||
+ | Both way will create a new training model in the `/ | ||
+ | |||
+ | < | ||
+ | # check file existence | ||
+ | $ ls -la app/models | ||
+ | </ | ||
+ | |||
+ | === 4 - Replace existing models file === | ||
+ | |||
+ | The model file which is used by Rasa in production is placed in the `app/ | ||
+ | |||
+ | < | ||
+ | # delete existing model (if you are still in `training` directory) | ||
+ | $ rm -rf ../ | ||
+ | |||
+ | # then copy the newes model archive | ||
+ | $ cp " | ||
+ | |||
+ | # .. or you use the convenient make target | ||
+ | $ make update-model | ||
+ | </ | ||
+ | |||
+ | > Restart Rasa container or complete BeuthBot container and you are done. Rasa now runs with you new model. | ||
+ | |||
+ | === 5 - Shorthand === | ||
+ | |||
+ | There is a shorthand for all the above listed steps. Simply use the `Makefile` target to run all commands from step 1 till step 4. Providing new input data still depants on you. | ||
+ | |||
+ | < | ||
+ | # assuming you are in the `training` main directory | ||
+ | $ make train | ||
+ | </ | ||
+ | |||
+ | Lean back an wait till the training is done. |