Know how empty functions are running in the rasa internal code

I was checking the Rasa 1.3.X git hub code. Wanted to know the exact code that triggers the training of the models. When I was digging in, the flow was,

train.py in the rasa folder.

From their to rasa.core.train.py

from rasa.core.train.py to agent.train

from agent.train to policy_ensemble.train

from ensemble.train to policy.train

Now I kind of didn’t get the train function inside the policy.py.

the function is as follows.

def train(self,training_trackers: List[DialogueStateTracker],domain: Domain,
        **kwargs: Any
    ) -> None:
        """Trains the policy on given training trackers."""
        raise NotImplementedError("Policy must have the capacity to train.")

The above function is just raising an exception.

I quite don’t understand how does these functions run and what code they are executing ?

Hi @suryavamsi62!

The code:

def train(self,training_trackers: List[DialogueStateTracker],domain: Domain,
        **kwargs: Any
    ) -> None:
        """Trains the policy on given training trackers."""
        raise NotImplementedError("Policy must have the capacity to train.")

It is for the case when you want to extend the Policy class to implement your own custom policy. The train method is intrinsic to a particular policy. For example if you want to see the train method of the KerasPolicy, you should be able to see it at core/policies/keras_policy.py (check this github link to see the detailed implementation)

Hope that helps!

Thank you @saurabh-m523. Appreciate the help.

I want to externally build a model with rasa implemented specifications of supervised_embeddings. My goal is to build a text classification system just like Rasa NLU. I want to externalize it with the same concept of rasa NLU but I couldn’t exactly pinpoint the machine learning code, which triggers or trains the NLU of RASA.

Can you please help me on this. Thanks in advance.

You can use only the NLU (using NLU only) if you want. For the code which triggers training I think this could help. Take a look at this whole class the EmbeddingIntentClassifier has been extended from this class.

Hope that help.