# Intent classification between two

**URL:** <https://forum.rasa.com/t/intent-classification-between-two/17875>\
**Category:** Rasa Open Source\
**Created:** [October 2, 2019, 4:33pm UTC](https://forum.rasa.com/t/intent-classification-between-two/17875 "2019-10-02T16:33:22Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![kapoorh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/kapoorh/32/2091_2.png) [@kapoorh](https://forum.rasa.com/u/kapoorh)\
**Post date:** [October 2, 2019, 4:33pm UTC](https://forum.rasa.com/t/intent-classification-between-two/17875/1 "2019-10-02T16:33:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rohitiec](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rohitiec/32/2784_2.png) [@rohitiec](https://forum.rasa.com/u/rohitiec)\
**Post date:** [October 3, 2019, 6:09am UTC](https://forum.rasa.com/t/intent-classification-between-two/17875/2 "2019-10-03T06:09:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kapoorh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/kapoorh/32/2091_2.png) [@kapoorh](https://forum.rasa.com/u/kapoorh)\
**Post date:** [October 3, 2019, 11:03am UTC](https://forum.rasa.com/t/intent-classification-between-two/17875/3 "2019-10-03T11:03:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Anand\_Menon](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@Anand\_Menon](https://forum.rasa.com/u/Anand_Menon)\
**Post date:** [October 3, 2019, 1:00pm UTC](https://forum.rasa.com/t/intent-classification-between-two/17875/4 "2019-10-03T13:00:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kapoorh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/kapoorh/32/2091_2.png) [@kapoorh](https://forum.rasa.com/u/kapoorh)\
**Post date:** [October 3, 2019, 1:24pm UTC](https://forum.rasa.com/t/intent-classification-between-two/17875/5 "2019-10-03T13:24:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Anand\_Menon](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@Anand\_Menon](https://forum.rasa.com/u/Anand_Menon)\
**Post date:** [October 3, 2019, 2:12pm UTC](https://forum.rasa.com/t/intent-classification-between-two/17875/6 "2019-10-03T14:12:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rohitiec](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rohitiec/32/2784_2.png) [@rohitiec](https://forum.rasa.com/u/rohitiec)\
**Post date:** [October 3, 2019, 2:52pm UTC](https://forum.rasa.com/t/intent-classification-between-two/17875/7 "2019-10-03T14:52:13Z")

</div>

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**

---

<div class="post-metadata">

**Author:** ![Anand\_Menon](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@Anand\_Menon](https://forum.rasa.com/u/Anand_Menon)\
**Post date:** [October 4, 2019, 6:35am UTC](https://forum.rasa.com/t/intent-classification-between-two/17875/8 "2019-10-04T06:35:31Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![kapoorh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/kapoorh/32/2091_2.png) [@kapoorh](https://forum.rasa.com/u/kapoorh)\
**Post date:** [October 4, 2019, 6:39am UTC](https://forum.rasa.com/t/intent-classification-between-two/17875/9 "2019-10-04T06:39:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Anand\_Menon](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@Anand\_Menon](https://forum.rasa.com/u/Anand_Menon)\
**Post date:** [October 4, 2019, 6:47am UTC](https://forum.rasa.com/t/intent-classification-between-two/17875/10 "2019-10-04T06:47:23Z")

</div>

correct.

---

<div class="post-metadata">

**Author:** ![kapoorh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/kapoorh/32/2091_2.png) [@kapoorh](https://forum.rasa.com/u/kapoorh)\
**Post date:** [October 4, 2019, 6:54am UTC](https://forum.rasa.com/t/intent-classification-between-two/17875/11 "2019-10-04T06:54:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Anand\_Menon](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@Anand\_Menon](https://forum.rasa.com/u/Anand_Menon)\
**Post date:** [October 4, 2019, 7:20am UTC](https://forum.rasa.com/t/intent-classification-between-two/17875/12 "2019-10-04T07:20:16Z")

</div>

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.
