关于 LUIS 应用中的意向的概念Concepts about intents in your LUIS app

意向表示用户想执行的任务或操作。An intent represents a task or action the user wants to perform. 这是用户的陈述中所表示的目的或目标。It is a purpose or goal expressed in a user's utterance.

定义一组意向,对应于用户希望在应用程序中执行的操作。Define a set of intents that corresponds to actions users want to take in your application. 例如,旅行应用定义了几个意向:For example, a travel app defines several intents:

旅行应用意向Travel app intents 示例陈述Example utterances
BookFlightBookFlight “帮我预订下周去里约的航班”"Book me a flight to Rio next week"
“24 号飞里约”"Fly me to Rio on the 24th"
“我需要下周日去里约热内卢的机票”"I need a plane ticket next Sunday to Rio de Janeiro"
GreetingGreeting “嗨”"Hi"
“你好”"Hello"
“早上好”"Good morning"
CheckWeatherCheckWeather “波士顿的天气怎样?”"What's the weather like in Boston?"
“显示本周末的天气预报”"Show me the forecast for this weekend"
None “给我一份饼干食谱”"Get me a cookie recipe"
“湖人赢了吗?”"Did the Lakers win?"

所有应用程序均附带了预定义意向“None”,这是一个回退意向。All applications come with the predefined intent, "None", which is the fallback intent.

预生成域提供意向Prebuilt domains provide intents

除了定义的意向外,还可以使用其中一个预生成域中的预生成意向。In addition to intents that you define, you can use prebuilt intents from one of the prebuilt domains. 获取详细信息。For more information.

返回所有意向的得分Return all intents' scores

将陈述分配给单个意向。You assign an utterance to a single intent. 当 LUIS 在终结点上收到陈述时,它将返回该陈述的最高意向。When LUIS receives an utterance on the endpoint, it returns the one top intent for that utterance. 如果需要陈述的所有意向得分,可以在 API 终结点调用的查询字符串上提供 verbose=true 标记。If you want scores for all intents for the utterance, you can provide verbose=true flag on the query string of the API endpoint call.

意向与实体Intent compared to entity

意向表示应用程序应为用户采取的操作,并且基于整个话语。The intent represents action the application should take for the user and is based on the entire utterance. 陈述仅可具有一个得分最高的意向,但可具有多个实体。An utterance can have only one top scoring intent but it can have many entities.

当用户的意图 将在客户端应用程序中触发操作(例如,调用 checkweather() 函数)时,请创建一个意向。Create an intent when the user's intention would trigger an action in your client application, like a call to the checkweather() function. 然后创建实体以表示执行操作所需的参数。Then create entities to represent parameters required to execute the action.

IntentIntent 实体Entity 示例陈述Example utterance
CheckWeatherCheckWeather { "type": "location", "entity": "seattle" }{ "type": "location", "entity": "seattle" }
{ "type": "builtin.datetimeV2.date","entity": "tomorrow","resolution":"2018-05-23" }{ "type": "builtin.datetimeV2.date","entity": "tomorrow","resolution":"2018-05-23" }
What's the weather like in Seattle tomorrow?(西雅图明天天气怎样?)What's the weather like in Seattle tomorrow?
CheckWeatherCheckWeather { "type": "date_range", "entity": "this weekend" }{ "type": "date_range", "entity": "this weekend" } Show me the forecast for this weekend(显示本周末的天气预报)Show me the forecast for this weekend

预生成域意向Prebuilt domain intents

预生成域具有带有话语的意向。Prebuilt domains have intents with utterances.

None 意向None intent

已创建 None 意向但有意留空 。The None intent is created but left empty on purpose. None 意向是必需的意向,不能删除或重命名 。The None intent is a required intent and can't be deleted or renamed. 使用域外的陈述对其进行填充。Fill it with utterances that are outside of your domain.

