Warning: This document is for the development version of Rasa Platform. The latest version is 0.18.0.

Training your ML Models Locally

Train Locally from a Rasa Platform Instance

If you would like to test test out a new NLU model, or just tweak some training parameters on your local machine, you have the option to retrieve the data straight from the running Rasa Platform instance. This lets you avoid having multiple copies of the same dataset which are difficult to keep in sync.

Note

This page covers the instructions for manually training Rasa NLU with data from Rasa Platform. If you would like to set up a nightly build or continuous integration, see Continuous Integration of Machine Learning Models.

How do I do that?

The training process is similar to the one outlined in the Rasa NLU docs on training. Here, instead of specifying a local path to the training data with --data, you can use the data URL of your Rasa Platform instance with the --url parameter. Under the hood, Rasa NLU logs into the Rasa Platform, fetches the training data, temporarily saves it to a local file, and uses that for training.

If your Rasa Platform runs under https://platform-example.com, the URL you’re going to use is https://platform-example.com/api/default/data.json?api_token=<TOKEN>. Replace <TOKEN> with your personal API token. You can find your API token in the Platform under the NLU Training/Training Data tab (along with the command shown below). Have a look at the example below:

$ python -m rasa_nlu.train \
    --config sample_configs/config_spacy.yml \
    --url https://platform-example.com/api/default/data.json?api_token=<TOKEN> \
    --path projects

Note

If you want to reproduce the Platform results, copy the config from the Model config page, save it to a .yml file and use that with the --config option.

Upload an NLU model

If you have trained a model locally and would like to try it out on Rasa Platform, you can simply create a zip file and send it to your Platform API. Enter the directory of your trained model, for example with cd models/nlu/default/model and create a zip file called my_nlu_model.zip with

$ zip -r my_nlu_model.zip *

The next step is to send the model to Rasa Platform. If your Platform runs at https://platform-example.com/, the command looks like this:

$ curl -F "model=@my_nlu_model.zip" -H "filename: my_nlu_model.zip" https://platform-example.com/api/projects/default/models/nlu?api_token=<TOKEN>

Note

You can specify the filename in the filename header as in the example above. Everything before .zip will show up as your model name. If you don’t provide the filename header, the name of the file will be used.

The <TOKEN> is available in the NLU Training/Training Data tab in the command to pull data. If the upload is successful, your model will show up in the NLU model overview, where you can assign tags to it or mark it as active.

Upload a Core model

Once you have trained your model locally, navigate into the folder containing it (for example models/dialogue) and create a zip file called my_model.zip with

$ zip -r my_model.zip *

The next step is to send the model to Rasa Platform. If your Platform runs at https://platform-example.com/, the command looks like this:

$ curl -F "model=@my_model.zip" https://platform-example.com/api/projects/default/models/core?api_token=<TOKEN>

You can find your api_token in the example curl command in the https://rasa.example.com/data/training-data view.

If the upload is successful, your model will show up in the core models view at https://rasa.example.com/models/core-models, where you can mark it as active. Marking the model as active means that it will be used by Rasa Core.