快速入门:在 LUIS 门户中创建新应用Quickstart: Create a new app in the LUIS portal

本快速入门介绍如何在 LUIS 门户中生成新应用。In this quickstart, you build a new app in the LUIS portal. 首先,创建应用的基本部件、意向和实体 。First, create the basic parts of an app, intents, and entities. 然后,通过在交互式测试面板中提供用于获取预测的意向的示例用户话语,对应用进行测试。Then test the app by providing a sample user utterance in the interactive test panel to get the predicted intent.

登录到 LUIS 门户Sign in to LUIS portal

LUIS 的新用户需要执行此过程:A new user to LUIS needs to follow this procedure:

  1. 登录 LUIS 门户,选择你所在的国家/地区,然后同意使用条款。Sign in to the LUIS portal, select your country/region and agree to the terms of use. 如果看到“我的应用”,则 LUIS 资源已存在,你应该跳过此过程,开始创建应用。If you see My Apps instead, a LUIS resource already exists and you should skip ahead to create an app. 如果没有,首先使用 Azure 资源,这使你能将 LUIS 帐户与新的或现有的 Azure 创作资源进行关联。If not, start by using an Azure resource, this allows you to link your LUIS account with a new or existing Azure Authoring resource.
  1. 在出现的“选择创作”窗口中,找到你的 Azure 订阅和 LUIS 创作资源。In the Choose an authoring window that appears, find your Azure subscription, and LUIS authoring resource. 如果没有资源,可新建一个。If you don't have a resource, you can create a new one.

    选择语言理解创作资源的类型。

    创建新的创作资源时,请提供以下信息:When you create a new authoring resource, provide the following information:

    • 租户名称 - 与 Azure 订阅关联的租户。Tenant name - the tenant your Azure subscription is associated with.
    • Azure 订阅名称 - 将对资源计费的订阅。Azure subscription name - the subscription that will be billed for the resource.
    • Azure 资源组名称 - 你选择或创建的自定义资源组名称。Azure resource group name - a custom resource group name you choose or create. 使用资源组可将 Azure 资源分组,以便进行访问和管理。Resource groups allow you to group Azure resources for access and management.
    • Azure 资源名称 - 你选择的自定义名称,用作创作和预测终结点查询的 URL 的一部分。Azure resource name - a custom name you choose, used as part of the URL for your authoring and prediction endpoint queries.
    • 定价层 - 定价层确定每秒和每月的最大事务数。Pricing tier - the pricing tier determines the maximum transaction per second and month.

创建应用Create an app

若要创建应用程序,请选择“+ 新建应用”。To create an application, select + New app.

在显示的窗口中,输入以下信息:In the window that appears, enter the following information:

名称Name 说明Description
名称Name 应用的名称,A name for your app. 例如“home automation”。For example, "home automation". 必需。Required.
环境Culture 应用能够理解和显示的语言。The language that your app understands and speaks. 必需。Required.
说明Description 应用的说明。A description for your app. 可选。Optional.
预测资源Prediction resource 将接收查询的预测资源。The prediction resource that will receive queries. 可选。Optional.

选择“完成”。Select Done.

备注

创建应用程序后将无法更改区域性。The culture cannot be changed once the application is created.

创建意向Create intents

创建 LUIS 应用后,需创建意向。After the LUIS app is created, you need to create intents. 意向用于分类用户提供的文本。Intents are a way to classify text from users. 例如,人力资源应用可以有两项功能。For example, a human resources app might have two functions. 帮助用户:To help people:

  1. 找工作和申请工作Find and apply for jobs
  2. 查找工作申请表Find forms to apply for jobs

此应用的两个不同 意向 对应于以下意向:The app's two different intentions align to the following intents:

IntentIntent 用户提供的文本示例Example text from user
称为“言语”known as an utterance
ApplyForJobApplyForJob I want to apply for the new software engineering position in Cairo.
FindFormFindForm Where is the job transfer form hrf-123456?

若要创建意向,请完成以下步骤:To create intents, complete the following steps:

  1. 创建应用后,请确保你位于“生成”部分的“意向”页上 。After the app is created, make sure you are on the Intents page of the Build section. 选择“创建”。Select Create.

    选择“创建”以创建新意向的屏幕截图Screenshot of selecting 'Create' to create new intent

  2. 输入意向名称 FindForm,然后选择“完成”。Enter the intent name, FindForm, and then select Done.

添加示例话语Add an example utterance

在创建意向后添加示例话语。You add example utterances after you create intents. 示例话语是用户在聊天机器人或其他客户端应用程序中输入的文本。Example utterances are text that a user enters in a chat bot or other client application. 它们可将用户文本的意向映射到 LUIS 意向。They map the intention of the user's text to a LUIS intent. 就此示例应用程序的 FindForm 意向来说,示例话语将包含表格编号。For this example application's FindForm intent, example utterances will include the form number. 客户端应用程序需要该表格编号来履行用户的请求,因此必须将其包括在话语中。The client application needs the form number to fulfill the user's request, so it's important to include it in the utterance.

FindForm 的“意向”页上,请在“示例言语”下添加以下示例言语 ,On the Intents page for FindForm, add the following example utterances under Example Utterance,

