如何添加模式以提高预测准确性How to add patterns to improve prediction accuracy

在 LUIS 应用接收到终结点话语后,请使用模式提高话语(按字词顺序和字词选择呈现模式)的预测准确性。After a LUIS app receives endpoint utterances, use a pattern to improve prediction accuracy for utterances that reveal a pattern in word order and word choice. 模式使用特定语法指示实体、实体角色和可选文本的位置。Patterns use specific syntax to indicate the location of: entities, entity roles, and optional text.

注意

模式仅包括机器学习实体父项,而不包括子实体。Patterns only include machine-learning entity parents, not subentities.

使用正确的语法添加模板言语Add template utterance using correct syntax

  1. 登录到 LUIS 门户,选择“订阅”和“创作资源”以查看分配给该创作资源的应用。Sign in to the LUIS portal, and select your Subscription and Authoring resource to see the apps assigned to that authoring resource.

  2. 在“我的应用”页上选择应用名称以打开应用。Open your app by selecting its name on My Apps page.

  3. 在左侧面板中,选择“改进应用性能”下的“模式” 。Select Patterns in the left panel, under Improve app performance.

  4. 为模式选择正确意向。Select the correct intent for the pattern.

  5. 在模板文本框中,键入模板表述,然后按 Enter。In the template textbox, type the template utterance and select Enter. 如果要输入实体名称,请使用正确的模式实体语法。When you want to enter the entity name, use the correct pattern entity syntax. 使用以 { 开头的实体语法。Begin the entity syntax with {. 实体列表随即显示。The list of entities displays. 选择正确的实体。Select the correct entity.

    模式实体的屏幕截图Screenshot of entity for pattern

    如果实体中包含角色,请在实体名称后用一个冒号 (:) 指示该角色,例如 {Location:Origin}If your entity includes a role, indicate the role with a single colon, :, after the entity name, such as {Location:Origin}. 实体的角色列表将以列表形式显示。The list of roles for the entities displays in a list. 选择该角色,然后按 Enter。Select the role, and then select Enter.

    包含角色的实体的屏幕截图Screenshot of entity with role

    选择正确的实体后,请完成模式输入,然后按 Enter。After you select the correct entity, finish entering the pattern, and then select Enter. 模式输入完成后,请培训应用。When you are done entering patterns, train your app.

    包含两种实体类型的已输入模式的屏幕截图Screenshot of entered pattern with both types of entities

创建 pattern.any 实体Create a pattern.any entity

Pattern.any 实体仅在模式中有效,在意向的示例言语中无效。Pattern.any entities are only valid in patterns, not intents' example utterances. 此类实体有助于 LUIS 查找不同长度和字词选择的实体结尾。This type of entity helps LUIS find the end of entities of varying length and word choice. 由于此实体会在模式中使用,因此,LUIS 可识别实体末尾在话语模板中的位置。Because this entity is used in a pattern, LUIS knows where the end of the entity is in the utterance template.

  1. 登录到 LUIS 门户,选择“订阅”和“创作资源”以查看分配给该创作资源的应用。Sign in to the LUIS portal, and select your Subscription and Authoring resource to see the apps assigned to that authoring resource.

  2. 在“我的应用”页上选择应用名称以打开应用。Open your app by selecting its name on My Apps page.

  3. 在“生成”部分的左侧面板中选择“实体”,然后选择“+ 创建” 。From the Build section, select Entities in the left panel, and then select + Create.

  4. 在“选择实体类型”对话框中,在“名称”框中输入实体名称,然后选择“Pattern.Any”作为“类型”,然后选择“创建” 。In the Choose an entity type dialog box, enter the entity name in the Name box, and select Pattern.Any as the Type then select Create.

    使用此实体创建模式言语后,此实体可被机器学习和文本匹配相结合的算法提取出来。Once you create a pattern utterance using this entity, the entity is extracted with a combined machine-learning and text-matching algorithm.

添加示例言语作为模式Adding example utterances as pattern

若要为实体添加模式,最简单的方法是从“意向详细信息”页创建模式。If you want to add a pattern for an entity, the easiest way is to create the pattern from the Intent details page. 这可确保语法与示例言语匹配。This ensures your syntax matches the example utterance.

  1. 登录到 LUIS 门户,选择“订阅”和“创作资源”以查看分配给该创作资源的应用。Sign in to the LUIS portal, and select your Subscription and Authoring resource to see the apps assigned to that authoring resource.

  2. 在“我的应用”页上选择应用名称以打开应用。Open your app by selecting its name on My Apps page.

  3. 在“意向”列表页上,选择要从中创建模板言语的示例言语的意向名称。On the Intents list page, select the intent name of the example utterance you want to create a template utterance from.

  4. 在“意向详细信息”页上,选择要用作模板言语的示例言语所在的行,然后从上下文工具栏中选择“+ 添加为模式”。On the Intent details page, select the row for the example utterance you want to use as the template utterance, then select + Add as pattern from the context toolbar.

    屏幕截图,显示了如何在“意向详细信息”页上选择作为模板模式的示例言语。Screenshot of selecting example utterance as a template pattern on the Intent details page.

    若要从言语创建模式,言语必须包含一个实体。The utterance must include an entity in order to create a pattern from the utterance.

  5. 在弹出框中,选择“确认模式”页上的“完成”。In the pop-up box, select Done on the Confirm patterns page. 不需要定义实体的子实体或特征。You don't need to define the entities' subentities, or features. 只需列出机器学习实体即可。You only need to list the machine-learning entity.

    屏幕截图,显示了如何在“意向详细信息”页上确认作为模板模式的示例言语。Screenshot of confirming example utterance as a template pattern on the Intent details page.

  6. 如果需要编辑模板,比如使用 [](方括号)选择文本作为可选项,则需要从“模式”页进行此编辑。If you need to edit the template, such as selecting text as optional, with the [] (square) brackets, you need to make this edit from the Patterns page.

  7. 在导航栏中,选择“训练”以新模式训练应用。In the navigation bar, select Train to train the app with the new pattern.

在对模型进行模式更改后对应用进行培训Train your app after changing model with patterns

添加、编辑、删除或重新分配模式后,请针对更改来培训发布应用以影响终结点查询。After you add, edit, remove, or reassign a pattern, train and publish your app for your changes to affect endpoint queries.

使用上下文工具栏Use contextual toolbar

使用模式列表上方的上下文工具栏可以:The contextual toolbar above the patterns list allows you to:

  • 搜索模式Search for patterns
  • 编辑模式Edit a pattern
  • 为其他意向重新分配一个模式Reassign individual pattern to different intent
  • 为其他意向重新分配多个模式Reassign several patterns to different intent
  • 删除单个模式Delete-a-single-pattern
  • 删除多个模式Delete several patterns
  • 按实体筛选模式列表Filter pattern list by entity
  • 按意向筛选模式列表Filter-pattern-list-by-intent
  • 删除实体或意向筛选器Remove entity or intent filter
  • 在意向或实体页上通过现有表述添加模式Add pattern from existing utterance on intent or entity page

后续步骤Next steps

  • 了解如何按照教程生成模式(使用 pattern.any 和角色)。Learn how to build a pattern with a pattern.any and roles with a tutorial.
  • 了解如何培训应用。Learn how to train your app.