How to use own model in pipeline?

Would you please show me a similar working sentiment analyzer or intent classification file example with any pipeline?

My end goal is to learn to implement my own components(models) in Rasa, so to begin with I created my own DL sentiment analyzer model to implement (later I want and plan to try other components(models), classifications, etc. as well).

It seems I need to understand inter-component communications what data and in what format it pathing through between components and how and where I should put my model and how to bint it.

So I think I figured it out and able to understand if I have these two working examples in my machine with any pipeline. (first already works :slight_smile: thanks to you)

It will be highly appreciated for any advice, link, explanation, information to help me understand intercomponent communication and data formats between them. Maybe for someone, it’s easy but I’m struggling with it for a couple of months.

You can find a custom naive bayes classifier on the rasa-nlu-examples project.

In terms of a quick overview of our component stack, here’s a quick summary.

Rasa NLU Pipeline

The NLU Pipeline in Rasa concerns itself with detecting intents and entities. It starts with text as input and it keeps parsing until it has entities and intents as output.

The text is first turned into tokens.

After that, we take the tokens and text and we generate features for each. Some of these features are sparse (countvectors) while others are dense (word embeddings).

Besides features for tokens, we also generate features for the entire utterance. This is sometimes also referred to as the CLS token but we internally call it the sentence feature. The sparse features in this token are a sum of all the sparse features in the tokens. The dense features are either a pooled sum/mean of word vectors (in the case of spaCy) or a contextualised representation of the entire text (in the case of huggingface models).

Finally once we’ve got our features set up we can pass it to a model.

Rasa allows you to bring your own model for intent classification, entity extraction and response selection, however, it’s probably best that you use the DIET model for both intent classification and entity extraction. You can read the paper for more information but you may also enjoy our algorithm whiteboard series on the model.

A Rasa pipeline can have one, and only one, intent detection algorithm. Entity extraction algorithms, on the other hand, can run in parallel. So your diagram could look like this:

Note that each model can decide what to listen to. DIET ignores tokens, but it definitely needs numeric features. Other entity detection methods, like spaCy, might ignore the numeric features entirely and will only look at the text going in.

Message Objects

During this entire pipeline procedure we keep track of an object called Message. It’s like a dictionary. Every time it passes through a component we attach extra information to it. In the beginning it’s just "text" that is attached. But later we will attach "tokens", as well as features and model output. The Printer class that I mentioned earlier does a pretty good job at showing this.

Does this help?

1 Like

Thanks a lot, @koaning for your additional clarification, I read a lot in Rasa docs and other places but your short and clear explanation was perfect. You made a wonderful job.

Theoretically now everything is clear. Now I have to clear up the technical part, let me play around and experiment. I will definitely let you know my results or come back to you again :slight_smile: if I can’t resolve something.

Have a wonderful day! :slight_smile:

The guide you just saw is part of a blogpost/doc document that I’m currently writing. Happy to hear any feedback that you might have on it.

Side note: if you end up making a component that might be useful to the generate audience, please ping me over at the rasa nlu examples repo.

Thanks for info. I am trying to develop a custom component with IBM Tone Analyzer so I could get emotions in the intent. I used your tutorial, which I have just found out is super outdated.

I used the component in my config file and got the following error: