LUIS 的迭代应用设计Iterative app design for LUIS

语言理解 (LUIS) 应用可以使用迭代进行学习并最高效地执行。A Language Understanding (LUIS) app learns and performs most efficiently with iteration. 下面是典型的迭代周期:Here's a typical iteration cycle:

  • 创建新版本Create new version
  • 编辑 LUIS 应用架构。Edit the LUIS app schema. 这包括:This includes:
    • 意向和示例言语Intents with example utterances
    • 实体Entities
    • 功能Features
  • 训练、测试和发布Train, test, and publish
    • 在预测终结点上进行主动学习测试Test at the prediction endpoint for active learning
  • 从终结点查询收集数据Gather data from endpoint queries

创作周期

生成 LUIS 架构Building a LUIS schema

应用的架构定义用户的需求是什么(意图或意向),以及意向的哪些部分提供有助于确定答案的详细信息(称为实体)。 An app's schema defines what the user is asking for (the intention or intent ) and what parts of the intent provide details (called entities) that are used to help determine the answer.

应用架构必须特定于应用域,以此确定相关的单词和短语,并确定典型的单词顺序。The app schema must be specific to the app domains to determine words and phrases that are relevant, as well as to determine typical word ordering.

示例言语表示应用在运行时所需的用户输入,例如识别的语音或文本。Example utterances represent user inputs, such as recognized speech or text, that the app expects at runtime.

架构需要意向,并且应该包含实体。The schema requires intents, and should have entities.

意向的示例架构Example schema of intents

最常见的架构是使用意向组织的意向架构。The most common schema is an intent schema organized with intents. 此类架构使用 LUIS 来确定用户的意图。This type of schema uses LUIS to determine a user's intention.

如果意向架构类型有助于 LUIS 确定用户的意图,则此类型可以包含实体。The intent schema type may have entities if it helps LUIS determine the user's intention. 例如,发货实体(作为意向的机器学习功能)可帮助 LUIS 确定发货意图。For example, a shipping entity (as a machine learning feature to an intent) helps LUIS determine a shipping intention.

实体的示例架构Example schema of entities

实体架构侧重于实体,是从用户言语中提取的数据。An entity schema focuses on entities, which is the data that is extracted from user utterances. 例如,如果用户说“我想要订三份披萨”。For example, if a user was to say, "I'd like to order three pizzas." 将会提取两个实体:“三份”和“披萨”。 There are two entities that would be extracted: three and pizzas. 这些实体有助于实现意图,即订餐。These are used to help fulfill the intention, which was to make an order.

在实体架构方面,言语的意图对于客户端应用程序而言不太重要。For an entity schema, the intention of the utterance is less important to the client application.

组织实体架构的常用方法是将所有示例言语添加到 None 意向。A common method of organizing an entity schema is to add all example utterances to the None intent.

混合架构的示例Example of a mixed schema

最强大且成熟的架构是包含完整实体和特征的意向架构。The most powerful and mature schema is an intent schema with a full range of entities and features. 此架构可用作意向架构或实体架构的起点,并可以不断扩充以包含两者的概念,因为客户端应用程序需要这些信息片段。This schema can begin as either an intent or entity schema and grow to include concepts of both, as the client application needs those pieces of information.

将示例言语添加到意向Add example utterances to intents

LUIS 需要在每个意向中添加几个示例言语。LUIS needs a few example utterances in each intent. 示例言语需要有足够的单词选择和单词顺序方面的变化,才能确定言语表达的意向。The example utterances need enough variation of word choice and word order to be able to determine which intent the utterance is meant for.

注意

请不要批量添加示例言语。Do not add example utterances in bulk. 先添加 15 到 30 个具体的且有变化的示例。Start with 15 to 30 specific and varying examples.

需要为每个示例言语设计任何需要提取的数据,并将这些数据标记为实体Each example utterance needs to have any required data to extract designed and labeled with entities.

