Will Rasa's NLU run significantly slower depending on its components? Should I use multiple NLU models instead of one?

Hi everyone, I’m currently using Rasa NLU to get intents and extract entities for some custom code. For each of the different functions, the required components for the function will vary.

For example, I have:

  • multiple intents “hi”, “bye”, “sad”, “happy” etc. where I only need the classifier to get the intent.

However, I also have:

  • the intent “reminder” which requires the use of Duckling http extractor, and
  • the intent “weather” which requires the RegexEntityExtractor.and Diet Classifier for Entity extraction

My questions are:

  • Should I include all of the intent examples in one single NLU file and train one single nlu model with all the required components in the config file?
  • Will the extra components impact the intent detection times of intents not using such components?
  • Will the extra components significantly impact training time?

Alternately:

  • Should I train multiple NLU models, with the main model only detecting intents and passing the input to a secondary model, which performs entity extraction, such that each secondary model would contain examples which requires a specific components config?
  • Would a structure like this be more or less computationally expensive if most of the intents do not require entity extraction?
  • Would a structure like this potentially reduce overall training time of the entire project as I would only need to train my main model multiple times, whereas the secondary models (with extra components) would only need to be trained once or twice?

Thank you in advance to anyone who can help answer all or even some of these questions!

Giving this a gentle bump in case anyone has answers c:

  • Should I include all of the intent examples in one single NLU file and train one single nlu model with all the required components in the config file?

You can split up your nlu.yml file. If you keep your data in the data/nlu/*.yml and in the correct format it should still pick up all the training examples.

  • Will the extra components impact the intent detection times of intents not using such components?

Technically every component in the pipeline will perform inference at every turn. This means that if there is a very slow component, every turn will take a performance hit. However, the slowest part of the pipeline is likely a huggingface component if you use it, and this component takes milliseconds, not seconds to run on most cloud hardware.

  • Will the extra components significantly impact training time?

In theory; yes. But extend of which determines a lot on the amount of training data/language/hyperparameters as well.

  • Should I train multiple NLU models, with the main model only detecting intents and passing the input to a secondary model, which performs entity extraction, such that each secondary model would contain examples which requires a specific components config?

It’s pretty normal to add more than 1 entity detection model to the pipeline actually! Duckling is very good at detecting dates, while spaCy has pretrained models that can be useful. Feel free to pick any model that works best on your problem.

  • Would a structure like this be more or less computationally expensive if most of the intents do not require entity extraction?

Again, any component that is added to the pipeline will make it take longer at every turn. Also, typically the “performance hit” is limited.

1 Like

Thank you so much, this is very helpful!!!

1 Like