How to handle 2 numerical slots in 1 form?

Hello,

We have the following use case: a bot to book a hotel which asks for the following information:

  • amount of people (utter: for how many people?)
  • amount of nights (utter: for how many nights?)

We have tried to work with entity-roles, however the slot filling goes wrong. Sometimes it overwrites the previous ‘numerical’ slot (and this is pretty random behavior): For example:

  • i want a hotel
  • for how many people?
  • ten (slot: amount_of_people: ‘10’, slot: amount_of_nights: None)
  • for how many nights?
  • 2 (slot: amount_of_people: ‘2’, slot: amount_of_nights: ‘2’)

How can we prevent the slot filling to overwrite previous slots?


A part of our domain file:

entities:
- number
- amount_of:
    roles:
      - people
      - nights

slots:
  amount_of_people:
    type: any
  amount_of_nights:
    type: any

forms:
  search_form:
    amount_of_people:
    - type: from_entity
      entity: amount_of
      role: people
    - type: from_entity
      entity: number
    amount_of_nights:
    - type: from_entity
      entity: amount_of
      role: nights
    - type: from_entity
      entity: number

Some nlu data:

- intent: search_facility
  examples: | 
    - i would like a hotel
    - can you suggest a hotel for [2]{"entity":"amount_of", "role":"people"} people
    - can you suggest a hotel for [three]{"entity":"amount_of", "role":"nights"} nights
    - find a hotel for [one]{"entity":"amount_of", "role":"nights"} night for [eight]{"entity":"amount_of", "role":"people"} persons
    - find a hotel
    - want to find a hotel for [1]{"entity":"amount_of", "role":"nights"} night

- intent: inform
  examples: |
    - [one]{"entity":"amount_of", "role":"people"}
    - [one]{"entity":"amount_of", "role":"nights"}
    - [4]{"entity":"amount_of", "role":"nights"}
    - [4]{"entity":"amount_of", "role":"people"}
    - [3]{"entity":"amount_of", "role":"people"} persons
    - [3]{"entity":"amount_of", "role":"nights"} nights
    - [four]{"entity":"amount_of", "role":"nights"} nights
    - [four]{"entity":"amount_of", "role":"people"} people
    - we are with [five]{"entity":"amount_of", "role":"people"} people and want to stay [9]{"entity":"amount_of", "role":"nights"} nights
1 Like

Hello @losimons, welcome back to the forum!

Your approach seems generally good, but you don’t have much nlu training data. Especially to learn roles and groups, a lot of data is needed for DIET to learn this well. Perhaps 10x as much as you have there.

To collect more examples you can just write them yourself or share your bot and annotate the incoming data with Rasa X (you can use the free version).

I wouldn’t recommend to have entity amount_of_... for inputs like ten, I’d rather label them as abstract number, then use slot_mapping to correctly fill appropriate slot with a form

Aha, ok! We increased the amount of epochs of the DIETClassifier, but will give this a shot as well!

these entity examples are unlearnable

    - [one]{"entity":"amount_of", "role":"people"}
    - [one]{"entity":"amount_of", "role":"nights"}

rather do

    - [one]{"entity":"number"}

or use duckling to extract abstract numbers

increasing the amount of epochs for such confusing train data will not help

1 Like

Yes, we are using duckling for that, which works good! But we are actually trying to combine duckling with entity-roles :slight_smile:

these examples should work

    - [3]{"entity":"amount_of", "role":"people"} persons
    - [3]{"entity":"amount_of", "role":"nights"} nights

but you need to remove these examples or substitute entities with abstract number

also you can set auto_fill slots to false in your domain for entities. Then whatever entities are extracted, they will not override other slots

1 Like

sorry for multiple posts, but if you use roles, I’d also unite amount_of and number into one entity. For example:

    - [3]{"entity":"number"}
    - [3]{"entity":"number", "role":"people"} persons
    - [3]{"entity":"number", "role":"nights"} nights

Thank you for all the replies, got something working now!

However, I was trying to create some test data to check the performance and I noticed something strange, potentially it has to do with the fact that I am using Duckling to extract numbers and at the same time using roles. For example, after running rasa test nlu , I get the following error in the test-results RegexEntityExtractor_errors.json file:

 {
    "text": "2 nights for 3 persons",
    "entities": [
      {
        "start": 0,
        "end": 1,
        "value": "2",
        "entity": "number",
        "role": "nights"
      },
      {
        "start": 13,
        "end": 14,
        "value": "3",
        "entity": "number",
        "role": "people"
      }
    ],
    "predicted_entities": [
      {
        "entity": "number",
        "start": 0,
        "end": 1,
        "confidence_entity": 0.9993997812271118,
        "role": "nights",
        "confidence_role": 0.9364138841629028,
        "value": "2",
        "extractor": "DIETClassifier"
      },
      {
        "entity": "number",
        "start": 13,
        "end": 14,
        "confidence_entity": 0.9996367692947388,
        "role": "nights",
        "confidence_role": 0.9225713014602661,
        "value": "3",
        "extractor": "DIETClassifier"
      }
    ]
  }

But as you can see, this is clearly correct.

I will write some rules to cope with these incorrect errors, but just want to check if I was missing something here. Does this have something to do with the fact that Pretrained extractors like the DucklingHTTPExtractor are not evaluated? (found this in the docs)

Hi @losimons, glad it works for you now!

We have an open issue in our research pipeline to enable roles and groups with duckling-extracted entities. But for now, that is not possible.