关键元素Key element 目的Purpose
IntentIntent 将用户言语分类成单一意图或操作。Classify user utterances into a single intention, or action. 示例包括 BookFlightGetWeatherExamples include BookFlight and GetWeather.
实体Entity 从言语中提取实现意图所需的数据。Extract data from utterance required to complete intention. 示例包括旅行日期和时间以及地点。Examples include date and time of travel, and location.

可以通过将言语分配到 None 意向,将 LUIS 应用设计为忽略与应用域不相关的言语。A LUIS app can be designed to ignore utterances that aren't relevant to an app's domain by assigning the utterance to the None intent.

测试并训练应用Test and train your app

在每个意向中添加 15 到 30 个不同的示例言语并标记所需的实体后,需要测试并训练 LUIS 应用。After you have 15 to 30 different example utterances in each intent, with the required entities labeled, you need to test and train your LUIS app.

发布到预测终结点Publish to a prediction endpoint

必须发布 LUIS 应用,使之出现在预测终结点区域列表中。The LUIS app must be published so that it's available to you in the list prediction endpoint regions.

测试已发布的应用Test your published app

可以从 HTTPS 预测终结点测试已发布的 LUIS 应用。You can test your published LUIS app from the HTTPS prediction endpoint. 从该预测终结点测试可使 LUIS 选择对可信度低的表述进行评审Testing from the prediction endpoint allows LUIS to choose any utterances with low-confidence for review.

为每个周期创建新版本Create a new version for each cycle

每个版本是 LUIS 应用的即时快照。Each version is a snapshot in time of the LUIS app. 在对应用进行更改之前,请创建新版本。Before you make changes to the app, create a new version. 恢复旧版本比尝试将意向和言语转移到以前的状态要更容易。It is easier to go back to an older version than to try to remove intents and utterances to a previous state.

版本 ID 由字符、数字或“.”组成,且长度不得超过 10 个字符。The version ID consists of characters, digits or '.' and cannot be longer than 10 characters.

初始版本 (0.1) 是默认活动版本。The initial version (0.1) is the default active version.

首先克隆现有版本Begin by cloning an existing version

克隆现有版本,用作每个新版本的起点。Clone an existing version to use as a starting point for each new version. 克隆版本后,新版本将成为活动版本。After you clone a version, the new version becomes the active version.

发布槽Publishing slots

可以发布到过渡槽和/或生产槽。You can publish to either the stage and/or production slots. 每个槽可以具有不同的版本或相同的版本。Each slot can have a different version or the same version. 这样,在将更改发布到可供机器人或其他 LUIS 调用应用使用的生产槽之前,可以方便地验证这些更改。This is useful for verifying changes before publishing to production, which is available to bots or other LUIS calling apps.

训练的版本在 LUIS 应用的终结点中不会自动可用。Trained versions aren't automatically available at your LUIS app's endpoint. 要使某个版本在 LUIS 应用终结点中可用,必须发布或重新发布该版本。You must publish or republish a version in order for it to be available at your LUIS app endpoint. 可以发布到“过渡”和“生产”槽,从而提供两个在终结点中可用的应用版本。 You can publish to Staging and Production, giving you two versions of the app available at the endpoint. 如果需要更多应用版本在终结点上可用,应导出版本并将其重新导入到新的应用。If more versions of the app need to be available at an endpoint, you should export the version and reimport it to a new app. 新的应用具有不同的应用 ID。The new app has a different app ID.

导入版本Import a version

可将版本导入为新版本:A version can be imported as a new:

  • 应用,具有新的应用 IDApp, with a new app ID
  • 现有应用的版本Version of an existing app

该版本将成为活动版本,并使用应用文件的 versionId 属性中的版本 ID。That version becomes the active version and uses the version ID in the versionId property of the app file.

导出版本Export a version

可从 LUIS 门户中,在应用级别或版本级别导出版本:A version can be exported from the LUIS portal at either the app level or version level:

  • 应用级别 - 在“我的应用”页面上选择应用,然后选择“导出” App level - select app on My apps page, then select Export
  • 版本级别 - 在“我的应用”页面上选择应用链接,然后选择“管理”,再选择“版本” Version level - select app link on My apps page, select Manage, select Versions

唯一的区别是,在应用级别导出的版本是当前活动版本,而在版本级别,可在“设置”页上选择任意要导出的版本。The only difference is that the app-level, the exported version is the currently active version while at the version level, you can choose any version to export on the Settings page.

导出的文件包含:The exported file doesn't contain:

  • 机器学习信息,因为应用在导入后会经过重新训练machine-learning information, because the app is retrained after it's imported
  • 参与者信息Contributor information

若要备份 LUIS 应用架构,请从 LUIS 门户导出版本。In order to back up your LUIS app schema, export a version from the LUIS portal.

使用版本和参与者信息管理参与者更改Manage contributor changes with versions and contributors

LUIS 通过提供 Azure 资源级权限来使用应用参与者的概念。LUIS uses the concept of contributors to an app, by providing Azure resource-level permissions. 将此概念与版本控制相结合可以提供有针对性的协作。Combine this concept with versioning to provide targeted collaboration.

使用以下方法来管理应用的参与者更改。Use the following techniques to manage contributor changes to your app.

在同一应用中管理多个版本Manage multiple versions inside the same app

首先,每个创建者基于基础版进行克隆Begin by cloning from a base version for each author.

每个创建者对自己的应用版本进行更改。Each author makes changes to their own version of the app. 创建者对模型感到满意后,将新版本导出到 JSON 文件中。When the author is satisfied with the model, export the new versions to JSON files.

可以比较导出的应用、.json 文件或 .lu 文件的差异。Exported apps, .json or .lu files, can be compared for changes. 合并这些文件,创建一个新版本的文件。Combine the files to create a single file of the new version. 更改 versionId 属性以指示新的合并版本。Change the versionId property to signify the new merged version. 将该版本导入原始应用。Import that version into the original app.

通过此方法可获得一个活动版本、阶段版本和已发布版本的应用。This method allows you to have one active version, one stage version, and one published version. 可以在交互式测试窗格中将活动版本与发布版本(阶段或生产)的结果进行比较。You can compare the results of the active version with a published version (stage or production) in the interactive testing pane.

将各版本作为应用进行管理Manage multiple versions as apps

导出基础版本。Export the base version. 各创建者导入该版本。Each author imports the version. 导入应用的创建者即为该版本的所有者。The person that imports the app is the owner of the version. 修改应用后,导出该版本。When they are done modifying the app, export the version.

导出的应用为 JSON 格式的文件,可与导出的基础版进行比较,发现所做更改。Exported apps are JSON-formatted files, which can be compared with the base export for changes. 合并这些文件,创建一个新版本的 JSON 文件。Combine the files to create a single JSON file of the new version. 更改 JSON 中的 versionId 属性以表示新的合并版本。Change the versionId property in the JSON to signify the new merged version. 将该版本导入原始应用。Import that version into the original app.

详细了解来自协作者的创作贡献。Learn more about authoring contributions from collaborators.

评审终结点言语以开始新的迭代周期Review endpoint utterances to begin the new iterative cycle

完成一个迭代循环后,可以重复该过程。When you are done with an iteration cycle, you can repeat the process. 首先评审被 LUIS 标记为低置信度的预测终结点言语Start with reviewing prediction endpoint utterances LUIS marked with low-confidence. 检查这些言语中预测的意向是否正确,以及提取的实体是否正确且完整。Check these utterances for both correct predicted intent and correct and complete entity extracted. 评审并接受更改后,评审列表应是空的。After you review and accept changes, the review list should be empty.

后续步骤Next steps

了解有关协作的概念。Learn concepts about collaboration.