How to use Flair models in Rasa for entity extraction

Hey, I am building a conversational bot that can automate Gsuite related tasks such as creating email ids, mailing groups, adding folks to DL etc. I experimented with some models for intent detection and entity extraction and here are my findings: a) For intent detection, which is a multiclass classification problem in my case, Bert (base+uncased) was the best, followed by ELMO and FastText (FT) supervised. Rasa (starspace) was not far behind FT. I used precision, recall and f-score for measuring performance.

b) For entity extraction, Flair was much better than the ones that I tried which included Rasa (CRF) and Bert.

As far as dialog management is concerned, Rasa is super cool with all its features. So, what I want to do is use Rasa core for dialog management and FT for intent detection + Flair for entity extraction. Bert is good for intent detection but too slow because of the model size. And, FT is also super fast for training models.

So, my question is can I use custom NLU viz. FT for intent and Flair for entity extraction with Rasa core for dialog management.

Appreciate your thoughts and help!


Sure thing, you can create custom components for your own FT-based intent classifier and flair entity extractor. I would check out the EmbeddingIntentClassfifier and CRFEntityExtractor for more info about the inputs and outputs of those components.

1 Like

Thanks a lot @erohmensing. I have started looking at the custom components page. Appreciate your help.

1 Like

@erohmensing, I got my custom Flair based entity extractor and fasttext based intent detector working. Thanks! I have another question and I would appreciate your thoughts on that. If I want to have 1 NLU model and multiple dialog models working together, how do I go about it? Let me explain the business use case: The slot requirement is different for different intents. Hence, the need for separate core models. An example of this is as follows: Add_to_mailing_list intent has the slots as from_email (email ids of people to be added) and dl_email (email ids of mailing list). In contrast, Create_email_id intent has different slots viz. from_email.

So, in this case, I guess I need multiple dialog models and 1 NLU model working together. And, I want to be able to get predicted actions from the dialog model that’s appropriate for the intent. Can you please share your thoughts on how I can achieve this?

Appreciate your help!

Hey @varun-nathan I am trying something similar here and wanting to integrate a pretrained NER model(Deepavlov).Can you tell me how did you integrated Flair which is another pretrained mod for NER in Rasa.

Like I was not able to understand what changes I should make to the custom component skeleton that RASA has provided.Can you help me here?