# Enhance rasa with a pre-trained classification model

**URL:** <https://forum.rasa.com/t/enhance-rasa-with-a-pre-trained-classification-model/10586>\
**Category:** Rasa Open Source\
**Created:** [May 29, 2019, 9:43am UTC](https://forum.rasa.com/t/enhance-rasa-with-a-pre-trained-classification-model/10586 "2019-05-29T09:43:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ghassen](https://avatars.discourse-cdn.com/v4/letter/g/eada6e/32.png) [@Ghassen](https://forum.rasa.com/u/Ghassen)\
**Post date:** [May 29, 2019, 9:43am UTC](https://forum.rasa.com/t/enhance-rasa-with-a-pre-trained-classification-model/10586/1 "2019-05-29T09:43:29Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Kenz](https://avatars.discourse-cdn.com/v4/letter/k/ee7513/32.png) [@Kenz](https://forum.rasa.com/u/Kenz)\
**Post date:** [May 29, 2019, 10:57am UTC](https://forum.rasa.com/t/enhance-rasa-with-a-pre-trained-classification-model/10586/2 "2019-05-29T10:57:06Z")

</div>

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:

> **[How to Enhance Rasa NLU Models with Custom Components | Rasa Blog](https://rasa.com/blog/enhancing-rasa-nlu-with-custom-components/)**
>
> In this tutorial, you'll learn how to create custom components and add them to the Rasa NLU pipeline to take your AI assistants to a whole new level.

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

---

<div class="post-metadata">

**Author:** ![Ghassen](https://avatars.discourse-cdn.com/v4/letter/g/eada6e/32.png) [@Ghassen](https://forum.rasa.com/u/Ghassen)\
**Post date:** [May 29, 2019, 12:26pm UTC](https://forum.rasa.com/t/enhance-rasa-with-a-pre-trained-classification-model/10586/3 "2019-05-29T12:26:33Z")

</div>

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](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/9/942fdb8af333e250cb83a0cf4f3f98d04a518439.jpeg)

---

<div class="post-metadata">

**Author:** ![Kenz](https://avatars.discourse-cdn.com/v4/letter/k/ee7513/32.png) [@Kenz](https://forum.rasa.com/u/Kenz)\
**Post date:** [May 30, 2019, 5:06pm UTC](https://forum.rasa.com/t/enhance-rasa-with-a-pre-trained-classification-model/10586/4 "2019-05-30T17:06:15Z")

</div>

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](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](http://localhost:5055/webhook)”)
> 
> agent = Agent.load(model\_path, interpreter=interpreter, action\_endpoint=action\_endpoint)

---

<div class="post-metadata">

**Author:** ![aizanzafar](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/aizanzafar/32/5265_2.png) [@aizanzafar](https://forum.rasa.com/u/aizanzafar)\
**Post date:** [October 22, 2019, 11:51am UTC](https://forum.rasa.com/t/enhance-rasa-with-a-pre-trained-classification-model/10586/5 "2019-10-22T11:51:47Z")

</div>

@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
