使用意向和实体模型进行设计Design with intent and entity models

语言理解提供了两种类型的模型,用于定义应用架构。Language understanding provides two types of models for you to define your app schema. 应用架构决定了从新用户言语预测获得的信息。Your app schema determines what information you receive from the prediction of a new user utterance.

应用架构是根据使用机器教学创建的模型构建的:The app schema is built from models you create using machine teaching:

Authoring 使用机器教学Authoring uses machine teaching

使用 LUIS 的机器教学方法,可以轻松地将概念传授给计算机。LUIS's machine teaching methodology allows you to easily teach concepts to a machine. 了解机器学习不是使用 LUIS 所必需的。Understanding machine learning is not necessary to use LUIS. 不过,可以由你作为教师通过提供概念的示例并说明如何使用其他相关概念为某个概念建模,将概念传达给 LUIS。Instead, you as the teacher, communicates a concept to LUIS by providing examples of the concept and explaining how a concept should be modeled using other related concepts. 你作为教师,还可以通过识别和修复预测错误,以交互方式改进 LUIS 的模型。You, as the teacher, can also improve LUIS's model interactively by identifying and fixing prediction mistakes.

使用意向对言语进行分类Intents classify utterances

意向将示例言语分类,以便向 LUIS 传授意向。An intent classifies example utterances to teach LUIS about the intent. 意向中的示例言语用作言语的积极示例。Example utterances within an intent are used as positive examples of the utterance. 相同的这些言语用作所有其他意向中的消极示例。These same utterances are used as negative examples in all other intents.

假设某个应用需要确定用户的预订意向,另一个应用需要客户的交货地址。Consider an app that needs to determine a user's intention to order a book and an app that needs the shipping address for the customer. 此应用具有两个意向:OrderBookShippingLocationThis app has two intents: OrderBook and ShippingLocation.

以下言语是 OrderBook 意向的 积极示例 ,以及 ShippingLocationNone 意向的 消极示例The following utterance is a positive example for the OrderBook intent and a negative example for the ShippingLocation and None intents:

Buy the top-rated book on bot architecture.

使用实体提取数据Entities extract data

实体表示要从言语中提取的数据单位。An entity represents a unit of data you want extracted from the utterance. 机器学习实体是包含子实体(也是机器学习实体)的顶级实体。A machine-learning entity is a top-level entity containing subentities, which are also machine-learning entities.

机票预订就是机器学习实体的一个例子。An example of a machine-learning entity is an order for a plane ticket. 从概念上讲,机票预测是包含许多较小数据单位(例如日期、时间、座位数、座位类型(头等舱或经济舱)、出发地、目的地和餐饮选项)的单笔交易。Conceptually this is a single transaction with many smaller units of data such as date, time, quantity of seats, type of seat such as first class or coach, origin location, destination location, and meal choice.

意向与实体Intents versus entities

意向是整个言语的所需结果,而实体是从言语中提取的数据片段。An intent is the desired outcome of the whole utterance while entities are pieces of data extracted from the utterance. 意向通常与客户端应用程序应采取的操作相关联。Usually intents are tied to actions, which the client application should take. 实体是执行此操作所需的信息。Entities are information needed to perform this action. 从编程的角度讲,意向会触发方法调用,而实体将用作该方法调用的参数。From a programming perspective, an intent would trigger a method call and the entities would be used as parameters to that method call.

以下言语肯定包含意向,同时可能包含实体:This utterance must have an intent and may have entities:

Buy an airline ticket from Seattle to Cairo

以下言语包含单个意向:This utterance has a single intention:

  • 购买机票Buying a plane ticket

以下言语可能包含多个实体:This utterance may have several entities:

  • Seattle(出发地)和 Cairo(目的地)的地点Locations of Seattle (origin) and Cairo (destination)
  • 数量为一张机票The quantity of a single ticket

实体模型分解Entity model decomposition

LUIS 支持使用创作 API 进行的模型分解,可将概念分解成较小的组成部分。LUIS supports model decomposition with the authoring APIs, breaking down a concept into smaller parts. 这样,你便可以生成自己的模型,并有把握地构造和预测各个组成部分。This allows you to build your models with confidence in how the various parts are constructed and predicted.

模型分解包括以下组成部分:Model decomposition has the following parts:

功能Features

特征是系统观察到的数据的特征或特有属性。A feature is a distinguishing trait or attribute of data that your system observes. 机器学习特征为 LUIS 提供了重要提示,指示在何处查找可判别概念的项。Machine learning features give LUIS important cues for where to look for things that will distinguish a concept. 它们是 LUIS 可以使用的提示,但并不是硬性规则。They are hints that LUIS can use, but not hard rules. 这些提示将与标签结合使用来查找数据。These hints are used in conjunction with the labels to find the data.

模式Patterns

模式旨在多条言语非常类似的情况下提升准确性。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.

在运行时扩展应用Extending the app at runtime

应用的架构(模型和功能)经过训练后将发布到预测终结点。The app's schema (models and features) is trained and published to the prediction endpoint. 可以将新信息以及用户的言语传递到预测终结点以增强预测。You can pass new information, along with the user's utterance, to the prediction endpoint to augment the prediction.

后续步骤Next steps