Is it possible to use nlu part of previously trained model only and use a newly trained core?

I have a model that I trained previously using rasa train whose NLU training takes a while to finish. Is it possible to just use the NLU part of that model and then replace the Rasa core part?

If I am not mistaken, you can just train with rasa train core.

I’m currently trying to meet a deadline, so I can’t test this at the moment. I would really appreciate it if you, or someone else here could confirm this. @j.mosig

From the docs:

If you only want to train an NLU or a Core model, you can run rasa train nlu or rasa train core. However, Rasa will automatically skip training Core or NLU if the training data and config haven’t changed.

See, Command Line Interface

1 Like

I’m using rasa train core to attempt to accomplish exactly what the original poster said. However, I’m unable to get it working with rasa interactive. It loads the core model (most recently trained model), but doesn’t load an NLU model; this results in it detecting whatever string I give it as an intent that correspond to the given string literal. Example: I type “bacon is good” and it says the following:

Your NLU model classified ‘/bacon is good’ with intent ‘bacon is good’ and there are no entities, is this correct? (Y/n)

The core training run prepends “core-” to the beginning of the model, unlike nlu-core joint model files that don’t have “core-” at the beginning. Example core model file name: “core-20211014-101916.tar.gz”. Example flu-core joint model file name: “20211014-101916.tar.gz”.

Is there a way to specify both an NLU model and a Core model rather than specifying just one?

@bradyneal If you train an NLU model once, then subsequent calls of rasa train should actually just call the training for Core and re-use the NLU model (unless you changed training data that’s relevant for NLU or you use end-to-end predictions). Does this work for you?

Yes, I haven’t had an issue with rasa train rerunning NLU training when NLU data hasn’t trained, but I’m specifically interested in the case where my NLU data is different, but I don’t want to retrain the NLU model yet because it takes some time whereas training the core model is fast (at least for now). In Rasa X, the following seems to work:

  1. Make old combined NLU-Core model file active.
  2. Make new Core-only model file active (but can’t do this step without doing step 1 first).

But I’d like to be able to get this working with rasa interactive as well.

That shouldn’t actually work. If you only want to update the core part of your model, then you shouldn’t make any NLU changes. Perhaps you can stash those changes before training? You might also be interested in incremental training.

Gotcha, sounds like there’s no way to get it working with rasa interactive. I haven’t been careful about hooking training and git together, but it sounds the thing you suggest is maybe the best solution for now:

  1. Hook git commits and training together (always have a data commit associated with a training run)
  2. Run git stash && rasa train (should only train the Core component, but save all the models together, unlike rasa train core).

That [Rasa X hack Brady mentioned] shouldn’t actually work.

Hehe weird :slight_smile:. What is the point of rasa train core then?

What is the point of rasa train core then?

Mostly for debugging. I use it often to check that my stories don’t conflict with rules. Since rasa train core will raise an error if that is not so.