Same statement different Intents under different context

tommetcalfe
rasa-core
rasa-nlu

(Ashutosh) #1

My chatbot can answer sales related queries for different products(ms, hsd, power,turbo) and for different period(eg. In last 3 days, in last week, in last month, yesterday's etc). to answer sales queries two slots namely period and product must be filled. So if user has not provided any of these two fields chatbot must ask product using utter_ask_product and period using utter_ask_period template defined in domain.yml file. Now problem is that I have defined similar statement under different intents. As you can see below:

    ## intent:custBelowHist
    - do you mind telling me below historical customer
    - for [ms](product)
    - in [last 3 weeks](period)
    - and who are below historical customers
    - ok and who are customer below historicals for same product and same period
    - worst 10 [turbo](product) dealers

    ## intent:findBottom10Cust
    - can you please tell me bottom customer in my sales area
    - for [power](product)
    - in [last 4 days](period)
    - for [last 3 months](period)
    - can yot tell me bottom 10 customer for [hsd](product) in [last 4 days](period)
    - and waht about bottom 10 dealers in same period for [ms](product)
    - hi please show bottom sales performer for [non branded fuel](product)

    ## intent:findTop10Cust
    - and who are top customers
    - for power(product)
    - in [last 3 days](period)
    - ok can you please show top 10 dealers in sales of [ms](product)
    - hi please show top sales performer for [non branded fuel](product)
    - please show top sales gainers for [branded fuel](product)
    - who are best performers in sales for [branded fuel](product)
   - hi top sales gainer for [hsd](product) dealers

Stories format

## Generated Story -3620157380320438672
* aboutbot
    - utter_aboutbot
* custBelowHist{"period": "last 4 days"}
    - slot{"period": "last 4 days"}
    - utter_ask_product
* custBelowHist{"product": "hsd"}
    - slot{"product": "hsd"}
    - action_custbelowhist

## Generated Story -1539628878583761200
* greetme
    - utter_greetme
* findBottom10Cust{"period": "last 3 months"}
    - slot{"period": "last 3 months"}
    - utter_ask_product
* findBottom10Cust{"product": "power"}
    - slot{"product": "power"}
    - action_bottomcust

## Generated Story -1532628878583761200
* greetme
    - utter_greetme
* findTop10Cust
    - utter_ask_product
* findTop10Cust{"product": "power"}
    - slot{"product": "power"}
    - utter_ask_period
* findTop10Cust{"period": "last 3 months"}
    - slot{"period": "last 3 months"}
    - action_top10cust

So flow goes like this whenever user ask any one of the below questions(each one has different intent). For below questions RASA NLU has no difficulty to understand intent

Please tell me top 10 customers?
can you please tell me bottom customer in my sales area?
do you mind telling me below historical customer?

In any of the above scenario Chatbot must execute utter_ask_product which will ask for which product? and the user will say for hsd but here RASA NLU having difficulty to understand intent as same statement corresponds to other intent as well and same thing is happening when user says for last 3 months in response to utter_ask_period.

My assumption is if I provide sufficient examples for NLU and create enough stories then RASA NLU and RASA CORE will understand context of each user response even if they are similar statement . Please correct me if I am wrong. If this is not right approach can you please tell me what would be correct approach.

Thanks


(Tom Metcalfe) #2

You certainly could provide a lot of data to improve the accuracy, could be a little tedious to generate though.

Couple things for you to try here:

1 - Combine your intents to something like customer_query and use more entities to separate the type of query (i.e. “top”, “bottom”, “historical”)

2 - Use a form to discard intent classification - you would just need to define slot mappings for period and product. For a guide on this, I highly recommend using Akela’s implementation of formbot as a skeleton (this is in the rasa_core repo here)