Rules in Dialogflow - dialogflow-es

Dialogflow documentation mentions that agents can be set in two modes, Hybrid(Rule-base and ML) and ML Only. How do we set up rules in Dialogflow? Can't find any documentation for this. Or is it only through training phrases? For example I want to set a rule that says any utterance that starts with 'XYZ' should be matched against Intent A.
I've tried marking 'XYZ' as an entity at the beginning of the training phrases in Intent A hoping that all such utterances are matched with this intent, however that does not seem to be happening.
'XYZ needs some goods to be transferred to location 23'
I expect such utterances to be matched against Intent A but that doesn't happen always

Rule based agent will match only those request which will match the training phrases as it is (or maybe it will match lemma values also).
It will match the sentence and extract the parameters as well if you have annotated the parameters in the training phrase.
But it will not match the variant of the sentence.
Hope it helps.

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

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.

Dialogflow is not detecting entity when input is not exactly the same as training phrase?

I've made an intent to detect user's answer when they say, for example "when shop is closed" where "closed" is an entity.
When I give the input exactly the same as my training phrase, "when shop is closed", everything is working as expected and and dialogflow correctly detected the intent and the entity value (as shown in the second screenshot).
However, when I input a slight variant to the training phrase, by adding extra words "I think" in front of the sentence, dialogflow still correctly detected the intent, but however this time the parameter value is empty. (as shown in first screenshot)
I will need the value to be detected in both cases, and can't figure out why this is happening.
Screenshot 1
Screenshot 2
Google has published best practices for conversation design here, which should help:
https://developers.google.com/actions/assistant/basics
In this case, have you tried adding, "When is the shop closed?" as a training phrase? Clarifying verb tenses and sentence structure might help Dialogflow correctly identify the parameters you're hoping to extract from a user's given intent.

Why fallback intent is not working in api.ai?

When the user types some random words that doesn't match to any intent, my agent instead of recognizing it as a fall back intent, categorizes it as some particular intent.
And astonishing fact is that such random words get matched as a particular entity. and trust me such words random garbage words are not defined in my entity.
I am unable to find solution for this :(
Check whether "Default Fallback intent" is available in your list of intents or enabled in your agent.
Check all your training examples in your intents properly.
For more Info follow this link
https://docs.api.ai/docs/concept-intents#fallback-intent

Resources