问题
I followed what is described in the tutorial
- I first added an Pattern.any entity
- Next, I added a pattern for the required intent
- I had already created an intent like shown and now I click on train
- When I test, the intent is not hit
Any idea what's missing?
回答1:
The patterns are extremely literal. If the part of the phrase does not match exactly, the intent won't get recognized. (Note: you can add these phrases to the intent directly, instead of in the pattern, in which case it will recognize the intent but not the entities. Can be helpful if you have a dialog to prompt users for the missing entities.)
In your case, the way you have the pattern written you would need to write command create $mytest
, which should recognize the intent as well as the entity mytest. Since you did not include the $
character in your test, neither the intent nor the entity was recognized.
You do have the ability to mark a character as optional via brackets [], though I've had mixed success with this. Your phrases are specific enough that it may work in your case. So instead you could make your patterns like command create [$]command_params
where both command create $mytest
and command create mytest
would work and have the correct entity. Do note that if someone types something like command create $mytest please
, it's going to pick up the entire phrase mytest please as your entity. (If anyone knows how to create a pattern that avoids this, that would be fantastic!).
回答2:
TL;DR: Read patterns doc and improve your entity detection.
The Issue
The problem with your example that you have posted here is that LUIS failing to actually detect command_params
entity, therefore it cannot even match to your any one of those 3 patterns that you have shown.
As stated in Add common pattern template utterance formats to improve predictions:
In order for a pattern to be matched to an utterance, first the entities within the utterance have to match the entities in the template utterance. This means the entities have to have enough examples in example utterances with a high degree of prediction before patterns with entities are successful. However, the template doesn't help predict entities, only intents.
While patterns allow you to provide fewer example utterances, if the entities are not detected, the pattern does not match.
So you need to work on building out your command_params
entity to make it detectable before using a pattern.
Your entity
I'm not convinced Pattern.any is the correct entity type for you to use, as it's an entity that's used for values that are of variable length--maybe they are extremely long, for example.
I don't know what type of values your entity can evaluate to, but I suspect it would probably be better to go the route of creating a simple entity + phrase list (uses machine-learning) or a list entity if the entity values are a known set (exact pattern matching), depending on your command params values.
Update: also there are regex entities as well, that may work for you. (Again, I don't know what your entity values could be, so it's hard to point exactly to the correct entity to use)
Additionally, if you need help with understanding how to improve entity detection in general, see this StackOverflow answer.
来源:https://stackoverflow.com/questions/61334572/luis-adding-patterns-to-intents-is-not-taking-any-effect