Intent sample utterance (training phrase) structure - which is best? - dialogflow-es

3/28/19 update: Nick from Google did a great job of answering from the DialogFlow side. It would be great to get an answer from the ASK team as well!
We have a voice app available as both an Alexa skill and a Google Action (with DialogFlow). With both ASK and DialogFlow, we have an intent with a sample utterance / training phrase structure of:
leading carrier phrase {main slot} trailing phrase
There are many leading phrases, and many trailing phrases. The phrases are short. There are a maximum of 6 words in these phrases, and most have 3 words. Not all sample utterances have both a leading and trailing phrase. There are 100+ sample utterances with these combinations.
I'm wondering if we should create new slot values of {leading phrase} and {trailing phrase}. Then populate each of them with the respective phrases that are currently in the sample utterances. Then change the sample utterances from the current 100+ to only these 4:
{main slot}
{leading phrase} {main slot}
{main slot} {trailing phrase}
{leading phrase} {main slot} {trailing phrase}
I think we'll get better logging this way, and it seems cleaner. But I am nervous about it. What is the expected impact to the accuracy of the NLU for making this change to both platforms? Better? Worse? What is the best practice recommendation for this with ASK? What is the best practice recommendation for DialogFlow?
#Nick -
Thanks for the answer below. Let me paraphrase and see if I understand - if entities are used exclusively, the impact is:
1) if the user speaks an exact match for a combination of known entities, recognition can be better.
2) if a user speaks a phrase that does not match known entities, the intent won't be matched as strongly compared to the same situation when entities are not used. This could result in the intent not being selected.
Is this correct?
I'm not sure about the case where the utterance is not an exact match to the combination of entities, but it is close. Is the result that (compared to when entities are not used) the intent will be matched less frequently? Maybe you can clarify your statement "If the user is going to prefix or suffix a phrase, and it's irrelevant, it will help Dialogflow's ML matching by fuzzy matching the intent based on similar phrases."
Maybe an example would be helpful. Let's compare these two training phrases:
'tell me about {main slot} with french fries'
{leading slot} {main slot} {trailing slot}
Where:
{main slot} contains 'hamburger'
{leading slot} contains 'tell me about' but does NOT contain 'tell us about'
{trailing slot} contains 'with french fries'
Now let's say the user utterance is "tell us about hamburger with french fries". Is a match to this intent more or less likely using slots/entities?

If you define everything in entities, it can make it more accurate as Dialogflow will implement some biasing to identify the right entity (or ignore this intent entirely).
However, using an entity really only needs to be used for vocabulary that you're actually interested in. If the user is going to prefix or suffix a phrase, and it's irrelevant, it will help Dialogflow's ML matching by fuzzy matching the intent based on similar phrases.
Based on your question, it seems like you actually do care about the phrases to some extent, so using entities could be a good fit, and would be easier to maintain than 100 separate training phrases.

Related

Dialogflow Detect Intent Matching Confidence And Entity Value Selection

I am looking to understand how detect intent confidence impacts entity value selection in Dialogflow. For example, using two user generated phrases:
Phrase 1: "For snack yesterday I had an apple and peanut butter". This phrase has an intent detection confidence of '1' and 'snack' and 'yesterday' are tagged correctly to their respective entities, and the foods, 'apple' and 'peanut butter' are correctly matched within their entity [food], with values of 'apple' and 'peanut butter' respectively.
Phrase 2: "Are the snack yesterday I had an apple and peanut butter". This phrase was mumbled by the user or garbled by Siri (we use an iOS voice app). Here the intent detection confidence is '0.852' and while 'snack' and 'yesterday' are tagged to their entities correctly, the foods are not treated as above. Specifically, while both are tagged to the correct entity [food] and 'apple' was correctly tagged to 'apple', the 'peanut' of 'peanut butter' was tagged as one food [value = 'peanut'] and the 'butter' of 'peanut butter' was tagged as another food [value = 'butter'].
As context we have ~500 intents, the intent matched above has ~400 training phrases (clearly not including 'Are the...') and ~200 entities, the largest of which has 29,998 values.
So it appears the intent detection confidence impacts the entity parameter value matching. Can anyone shed any light on this? From our viewpoint, it is not a useful 'feature'. Quite the opposite.
When searching for a matching intent, Dialogflow scores potential matches with an intent detection confidence, also known as the confidence score.
These values range from 0.0 (completely uncertain) to 1.0 (completely certain). Without taking the other factors described in this document into account, once intents are scored, there are three possible outcomes:
If the highest scoring intent has a confidence score greater than or equal to the ML Classification Threshold setting, it is returned as a match.
If no intent meets the threshold, a fallback intent is matched.
If no intents meet the threshold and no fallback intent is defined, no intent is matched.
Update: As per the GCP DialogFlow development team:
Scores are referred to intent recognition confidence
Parameter extraction is not taken into account when scores are computed"
In other words, there is no relationship between intent classification confidence and entity extraction.
The described behavior could potentially be a bug within DialogFlow or something specific to your GCP project and further inspection for your GCP project is required with GCP Support to investigate why this is happening. You can create a GCP Support Case.
Over the last few weeks we have interacted at some length with GCP Support who've interacted with the DF engineering team.
The short answer is they indicate the entity value extraction is 'as designed', and specifically, when using a composite entity (a nested entity structure), values that match input terms (here, 'peanut', 'butter' and 'peanut butter') are extracted and matched at random. So a user's utterance of 'peanut butter' may be matched to 'peanut' and 'butter' or 'peanut butter' at random.
This behavior cannot be controlled by adding additional training phrases to the agent.
From our point of view, the behavior is not as desired but we understand the implications for our design. Hopefully this 'answer' helps others navigate this and similar issues.

I dentification of training phrases for Dialogflow

I am trying to build a chatbot using Google Dialogflow. I have a set of 100 utterances with me for different Intents. How can I select the training phrases out of this 100 utterance list? Is there any rule to select the unique patterns from the list on the basis of entity pattern or unique paraphrase?
It would be very helpful if you could share the answer here.
Thanks!
Training phrases are example phrases for what end-users might type or say, referred to as end-user expressions. For each intent, you create many training phrases. When an end-user expression resembles one of these phrases, Dialogflow matches the intent.
For example, the training phrase "I want pizza" trains your agent to recognize end-user expressions that are similar to that phrase, like "Get a pizza" or "Order pizza".
You don't have to define every possible example, because Dialogflow's built-in machine learning expands on your list with other, similar phrases. You should create at least 10-20 (depending on complexity of intent) training phrases and try to include more unique training phrases which are relevant to that specific Intent, so your agent can recognize a variety of end-user expressions.
Reference link :https://cloud.google.com/dialogflow/es/docs/intents-training-phrases

Word tolerance of training phrases in Dialogflow (- to create a Google Action)

I have an important question, at the moment i am writing my last essay before starting with my bachelor thesis. It is about voice apps, which includes the google actions for sure.
But i need some informations about the word tolerance of the training phrases. And I was not able to find some information on the internet yet. Does Google only recognize the training phrases typed in by the developer or can Google add some phrases by time or with training (so that the user can say different phrases to trigger an intent which were not typed in from the developer in the beginning) ?
It is really important for my essay. So I would be very happy if you can help me with this question.
I wish you a nice weekend!
Dialogflow uses the training phrases to build a machine-learning algorithm to match similar phrases that aren't exactly what you enter.
For example, the training phrase "I want pizza" trains your agent to recognize end-user expressions that are similar to that phrase, like "Get a pizza" or "Order pizza".

Map to the wrong LUIS intent

