Search code examples
nlpartificial-intelligencechatbotrasa-nlu

Rasa NLU: How to use multiple categorical slots with same values?


I just started working with Rasa NLU and I have some problem understanding the usage of categorical slots with same values. I have 3 different types of risk, each a categorical slot with values: low, medium and high.

How can the bot differentiate between the three risks and understand which slot to be filled up, given the intent is same for each. Or do I need to use different intents for each?

Right now what I see is (I removed unrelated logs):

How tired are you?
1: low (low)
2: medium (medium)
3: high (high)
medium
DEBUG:rasa_core.processor:Received user message 'medium' with intent '{'name': 'inform', 'confidence': 0.88372623999657118}' and entities  '[{'start': 0, 'end': 6, 'value': 'medium', 'entity': 'fatigue', 'extractor': 'ner_crf'}]'
DEBUG:rasa_core.processor:Current slot values: 
    fatigue: medium
    injury: None
    stress: None
How stressed are you?
1: low (low)
2: medium (medium)
3: high (high)
low
DEBUG:rasa_core.processor:Received user message 'low' with intent '{'name': 'inform', 'confidence': 0.88762049990079372}' and entities  '[{'start': 0, 'end': 3, 'value': 'low', 'entity': 'fatigue', 'extractor': 'ner_crf'}]'
DEBUG:rasa_core.processor:Current slot values: 
    fatigue: low
    injury: None
    stress: None

All the user replies have the intent inform. An example story is:

* _greet[]
 - utter_ask_fatigue
* _inform[fatigue=low]
 - utter_ask_injury
* _inform[injury=medium]
 - utter_ask_stress
* _inform[stress=low]
 - utter_on_it
 - action_reply

Solution

  • you can do it with one entity and four slots

    the entity may be defined as type "info", with text values (i.e. low, medium, high).

    The four slots: the first one is "info", which will auto filled by recognized entity "info" defined previously. The other three would be "fatigue", "stress" and "injury", which can be filled by bot actions such as action_fill_fatigue, action_fill_stress and action_fill_injury.

    an example story will make it clear:

    * _greet[]
     - utter_ask_fatigue
    * _inform[info=low]
     - action_fill_fatigue
     - utter_ask_injury
    * _inform[info=medium]
     - action_fill_injury
     - utter_ask_stress
    * _inform[info=low]
     - action_fill_stress
     - utter_on_it
     - action_reply