模式可提高预测的准确性Patterns improve prediction accuracy

模式旨在多条话语非常类似的情况下提升准确性。Patterns are designed to improve accuracy when several utterances are very similar. 使用模式可在不提供更多话语的情况下获得更高的意向准确度。A pattern allows you to gain more accuracy for an intent without providing many more utterances.

模式解决了意向置信度低的问题Patterns solve low intent confidence

设想一个人力资源应用,它在组织结构图上报告某员工的相关信息。Consider a Human Resources app that reports on the organizational chart in relation to an employee. 如果具有员工的姓名和组织关系,LUIS 就能反馈所涉及的员工。Given an employee's name and relationship, LUIS returns the employees involved. 设想员工叫做孔西明,经理叫做柏隼,下属员工有翁捷生、康霓和尹锋。Consider an employee, Tom, with a manager name Alice, and a team of subordinates named: Michael, Rebecca, and Carl.

组织结构图

陈述Utterances 预测的意向Intent predicted 意向得分Intent score
孔西明的下属员工有谁?Who is Tom's subordinate? 获取组织结构组GetOrgChart .30.30
谁归孔西明管辖?Who is the subordinate of Tom? 获取组织结构组GetOrgChart .30.30

如果应用具有 10 到 20 条句子长度不同、字词顺序不同,甚至用词不同(“下属员工”、“经理”和“报告”的近义词)的话语,则 LUIS 返回的置信度得分可能较低。If an app has between 10 and 20 utterances with different lengths of sentence, different word order, and even different words (synonyms of "subordinate", "manage", "report"), LUIS may return a low confidence score. 创建一个模式来帮助 LUIS 理解字词顺序的重要性。Create a pattern to help LUIS understand the importance of the word order.

模式可处理以下情况:Patterns solve the following situations:

  • 意向得分较低The intent score is low
  • 正确的意向得分不是最高得分但太接近最高得分。The correct intent is not the top score but too close to the top score.

模式不保证提取意向Patterns are not a guarantee of intent

模式使用多种预测技术。Patterns use a mix of prediction technologies. 在模式中设置模板话语的意向并不保证得出意向预测,但表示很可能得出。Setting an intent for a template utterance in a pattern is not a guarantee of the intent prediction but it is a strong signal.

模式不会提升机器学习实体检测Patterns do not improve machine-learning entity detection

模式的主要用途是帮助预测意向和角色。A pattern is primarily meant to help the prediction of intents and roles. pattern.any 实体用于提取自由格式实体。The pattern.any entity is used to extract free-form entities. 当模式使用实体时,模式不会帮助检测机器学习实体。While patterns use entities, a pattern does not help detect a machine-learning entity.

若将多个话语合并到单个模式,则无法提升实体预测。Do not expect to see improved entity prediction if you collapse multiple utterances into a single pattern. 若要触发简单实体,需要添加话语或使用列表实体,否则模式将不会触发。For simple entities to fire, you need to add utterances or use list entities else your pattern will not fire.

模式使用实体角色Patterns use entity roles

如果模式中的两个或多个实体具有相关的上下文,模式会使用实体角色来提取关于实体的上下文信息。If two or more entities in a pattern are contextually related, patterns use entity roles to extract contextual information about entities.

使用和不使用模式的情况下的预测得分Prediction scores with and without patterns

假定有足够多的实例话语,则 LUIS 不使用模式即能提高预测的置信度。Given enough example utterances, LUIS would be able to increase prediction confidence without patterns. 无需提供尽量多的话语,模式就能增加置信度得分。Patterns increase the confidence score without having to provide as many utterances.

模式匹配Pattern matching

模式的匹配顺序是先检测模式内的实体,再验证模式的其余字词和字词顺序。A pattern is matched based on detecting the entities inside the pattern first, then validating the rest of the words and word order of the pattern. 要匹配模式,需要在模式中包含实体。Entities are required in the pattern for a pattern to match. 模式在标记级别应用,而不在字符级别应用。The pattern is applied at the token level, not the character level.

只有模式的应用Pattern-only apps

你可以构建其中的意向没有示例话语的应用,只要每个意向具有模式即可。You can build an app with intents that have no example utterances, as long as there's a pattern for each intent. 对于只有模式的应用,模式不能包含机器学习实体,因为这些实体要求具有示例言语。For a pattern-only app, the pattern shouldn't contain machine-learning entities because these do require example utterances.

Pattern.any 实体Pattern.any entity

通过 pattern.any 实体,可找到自由格式数据,其中实体的用语方式比较晦涩,难以从话语的其余部分来确定实体的结尾。The pattern.any entity allows you to find free-form data where the wording of the entity makes it difficult to determine the end of the entity from the rest of the utterance.

此人力资源应用有助于员工查找公司表单。A Human Resources app helps employees find company forms.

话语Utterance
HRF-123456 在哪里?Where is HRF-123456?
HRF-123234 的作者是谁?Who authored HRF-123234?
HRF-456098 是以法语发布的吗?HRF-456098 is published in French?

但是,每个表单都具有一个带格式的名称(如上表所使用的名称),以及一个易记名称,如 Request relocation from employee new to the company 2018 version 5However, each form has both a formatted name, used in the preceding table, as well as a friendly name, such as Request relocation from employee new to the company 2018 version 5.

具有易记表单名称的话语如下所示:Utterances with the friendly form name look like:

话语Utterance
“公司新员工请求调职 2018 年第 5 版”在哪里?Where is Request relocation from employee new to the company 2018 version 5?
“公司新员工请求调职 2018 年第 5 版”的作者是谁?Who authored "Request relocation from employee new to the company 2018 version 5"?
“公司新员工请求调职 2018 年第 5 版”是以法语发布的吗?Request relocation from employee new to the company 2018 version 5 is published in French?

此可变长度包含可能导致 LUIS 无法正确识别实体结尾位置的单词。The varying length includes words that may confuse LUIS about where the entity ends. 在模式中使用 Pattern.any 实体,可指定表单名称的开头和结尾,以便 LUIS 正确提取表单名称。Using a Pattern.any entity in a pattern allows you to specify the beginning and end of the form name so LUIS correctly extracts the form name.

模板话语示例Template utterance example
{FormName} 在哪里[?]Where is {FormName}[?]
{FormName} 的作者是谁[?]Who authored {FormName}[?]
{FormName} 是以法语发布的吗[?]{FormName} is published in French[?]

查看模式。任何参考信息Review Pattern.any reference information

最佳实践Best practices

了解最佳实践Learn best practices.

模式语法Pattern syntax

模式语法参考了解模式语法。Learn pattern syntax from the pattern syntax reference.

后续步骤Next steps

详细了解模式:Learn more about patterns: