Wrong answer from QnAMaker with keyword - botframework

I have been working with the Microsoft Bot Framework v4 and QnA Maker(GA). A problem that I have come across is when the user types a keyword like 'leave absence'. There are 10+ kind of leave absence questions. The QnAMaker will send back the one with the highest score no matter what kind leave it is (not the right answer).
I have a tree to answer question that looks something like this:
Leave of absence
Parental leave
Maternity leave
Care leave
etc.
Each kind can have one or more related questions and a leave can also have a sub-leave.
When the user ask 'leave absence', the bot should answer: 'Which kind of leave absence' and after the user can ask a question about it.
When the user ask 'How many days can I have for a parental leave', the bot should answer straight from the QnA: 'You can have 10 free days'.
My question is, how can I implement this in v4 so the user can receive the right answer? Is LUIS a option for this? Any suggestions?
Thank you.

Its difficult if you have question after question to ask the user. For this, you may need to have a separate Dialog class with a
List<string>
for the set of questions built on runtime of course. At the end it could return back to the original Dialog class. I have implemented something similar for job openings on different posts. Each post having its own set of questions. The control remains in this QuestionnaireDialog (the separate Dialog class) asking next question once the user answers the current question. I don't think QnA Maker will help on this. I have not seen QnA maker much nor v4. I have done the above on v3 and the intent-response mapping was in a database table.
My suggestion is to flatten your structure if possible from multiple levels to just 2-level to avoid the tree.
For eg:
Leaves --> Care Leave --> Medical Care Leave
--> Family Care Leave
Change the structure to
Leaves --> Medical Care Leave
--> Family Care Leave
So that you could manage it with LUIS entities. Simply asking about leaves will bring a response that will have all the type of leaves available and asking specifically about a leave type will bring a different response specific to the type. Again I have done something similar without QnA maker in v3. If you can't flatten the structure then you will probably have to bring in a mixture of the two approaches because you want to respond to user's specific leave type query (LUIS entities) and take user through a questionnaire.

Related

In QnA Maker is there a way to preserve edited QnA pairs, so that they don't get overwritten when doing a "Refresh" import?

My scenario is that our marketing department have various (FAQ related) URL's , each of which contains approximately 20 question and answer pairs, per URL.
I have imported these URL's into QnA maker and (importantly) the marketing department have finessed and tidied the answers held in the knowledge base (* reason below)
The marketing department still use a process where they add new question and answers to the relevant URL when needed, so - for example URL "X" might contain 20 Question and Answer pairs currently , all of which have been imported (and tidied/finessed) in the KB.
They want to add a new question and answer pair to the URL (i.e. make the change on the website), and then they want to "Refresh" that URL into the Knowledge Base. The problem is (I believe), that the original 20 question and answers pairs on the web url will actually over-write the "finessed" ones in the KB.
Is there any way to avoid this? Ideally just (somehow) bring in the "newly added" Question and Answer pair? (without having to copy/paste the content from the web to the KB?)
(*)the reason this needed doing was simply that, on the source URL's the answers were quite verbose, and included images, which work fine on the actual website, but when these answers are imported , they didn't look elegant within the bot , so they have been edited (within QnA maker) so they now look good when yielded by the bot)
Importing URLs into QnA Maker that only contain new content will always overwrite a knowledgebase with the content found within. This is true whether that is from doc linked from a URL, an uploaded doc, or some other method. If you are wanting to add new questions to an existing knowledgebase, then you first need to export that KB, make updates to the content contained within it (i.e. add your new questions to the old), and then upload/provide a link to that new data set.
If you are wanting to do this via REST API, then you should look over the QnA Maker REST API Reference docs. By using calls like GET, LIST, and UPDATE, you should be able to achieve what you are wanting to do. There are samples you can reference, as well, to help you on your way.

Azure QnA Merging Same Questions

We are uploading a PDF with semi structured Question & Answers. QnA maker is merging same question if they are successive. If there is some other question exist between them, then QnA maker is not merging same questions. For example.
Q Machine was not able to be started
Answer 1
Q Machine was not able to be started
Answer 2
Q Burning plastic smell on machine
Answer 3
Now the QnA Maker will train it like this
Q Machine was not able to be started
Answer 1
Answer 2
Q Burning plastic smell on machine
Answer 3
Why is QnA is behaving like this and how to separate same questions. Help is required.
This is expected behavior. QnA works on the 'one question (and related, similar questions)' to one answer idea, and expects unique questions for the queries. The QnA documentation states:
A knowledge base consists of question and answer (QnA) sets. Each set has one answer and a set contains all the information associated with that answer. An answer can loosely resemble a database row or a data structure instance.
The required settings in a question-and-answer (QnA) set are:
a question - text of user query, used to QnA Maker's machine-learning, to align with text of user's question with different wording but the same answer
the answer - the set's answer is the response that's returned when a user query is matched with the associated question
Each set is represented by an ID.
The optional settings for a set include:
Alternate forms of the question - this helps QnA Maker return the correct answer for a wider variety of question phrasings
Metadata: Metadata are tags associated with a QnA pair and are represented as key-value pairs. Metadata tags are used to filter QnA pairs and limit the set over which query matching is performed.
Multi-turn prompts, used to continue a multi-turn conversation
QnA Maker doesn't differentiate between the two questions because it isn't two questions. It's literally the same question with two different answers.
This particular case would be a good use of QnAMaker's multi-turn prompt feature, where, after the customer has put in the query 'The machine won't start', QnA can follow up with a prompt that says "Which machine did you mean? Machine A or Machine B", and whichever they choose leads to the correct answer. I would look into Multi-Turn Conversations for your knowledgebase.

Handling typos / misspellings on list entities

What is the best practice approach to handle typos / misspelling on LUIS List Entities?
I have intents on LUIS which use a list entity (specifically Company Department - HR, Finance, etc). It is common for users to misspell this when putting forward their utterance. LUIS expects an exact match, it doesn't do a "smart" match, and therefore doesn't pick up the misspelled entity.
a) Using bing spell check is not necessarily a good solution. e.g. Certain departments are acronyms such as VRPA - and bing wont correct a typo there.
b) When I used LUIS a year ago, I would pre-process the utterance and use a Levenshtein distance algorithm to fix typos on list entities before feeding them to LUIS.
I would imagine that by now LUIS has some better out of the box way of handling this very common use case.
I'd appreciate input on what the best practice approach is to handle this.
#acambitsis and I exchanged messages via his UserVoice ticket, but I'm going to post the answer here for others.
A combination of Bing and Simple Entities might be what you're looking for, then (they're machine-learned).
I was able to accomplish something close and attached images.
In entities, I created a Simple entity with the role, VRPA. In intents, I created the Show Me intent and added sample utterances "Show me the VRPA" and "Show me the VPRA". I clicked on V**A and selected the Simple Entity:VRPA role. After training, I tried "show me the varp" and it correctly guessed "varp" was the "Simple:VRPA" entity.
You may also find RegEx entities useful. For acronyms, you could do something like: /[vrpa]/i and then any combination of VRPA/VPRA/VARP/ARVP would match.
I highly recommend reading through the Entity Types and Improve App Performance to see if anything jumps out to solve your particular issues.
This may not do exactly what you're looking for. If not, I'd recommend implementing a fuzzy-matching algo of your choice.
entities
intents

Understanding RASA-Core stories

I was trying to understand the examples given in RASA core git. I have seen an example story
greet
utter_ask_howcanhelp
inform{"cuisine": "italian"}
utter_on_it
utter_ask_location
But I didn't understand what {"cuisine": "italian"} is. Whether it is the default value of the slot or user has to provide italian in the input string. Can anybody help me to understand how to write stories in RASA core
Regards
One of the most powerful features of any dialog flow is stories. This is how you are telling the model what are the possible flows of conversational dialog.
In the questions you have asked about. Clearly the Italian is not the default value.
inform{"cuisine": "italian"}
Here you are telling the machine learning engine that you are looking for an Intent 'Inform' which will have a slot named cuisine. Here Italian is an example. At the runtime, it can be anything. You can also have another story line where Intent inform without cuisine slot. That story might ask for cuisine in the next dialog.
Defining the story lines, should not be confused with programming language. It is just an indication for Machine learning algorithms.
More details about using slots can be found here and here
This story describes how the dialogue model would behave in the case the user said something like "I want to eat Italian food". As you note, the slot "cuisine" is set to the value "italian".
In the restaurant example, the cuisine slot is a simple TextSlot. This means that the dialogue model only gets to see if the slot has a value or not. The behaviour would be exactly the same if the user had asked for chinese food, thai food, or anything else.
If you want the value of a slot to influence the dialogue going forward, you can use a different slot type, e.g. a categorical slot

LUIS entity not recognised

I trained my luis model to recognize an intent called "getDefinition" with example utterances such as: "What does BLANK mean" or "Can you explain BLANK to me?". It recognizes the intent correctly. I also added an entity called "topic" and trained it to recognize what topic the user is asking about. The problem is that luis only recognizes the exact topic the user is asking about if I used that specific term in one of the utterances before.
Does this mean I have to train it with all the possible terms a user can ask about or is there some way to have it recognize it anyway?
For example when I ask "What does blockchain mean" it correctly identifies the entity (topic) as blockchain because the word blockchain is in the utterance. But if I ask the same version of the question about another topic such as "what does mining mean", it doesn't recognize that as the entity.
Using a list or phrase list doesn't seem to be solving the problem. I want to eventually have thousands of topics the bot responds to, entering each topic in a list is tedious and inconvenient. Is there a way LUIS can recognize that its a topic just from the context?
What is the best way to go about this?
Same Doubt, Bit Modified. Sorry for Reposting this here.
At the moment LUIS cannot extract an entity just based on the the intent. Phrase lists will help LUIS extract tokens that don't have explicit training data. For example training LUIS with the utterance "What does blockchain mean?" does not mean that it will extract "mining" from "What does mining mean?" unless "mining" was either included in a phrase list, or a list entity. In addition to what Nicolas R said about tagging different values, another thing to consider is that using words not commonly found (or found at all) in the corpuses that LUIS uses for each culture will likely result in LUIS not extracting the words without assistance (either via Phrase list or list entity).
For example, if you created a LUIS application that dealt with units of measurement, while you might not be required to train it with units such as inch, meter, kilometer or ounce; you would probably have to train it with words like milliradian, parsec, and even other cultural spellings like kilometre. Otherwise these words would most likely not be extracted by LUIS. If a user provided the tokens "Planck unit", LUIS might provide a faulty extraction where it returns "unit" as the measurement entity instead of "Planck unit".

Resources