Custom EntityExtractor when implemented , default entity extractor stops working

I am trying to add a custom entity extractor to extract entities (lookup) with incorrect spellings. However, when I add that custom extractor inside pipelines configuration, right below SpactEntityExtractor and CRFEntityExtractor, only custom extractor is working and default two extractors are not working. However, if I remove custom extractor, I am able to get entities from CRF and Spacy.

Did I miss something or all three extractors are supposed to work?

Do you get any error? Can you paste it here?

How does you pipeline look like? Can you share the code of your custom extractor?

You can have as many extractors as you like. So, it should be possible to add all.

It was my mistake I guess. I didn’t know the position of pipelines matter. My custom component was after CRF and spacy’s and once I moved it before them, it started working. I am not sure if that was the case either. Sorry for the late reply though. Thank you!

Furthermore, can you confirm the method to pass defaults params through pipeline for custom component.

Suppose my default should be like {'param_1: [‘a’,‘b’]}

How should I pass these through config file.

If your custom component defines some default values like

    defaults = {
        "param_1": [‘a’,‘b’]
    }

you can overwrite those in your config.yml file by

language: en

pipeline:
  - name: "WhitespaceTokenizer"
  - name: "YourCusomComponent"
    param_1: ['c', 'd']
...

Does that answer your question?

Yes, I did the exact same thing but somehow it didn’t work.

My custom component is defined as below. It takes lookup name and autocorrect the spelling mistake in the entities. For example I have horoscope lookup, so if someone types arias. I will make a autocorrected noun to be ‘aries’. I am trying to send the name of lookups through the params in config and it is not working.

class AutocorrectNouns(Component):
    """A pre-trained sentiment component"""

    name = "autocorrect_nouns"
    provides = ["entities"]
    requires = []
    defaults = {"lookup":["horoscopelist"]}
    language_list = ["en"]

In My config

image

but is not working.

What exactly is not working? Do you get any error? If yes, please paste it here. Is the path to your custom component in the config.yml correct? Are you sure it is called? Would be great if you could paste some log here. It also might help to start your bot in debug mode --debug to get more log statements.

Below is my config, where I have added my custom component named “autocorrect_entity.AutocorrectNouns” and params lookup: [‘horoscopelist’] image

And my custom Component:

As you can see, near the cursor, I have printed the default params. But on training, the parameters are empty.

Now, on doing

rasa train -vv

I see no error, and prams printed is empty as well.

Here’s the screenshot

You should use

self.component_config["lookup"]

instead of

self.defaults["lookup"]

The defaults you define in your component and the configuration parameters from the config.yml file are all written to self.component_config in the init of the component. Can you adapt your code and check if it is working?

Yes it worked. I didn’t go through documentation thoroughly, my bad. Thank you for your help.

I have been constantly conversing questions. I had next query.

When you update something in your custom component and you head towards training. The “rasa train” command throws “Nothing changed. You can use the old model stored at '/var/www/ek-assistant/models/20191210-154804.tar.gz”

So, I need to force update to reflect the changes, right? Currently, I either delete all models and retrain or do “rasa train --force”. Is there any other way?

No, those are the two possibilities.

Oh, thank you! It would be wonderful if it can automatically acknowledge the changes. But both approaches seem easy for now.