Intent classification between two

Hi,

I am facing an issue between classification of two intents.

First use case is: What is Oracle?

So for this I created one intent

#intent: define_oracle

  • what is Oracle
  • define Oracle

Story for it is:

*define_oracle

-utter_define_oracle

Second use is: User: where are the logs of database? Bot: of which database? User: Oracle Bot: location of logs…

So I created:

#intent: logs_db

  • where are the logs of database
  • where are the logs of [Oracle] (db_name) database
  • where are the logs of [SQL server] (db_name) database

#intent: database_name

  • [Oracle] (db_name)
  • [SQL server] (db_name)

Story for it is:

  • logs_db
    • utter_ask_db_name
  • database_name{“db_name”:“Oracle”}
    • utter_response

Another story:

  • logs_db{“db_name”:“Oracle”}
    • utter_response

Issue is : If user writes only Oracle then it doesn’t pick define_oracle intent. And respond with did_not_understand. I want if user doesn’t ask for logs and writes only Oracle then it should respond with define_oracle response and if user ask for logs and writes Oracle then bot should respond for about logs location.

Please suggest me what should I do?

Thanks and Regards

Harsh

@amn41 Hi Alan, Can you please help us on this?

Hi @Anand_Menon, will you please help us out on this?

Hi @kapoorh,

#intent: define_oracle

  • what is Oracle
  • define Oracle

#intent: logs_db

  • where are the logs of database
  • where are the logs of [Oracle] (db_name) database
  • where are the logs of [SQL server] (db_name) database

The above two are correct intent classification, but

#intent: database_name

  • [Oracle] (db_name)
  • [SQL server] (db_name)

As per nlu database_name / db_name is an entity which by using ner_crf we extract out of the user query.So these are not intents they are entities

Solution

So when a user give query like

  • where are the logs of Oracle database

The rasa NLU parser will provide something like

intent:logs_db,confidence:0.9,entitities:[[value:“oracle”,entity:“db_name”]]

Write an action which could extract this entity value form your parser and give the response or

make use of rasa slot to extract value db_name entity and give a response based on the slot value (eg:oracle,mysql …etc)

So for question like

What is oracle?

you can specify some answers in utter_define_oracle in the domain.yml

I hope it helped

Hi Anand,

Thanks for the quick reply!! Really appreciate.

You are correct, but conversation can be like:

User: where are the logs of database?

Bot: which database?

User: Oracle

Bot: logs location is this…

How should I handle this scenario?

Thanks and Regards

Harsh

well in the case you have two option A user : where are the logs of database?

here the entity db_name will be empty so you can write so custom logic like

if entity like db_name has no value just use dispatcher to call utter_ask_db_name or something

B Simplest and best way is to use slot filling itself user : where are the logs of database? when the user ask a intent like this hit a form action like form_db_logs

class form_db_logs(FormAction)

{

@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
{ 
 return ['db_name']
}
def slot_mappings(self):
    return {"db_name": self.from_entity(entity = "db_name",intent = ['logs_db']

}

The above code give the answer for database log only if the user gives the database name else the bot keeps on asking for db name

I hope it helps

Hi Anand,

As you suggested we have implemented FormPolicy but issue is with:

User : Where the logs of database?

Bot: which database?

User: Oracle (here we are not setting any slot so action server throws an error)

and its classifying an intent define_oracle

Hi @rohitiec

Okay the issue here is

Since your training samples has something like

#intent: define_oracle

  • what is Oracle
  • define Oracle

Oracle would definitely be classified to define_oracle.So you either have to make a new intent as stated in the rasa examples

#intent: inform

  • [oracle] (db_name)

  • my database is [oracle] (db_name)

  • [oracle] (db_name) is my database

  • [mysql] (db_name)

    return {“db_name”: self.from_entity(entity = “db_name”,intent = [‘logs_db’,‘inform’]

Hi @Anand_Menon,

In case whenever user will write Oracle only, then rasa nlu will give inform intent with higher confidence instead of define_oracle.

Thanks and Regards Harsh

correct.

Anand, Which is wrong. If user ask “Oracle” then define_oracle should come. Inform intent should come whenever it will ask about logs.

Well that is not possible, you can’t map an intent to multiple classes.

So if user ask like define oracle or explain about oracle it should be mapped to define_oracle else it should be mapped to inform.