None 意向是回退意向,在每个应用中都很重要,应占话语总数的 10%。The None intent is the fallback intent, important in every app, and should have 10% of the total utterances. 它用于训练应用域(主题区域)中不重要的 LUIS 陈述。It is used to teach LUIS utterances that are not important in the app domain (subject area). 如果不向 None 意向添加任何陈述,LUIS 会强制域外的陈述进入其中一个域意向 。If you do not add any utterances for the None intent, LUIS forces an utterance that is outside the domain into one of the domain intents. 这将因对 LUIS 进行了错误的陈述意向训练而扭曲预测评分。This will skew the prediction scores by teaching LUIS the wrong intent for the utterance.

当话语预测为 None 意向时,客户端应用程序可以询问更多问题或提供菜单以指导用户进行有效选择。When an utterance is predicted as the None intent, the client application can ask more questions or provide a menu to direct the user to valid choices.

反面意图Negative intentions

如果希望确定正面和反面意向,例如“我想要一辆车”和“我不想要一辆车”,则可以创建两个意图(一个正面意向和一个反面意向),并为每个意向添加适当的陈述。If you want to determine negative and positive intentions, such as "I want a car" and "I don't want a car", you can create two intents (one positive, and one negative) and add appropriate utterances for each. 或者,可以创建单个意向,并将两个不同的正面和反面术语标记为实体。Or you can create a single intent and mark the two different positive and negative terms as an entity.

意向和模式Intents and patterns

如果你有可部分或全部定义为正则表达式的示例话语,请考虑使用与模式配对的正则表达式实体If you have example utterances, which can be defined in part or whole as a regular expression, consider using the regular expression entity paired with a pattern.

使用正则表达式实体可以确保数据提取,以便匹配模式。Using a regular expression entity guarantees the data extraction so that the pattern is matched. 模式匹配可确保返回确切的意向。The pattern matching guarantees an exact intent is returned.

意向平衡Intent balance

应用域意向应让每个意向的陈述数保持平衡。The app domain intents should have a balance of utterances across each intent. 请勿出现一个意向具有 10 个陈述,而另一个意向具有 500 个陈述的情况。Do not have one intent with 10 utterances and another intent with 500 utterances. 这样不平衡。This is not balanced. 如果遇到这种情况,请查看具有 500 个陈述的意向,了解是否可将其中许多意向重新组织为模式If you have this situation, review the intent with 500 utterances to see if many of the intents can be reorganized into a pattern.

平衡中不包含 None 意向。The None intent is not included in the balance. 该意向应包含应用中总陈述数的 10%。That intent should contain 10% of the total utterances in the app.

意向限制Intent limits

查看限制以了解可添加到模型中的意向数。Review limits to understand how many intents you can add to a model.

如果所需意向数超过了最大意向数If you need more than the maximum number of intents

首先,请考虑系统是否使用了过多意向。First, consider whether your system is using too many intents.

能否将多个意向合并为具有实体的单个意向Can multiple intents be combined into single intent with entities

如果意向过于类似,则会增加 LUIS 区分它们的难度。Intents that are too similar can make it more difficult for LUIS to distinguish between them. 意向应具有足够的差异,以捕获用户要求的主要任务,但无需捕获代码所采用的每条路径。Intents should be varied enough to capture the main tasks that the user is asking for, but they don't need to capture every path your code takes. 例如,在旅行应用中,BookFlight 和 FlightCustomerService 可能是单独的意向,但 BookInternationalFlight 和 BookDomesticFlight 太过于相似。For example, BookFlight and FlightCustomerService might be separate intents in a travel app, but BookInternationalFlight and BookDomesticFlight are too similar. 如果系统需要将其区分开来,请使用实体或其他逻辑,而不是意向。If your system needs to distinguish them, use entities or other logic rather than intents.

调度程序模型Dispatcher model

深入了解有关将 LUIS 和 QnA maker 应用与调度模型相结合的信息。Learn more about combining LUIS and QnA maker apps with the dispatch model.

请求具有大量意向的应用的帮助Request help for apps with significant number of intents

如果减少意向数或将意向划分给多个应用不起作用,请与支持部门联系。If reducing the number of intents or dividing your intents into multiple apps doesn't work for you, contact support. 如果所持 Azure 订阅包含支持服务,请与 Azure 技术支持联系。If your Azure subscription includes support services, contact Azure technical support.

后续步骤Next steps