Using multiple NLU models?

Hey,

can you load two NLU models in a custom component to combine different results of each?

I think there are two ways.

  1. I already trained two models and just load them
  2. I train two models with two different data sets in one training run (so within one config file)

I have another somehow related question. Can i use spacy model and tensorflow model in one config file? I would like to do Intent classfification both with spacy and tensorflow and then want to do custom logic afterwards in a custom component.Also I want to extract the word vectors from spacy and tensoflow in this component. I guess I need to load both trained models (spacy, tensorflow) inside this custom component?

Is this possible?

@Ghostvv

yes, you would need to create custom component for this. I think, you can train two different intent classifiers in the same config file (need to be checked). For prediction though, you would need to customize them to write results into different keys in Message object. Then you can create a custom component to choose between the predictions

Thanks.

But running the intent classifiers after each other in the config would overwrite the first intent. Do I have to customize the keys inside the classifier script then? Or can I do this with a component. I would rather like to do this with a component since after a new update of rasa I need to rewrite every step and this is not a good practice I think.

Do I have to customize the keys inside the classifier script then? yes

What about the first part of my question? Training on two data sets (like for entity and intent) or loading two models in a component?

Can I load spacy vectors and the tensorflow vectors inside a component?

Can I workaround this to train a spacy and tensorflow model separately (with two config files) then load them in a component (third config file)?

I don’t know, you should try it

1 Like

See my last edited post. :slight_smile:

Should it be possible to handover two dats sets for two different interperters and combine both results with one config file?

I don’t know, probably with some custom code it should be possible. It is hard to say without trying it.

I will try it. But as I said cusotmizing code inside the scripts is not good practice and can lead to clashes after a new update…

Can’t I create a message object in a custom component and load inside this two different models and create diff keys afterwards. All in one component? That would be nice.:slight_smile:

@datistiquo have you tried to create two NLU models? I would be helpful to know what problems can be with this approach because I am also going to create a custom component for two different classifiers.

Also interested to know what to look out for or any tips on training both supervised and a pretrained embeddings and to combine results for a final intent classification result.

hello there,

I am also facing similar challenge, i want to have to separate NLU models with complete different pipeline to support maybe two language one for each model, i want to choose which interpreter to parse the message depending on an id, so I know i need to build a custom component but what to do in it.

to summarize here :

  1. I want to run two NLU models based on an id sent inside the request
  2. i know how to build a custom competent in general but i don’t know what to do here
  3. I am using rasa 1 so the nlu model is extracted once at running server … how can i load two models in this step.

You need to add support to use several nlu pipelines during prediction time