# 示例陈述Example utterances
11 Looking for hrf-123456
22 Where is the human resources form hrf-234591?
33 hrf-345623, where is it
44 Is it possible to send me hrf-345794
55 Do I need hrf-234695 to apply for an internal job?
66 Does my manager need to know I'm applying for a job with hrf-234091
77 Where do I send hrf-234918? Do I get an email response it was received?
88 hrf-234555
99 When was hrf-234987 updated?
1010 Do I use form hrf-876345 to apply for engineering positions
1111 Was a new version of hrf-765234 submitted for my open req?
1212 Do I use hrf-234234 for international jobs?
1313 hrf-234598 spelling mistake
1414 will hrf-234567 be edited for new requirements
1515 hrf-123456, hrf-123123, hrf-234567

根据设计,这些示例话语按以下方式变化:By design, these example utterances vary in the following ways:

  • 言语长度utterance length
  • 标点punctuation
  • 选词word choice
  • 谓语时态(现在时、过去时和将来时)verb tense (is, was, will be)
  • 词序word order

创建正则表达式实体Create a regular expression entity

若要在运行时预测响应中返回表格编号,必须将表格编号提取为一个实体。To return the form number in the runtime prediction response, the form number must be extracted as an entity. 由于表格编号文本已高度结构化,可以使用正则表达式实体。Because the form number text is highly structured, you can use a regular expression entity. 通过以下步骤创建正则表达式实体:Create the regular expression entity with the following steps:

  1. 在左侧菜单中选择“实体”。Select Entities from the menu on the left.

  2. 在“实体”页上选择“创建”。 Select Create on the Entities page.

  3. 输入名称 FormNumber,选择“Regex”实体类型。Enter the name FormNumber, select the Regex entity type.

  4. 输入正则表达式,“Regex”字段中的 hrf-[0-9]{6}Enter the regular expression, hrf-[0-9]{6} in the Regex field. 此条目匹配文本字符 hrf-,只能包含 6 位数,然后选择“创建”。This entry matches the literal characters, hrf-, and allows for exactly six digits, then select Create.

    创建正则表达式实体的屏幕截图Screenshot of creating regular expression entity

    此实体提取在任何意向中匹配正则表达式的任何文本。This entity extracts any text that matches the regular expression in any of the intents.

将话语示例添加到 None 意向Add example utterances to the None intent

None 意向是回退意向,不可留空。The None intent is the fallback intent and shouldn't be left empty. 每为应用的其他意向添加 10 个示例话语,此意向就应该包含 1 个话语。This intent should contain one utterance for every 10 example utterances that you've added for the other intents of the app.

None 意向的示例言语应在客户端应用程序域的范围以外。The None intent's example utterances should be outside of your client application domain.

  1. 在左侧菜单中选择“意向”,然后从意向列表中选择“None”。 Select Intents from the left menu, and then select None from the intents list.

  2. 将以下示例言语添加到该意向:Add the following example utterances to the intent:

    None 意向示例言语None intent example utterances
    Barking dogs are annoying
    Penguins in the ocean

    对于此应用,这些示例言语在域的范围以外。For this app, these example utterances are outside the domain. 如果域包括动物或海洋,则应将其他示例言语用于 None 意向。If your domain includes animals, or the ocean, then you should use different example utterances for the None intent.

训练应用Train the app

  1. 在 LUIS 网站的右上方,选择“训练”按钮。In the top-right side of the LUIS website, select the Train button.

    “训练”按钮

  2. 当“训练”按钮上的状态指示器为绿色时,即表示训练完成。Training is complete when status indicator on the Train button is green.

在示例言语中查找正则表达式实体Look at the regular expression entity in the example utterances

  1. 在左侧菜单中选择“意向”,以验证是否能够在“FindForm”意向中找到该实体。 Verify the entity is found in the FindForm intent by selecting Intents from the left menu. 然后,选择“FindForm”意向。Then select FindForm intent.

    会标记该实体在示例言语中的显示位置。The entity is marked where it appears in the example utterances.

    标记有实体的所有示例言语的屏幕截图Screenshot of all example utterances marked with entities

使用交互式测试窗格测试新应用Test your new app with the interactive test pane

使用 LUIS 门户中的交互式“测试”窗格可以验证实体是否是从应用尚未看到的新话语中提取的。Use the interactive Test pane in the LUIS portal to validate that the entity is extracted from new utterances the app hasn't seen yet.

  1. 在右上方菜单中选择“测试”。Select Test from the upper-right menu.

  2. 添加新话语,然后按 Enter:Add a new utterance and then press Enter:

    Is there a form named hrf-234098

    选择“检查”以查看实体预测。Select Inspect to see entity predictions.

    在测试窗格中测试新言语的屏幕截图Screenshot of testing new utterance in test pane

    排名靠前的预测意向为 FindForm(正确),其置信度超过 90% (0.977)。The top predicted intent is correctly FindForm with over 90% confidence (0.977). 已提取“FormNumber”实体,其值为 hrf-234098。The FormNumber entity is extracted with a value of hrf-234098.

清理资源Clean up resources

完成本快速入门后,如果不继续学习下一快速入门,请在顶部导航菜单中选择“我的应用”。When you're done with this quickstart and aren't moving on to the next quickstart, select My apps from the top navigation menu. 接着在列表中选中应用左侧的复选框,然后在列表上方的上下文工具栏中选择“删除”。Then select the app's left check box from the list and select Delete from the context toolbar above the list.

后续步骤Next steps