I am facing an issue whereby words that does not match with any intents, it will assume it belongs to intent with the most labeled utterances.
Example: if
Intent A consists of utterances such as Animals
Intent B consists of utterances such as Fruits
Intent C consists of utterances such as Insects
Intent D consists of utterances such as People Name
Desired: If the random word(s) does not fit into any of the luis intent, it will fit into none luis intent. Example of desired: If word such as "emotions" or "clothes" were entered, it will match as "None" intent.
Actual: When user type random word(s), it match with luis intent with highest number of labeled utterances. If word such as "emotions" was entered, it will match as "A" intent as intent A consist of highest number of labeled utterances.
Please advise on the issue.
Set a score threshold, below which your app won't show any response to the user (or could show a "sorry I didn't get you" message instead). This avoid responding to users with anything LUIS is unsure about, which usually takes care of a lot of "off topic" input too.
I would suggest setting it your threshold between 0.3 and 0.7, depending on the seriousness of your subject matter. This is not a configuration option in LUIS, rather in your code you just do:
if(result.score >=0.5) {
// show response based on intent.
} else {
// ask user to rephrase
}
On a separate note, it looks like your intents are very imbalanced. You want to try and have roughly the same number of utterances for each intent, between 10 and 20 ideally.
So without more details on how you've built your language model, most likely the underlying issue is that you either don't have enough utterances in each intent that have enough variation displaying the different ways in which different utterances could be said for that particular intent.
And by variation I mean different lengths of the utterance (word count), different word order, tenses, grammatical correctness, etc. (docs here)
And remember each intent should have at least 15 utterances.
Also, as stated in best practices, do did you also make sure to include example utterances in your None intent as well? Best practices state that you should have 1 utterances in None for every 10 utterances in the other parts of your app.
Ultimately: build your app so that your intents are distinct enough with varying example utterances built into the intent, so that when you test other utterances LUIS will be more likely able to match to your distinct intents--and if you enter an utterance that doesn't follow any sort of pattern or context of your distinct intents, LUIS will know to detect the utterance to your fallback "None" intent.
If you want more specific help, please post the JSON of your language model.

LUIS List entity

I am using "list" entity. However, I do not achieve my expected result.
Here is what I have for LUIS intent:
getAnimal
I want to get a cat**[animal]**.
Here is what I have with LUIS entities:
List Entities [animal]
cat: russian blue, persian cat, british shorthair
dog: bulldog, german shepard, beagle
rabbit: holland lop, american fuzzy lop, florida white
Here is what I have with LUIS Phrase lists:
Phrase lists [animal_phrase]
cat, russian blue, persian cat, british shorthair, dog, bulldog, german shepard, beagle, etc
Desired:
When user enters "I want to get a beagle." It will be match with "getAnimal" intent.
Actual:
When user enters "I want to get a beagle." It will be match with "None" intent.
Please help. Your help will be appreciated.
So using a phrase list is a good way to start, however you need to make sure you provide enough data for LUIS to be able to learn the intents as well as the entities separate from the phrase list. Most likely you need to add more utterances.
Additionally, if your end goal is to have LUIS recognize the getAnimal intent, I would do away with the list entity, and instead use a simple entity to take advantage of LUIS's machine learning, and do so in combination with a phrase list to boost the signal to what an animal may look like.
As the documentation on phrase lists states,
Features help LUIS recognize both intents and entities, but features
are not intents or entities themselves. Instead, features might
provide examples of related terms.
--Features, in machine learning, being a distinguishing trait or attribute of data that your system observes, and what you add to a group/class when using a phrase list
Start by
1. Creating a simple entity called Animal
2. Add more utterances to your getAnimal intent.
Following best practices outlined here, you should include at least 15 utterances per intent. Make sure to include plenty of examples of the Animal entity.
3. Be mindful to include variation in your utterances that are valuable to LUIS's learning (different word order, tense, grammatical correctness, length of utterance and entities themselves). Highly recommend reading this StackOverflow answer I wrote on how to build your app properly get accurate entity detection if you want more elaboration.
above blue highlighted words are tokens labeled to the simple Animal entity
3. Use a phrase list.
Be sure to include values that are not just 1 word long, but 2, 3, and 4 words long in length, as different animal names may possibly be that long in length (e.g. cavalier king charles spaniel, irish setter, english springer spaniel, etc.) I also included 40 animal breed names. Don't be shy about adding Related Values suggested to you into your phrase list.
After training your app to update it with your changes, prosper!
Below "I want a beagle" reaches the proper intent. LUIS will even be able to detect animals that were not entered in the app in entity extraction.

Resources