How to Intent classification with similar examples in nlu.md in Rasa - rasa-nlu

I am developing chatbot using Rasa for a Contract Manager Organisation. I am facing few issues and after reading a lot on the forums and Rasa blog, I am unable to conclude to a solution for this. I have several similar intents with similar examples like -
“inform_supplier_start_date” and “inform_contract_start_date”.
“inform_supplier_email” and “inform_customer_email” and “inform_reviewer_email”
Now the issue is, for both the categories of intents the example sentence in nlu.md is same. What I exactly mean is-
##intent:inform_suppler_start_date
-what is the supplier [Microsoft] (supplier_name) start date
-[EON Digital] (supplier_name) start date
##intent:inform_contract_start
1) start-date of [O2 Mobile phones] (contract_name)
2) [O2 Mobile phones] (contract_name) start date
The model isnt able to differentiate and identify the correct intent. It is getting confused and identifying the wrong intent, since the words in these intents are similar.
I need correct intents to be recognised ,so that accordingly, In custom action i can query the Database and get the corresponding result for supplier and contract.
I have many fields like this for which the example data and user queries will be same. For Example-
customer_email & supplier_email & reviewer_email
total_spend_contract & total_spend_supplier & total_spend_customer
contract_number_for_supplier & contract_number_of_contract & contract_number_organisation
What exactly I should be doing to get correct classification. One solution i am thinking of is merging the intents like “supplier_start_date” and "contract_start_date" as one “start_date” and check for the extracted entity inside custom actions in both supplier and contract database. But I dont think that would be proper usage of Natural Language.
Please Suggest, I shall be highly greatful for the same. Regards.

As the examples for your intents are very similar, the model will not be able to differentiate between them. Also the intent is actual the same, inform_suppler_start_date and inform_contract_start inform the bot about a start date. What kind of start date it is should be figured out via the entity recognition. So I would propose to merge the similar intents and check what the entity recognition detected as entities. Depending on whether a supplier or a contract was found, you can execute query A or B.

Related

How do I use capture groups in Regular Expressions in Bot Composer

I am attempting to build a Microsoft Teams bot using the Bot Framework Composer. What I would like to do is create an integration with ServiceNow. The goal would be that if anyone posts a record number (ex. REQ0123456, INC0123456, KB0123456) into the group or direct chat (with the bot), the bot would look up that record and provide a card or a short summary of the record to the chat.
To avoid creating a completely separate intent for each record type, I was hoping to use RegEx to gather the match into 2 capture groups; one for the tbl_code and one for the number.
Here is the entry for the user input:
> add some example phrases to trigger this intent:
- look up {conversation.sn_record.tbl_code=REQ}{conversation.sn_record.number=0123456}
- lookup {conversation.sn_record.tbl_code=REQ}{conversation.sn_record.number=0123456}
- {conversation.sn_record.tbl_code=REQ}{conversation.sn_record.number=0123456}
- lu {conversation.sn_record.tbl_code=REQ}{conversation.sn_record.number=0123456}
> entity definitions:
# regex sn_record tbl_code, number = /([a-z]{2,4})([0-9]{7})/mi
The Issue I'm Having
I don't know how to get the values back from the individual capture groups. I would like to have them separate so that I can determine which table needs to be queried. I could probably just use the entire match and the search API in ServiceNow for the whole record string, but I would still like to know how to use capture group values.
I'm currently using turn.recognized.text, but I don't think this is the best method for what I'm looking to do. This returns the entire regex match.
I'm very new to this framework, so please be gentle. :) Let me know if there is more information I can provide.
Thanks all.
Best Regards,
Josh
I was able to figure this one out using the examples in the ToDosSample bot.
The answer was to use named capture groups and then add them to a dialog property to use in the corresponding dialog.
For reference here are the changes I had to make:
New Regex
(?<sn_record>(?<tbl_code>[a-z]{2,4})(?<numbers>[0-9]{7}))
New Dialog Properties
dialog.sn_record = #sn_record
dialog.sn_tbl_code = #tbl_code
dialog.sn_numbers = #numbers
New response
- Okay, looking up ${dialog.sn_tbl_code}${dialog.sn_numbers}

How to tie entity recognition to intent prediction?

I'm having a problem with Rasa_NLU giving me the wrong entity for an intent. An example is “How do I get to New York?” Where, I tagged the training data to name the entity “city”. In a different intent, it was tagged “destination”.
intent: check_weather
what is the weather in new york?
intent: get_directions
how do I get to new york?
I have a script that takes action on the intent returned and processes the entities. If I get back the get_directions intent, I’ll look in the json for the destination entity, but it has city instead. Using ner_crf, is there a way to de-emphasize entities in an intent, so that the classifier is biased to those that the intent was trained for? That is, the classifier would be weighted to giving a destination for get_directions, and a city for get_weather?
The typical answer I've found is to add more training examples. I'm up to 60 for each of the two intents I have, and it is still getting it wrong.
As of right now, you can only featurize/unfeaturize all entities for a certain intent. I can see that that's not really your use case since both intents require entities -- just different ones. There is currently a community PR open to add per-intent featurization of specific entities, so it will be available in the future.

Communication.ContactName Entity not recognized in LUIS Intent

I have created several utterances in LUIS for an intent to create new meeting items in my application.
I have tagged the corresponding elements in the utterance to recognize the name of the invited person and the date / time of the meeting.
When I train the model and test it afterwards, date and time is recognized every time. Not so for the contactname. I have tried all possible things like adding the utterance as pattern, adding phrase lists, but no success.
What can I do, to make this work? Is there anythink I am missing?
If you're using simple entities, keep in mind that you'll need to train 10-15 utterances, and that there should be different names in all utterances. Using the same name repeatedly may cause faulty training.

Luis intents with composite terms

I am developping a bot using the LUIS API by Microsoft. This bot must understand queries related to shopping like "I want potatoes".
The only thing my application is struggling with is detecting intents from composite terms:
For the query "I want chopped steak", LUIS will detect chopped as an intent but not "chopped steak". I tried creating a productName phrase list feature and setting different composite terms including "chopped steak" but this doesn't seem to work.
What could I do to achieve that purpose ?

CustomerInfo nickname and reference_id usage in different platforms

I find that the nickname and reference_id fields work differently across platforms and I'd like to get clarification on how they should be used.
With the API, I can retrieve and set both these fields.
In the web-based dashboard, both fields are displayed and can be edited if present, but there's no way to enter a nickname when creating a new customer.
In the Register iOS app, none of these fields are shown or editable. They're also absent when creating a new customer.
What I want to do is map Square Customers to our existing members, but we're facing three problems:
reference_id seems to map perfectly with our existing member numbers but, as mentioned, it's nowhere to be seen in the Register app.
Searching customers in the Register app only searches in names and emails. It would really help us if it searched in reference_id as well.
CustomerGroupInfo is read-only via the API (and not even an endpoint). We would map these to our membership levels.
As of now, I'm looking at ugly workarounds, but I wanted to know if something in the roadmap could help us out. Thanks in advance to the people at Square!

Resources