How to combine nlu model and core model


We can use the command rasa train to train a Rasa model that combines a Rasa NLU and a Rasa Core model. If we use the command rasa train nlu and rasa train core to train nlu model and core model separately, how to combine those models into one model? Many thanks.

If you train your NLU and Core model separately, you will have two tar.gz files. You need to unpack them and combine them manually:

  1. Unpack the NLU tar.gz model file. Inside the unpacked folder you will find a nlu folder and a fingerprint.json
  2. Unpack the Core tar.gz model file. Inside the unpacked folder you will find a core folder and a fingerprint.json
  3. Create a new folder combined-model (name it as you like)
  4. Move the nlu and the core folder inside the new folder combined-model
  5. Combine the fingerprint.json files - you need to update the domain, messages, and stories key. Move the combined file also into the new folder combined-model
  6. Zip the new folder combined-model, so that you have a combined-model.tar.gz file

You can use combined-model.tar.gz as combined Rasa model.

Thanks a lot Tanja for your detailed explanation:grinning:

  1. Can you tell us more about the fifth point?
  2. Which fingerprint.json do you need to change?
  3. Which fingerprint.json take of core or nlu ( basic )?
  4. We change only 3 parameters domain, messages, stories, do we need to change the parameter (core or nlu)?
  5. Will it work in Rasa v.2.0.3?

there is a problem in 2.x with combining models that were trained separately right now. If nlu exists, rasa core will use its components to featurize intent and action labels. So when you call rasa train core there is no nlu model, and it creates one-hot features for labels, however, when you combine the models during prediction time, nlu interpreter will exist, and rasa core featurization will be different.

We’re working on the solution to make sure that core featurizer persist the information how they were trained and behave appropriately during prediction

Thanks for the answer! Can you write in detail how this can be done when you fix it?

create a fix for separate training: core featurizers should use regex interpreter if core was trained separately by Ghostvv · Pull Request #7316 · RasaHQ/rasa · GitHub combining should work as described above

I wonder the same but as I can see @Tanja post, it’s much harder and much more time consuming work than I initially though. I am currently working on a project where rasa train nlu consumes ~ 1 hour and rasa train core consumes ~ 3 minutes. By doing changes just on Core part of my project, I’m forced to unnecessarily waste ~ 1 hour on every single training via rasa train command. It would be AMAZING, if all these @Tanja steps were automatically done by new CLI command rasa train merge or something like this OR if you make a command rasa run to be able to automatically handle these 2 model files by default and if it would be necessary, I have to specify path to NLU and Core model files by rasa run --model-core models/core.tar.gz --model-nlu models/nlu.tar.gz or something like this.


have you solve the problem, or any other idea