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