Enhance rasa with a pre-trained classification model

Hello, I created a multi label classifier model and I want to import this model into rasa, how to proceed and what configuration must be made to make it compatible ?

HI,

Could you explain further what you are trying to do?

If you want to add it as a custom component in the pipeline you can do so referring to this tutorial:

In fact you just have to transform your classifier model to make it become an extend of the rasa component class, then refer to this component when you need it in your config.yml file using the same manner you import classes in python.

Florian

hi, thank you for you response, I built a model that does the text classification as follows and now I want to import this model into rasa to generate the corresponding actions and responses for the chatbot.Is it possible ?classification

Oh , so you built your own NLU? If it’s the case you can use it to replace Rasa_NLU and only use Rasa_Core with it to make responses and actions.

To implement your NLU model first you need to create a class that extends NaturalLanguageInterpreter that init it and specify a least a parse method.

Here is the code architechture:

class MyNLUInterpreter(NaturalLanguageInterpreter):

def __init__(self, """what you need to init here"""):
    """Init your model

     Make sure everything is loaded properly and ready to use"""

def parse(self, text):
    """Parse a text message.

    Return a default value if the parsing of the text failed."""

Then setup your Rasa_Core domain.yml, stories.md ect… Everything like in the tutorial but adapt it to the intent you detect with your custom NLU.

Setup your action sever like in Rasa_Core tutorial and make the pipeline to generate core instance.

You just then have to replace:

interpreter = RasaNLUInterpreter(nlu_model)

action_endpoint = EndpointConfig(url=“http://localhost:5055/webhook”)

agent = Agent.load(model_path, interpreter=interpreter, action_endpoint=action_endpoint)

By:

interpreter = MyNLUInterpreter(""“The params you decided”"")

action_endpoint = EndpointConfig(url=“http://localhost:5055/webhook”)

agent = Agent.load(model_path, interpreter=interpreter, action_endpoint=action_endpoint)

@Kenz can you please elaborate it. I also request to @Ghassen if you have implemented your own NLU interpreter can you please share the code