Rasa NLU - Synonyms

Hi, I have a markdown nlu.md which looks somewhere like this and all entity

##intent:a1
alarm id for alarm [loss of frame ocn stmn](alarm_name:Loss Of Frame (OCn/STMn))

## synonym:Loss Of Frame (OCn/STMn)
- loss of frame ocn/stmn
- Loss Of Frame OCn/STMn
- loss of frame ocn stmn

But after training the entity alarm_name is not picked properly,

first the model is not looking into the synonym for the entity and even after doing

rasa interactive

I am not able to pass the actual value i.e Loss Of Frame (OCn/STMn) So I am doing something like this in rasa interactive

alarm id for alarm [loss of frame ocn stmn](alarm_name:Loss Of Frame (OCn/STMn))

But the model is considering the last but one ) as end of sentence!! like this alarm_name:Loss Of Frame (OCn/STMn

I want to make it learn alarm_name : Loss Of Frame (OCn/STMn)

Any help would be really appreciated.

Thanks,

Neel

Hi @neel17, I tried running your example locally and this is what I found:

First, our parser for .md NLU files isn’t picking correctly synonyms ending with “)” when specified inside the intents. Luckily this isn’t the only way to specify synonyms, you can still use ## synonym: xyz.

Second, you should add a “-” at the beginning of each intent line. So then:

alarm id for alarm [loss of frame ocn stmn](alarm_name:Loss Of Frame (OCn/STMn))

should be:

- alarm id for alarm [loss of frame ocn stmn](alarm_name:Loss Of Frame (OCn/STMn))

Now, as I mentioned earlier, synonyms ending with “)” aren’t being picked up correctly when specified inside the intent. However, you already have the exact same mapping on you synonym list! When you specified [loss of frame ocn stmn](alarm_name:Loss Of Frame (OCn/STMn)), you were creating a mapping from loss of frame ocn stmn to Loss Of Frame (OCn/STMn). But that’s already on your synonyms list:

## synonym:Loss Of Frame (OCn/STMn)   <-- to here
- loss of frame ocn/stmn
- Loss Of Frame OCn/STMn
- loss of frame ocn stmn   <-- from here

For that reason, you can remove the synonym specification from your intent (and bypass the bug in our parser). The end product would be:

## intent:a1
- alarm id for alarm [loss of frame ocn stmn](alarm_name)

## synonym:Loss Of Frame (OCn/STMn)
- loss of frame ocn/stmn
- Loss Of Frame OCn/STMn
- loss of frame ocn stmn

However, you should note that having only one example for your intent won’t yield great results. Make sure to add more examples, using different values from your synonyms list. Specifying synonyms alone won’t improve parsing results.

Hope it helps!

Hi @fede,

Thanks for your reply and effort!

I have been tried your way as well and yah the parser is able to extract the synonyms but the quality is very poor. NLU component EntitySynonymMapper is not performing well.

Please suggest any way:

  • Should I increase the training with synonyms
  • Retrain the model with different batch size

Thanks,

Neel

No problem! You should try adding more examples where you use your synonyms.