什么是语言理解 (LUIS)?What is Language Understanding (LUIS)?

语言理解 (LUIS) 是一种基于云的 API 服务,可在用户对话的自然语言文本中应用自定义机器学习智能,以便预测整体含义并提炼出相关的详细信息。Language Understanding (LUIS) is a cloud-based API service that applies custom machine-learning intelligence to a user's conversational, natural language text to predict overall meaning, and pull out relevant, detailed information.

LUIS 的客户端应用程序可以是任何传统的应用程序,只要其能够以自然语言与用户通信并完成任务即可。A client application for LUIS is any conversational application that communicates with a user in natural language to complete a task. 这些客户端应用程序包括社交媒体应用、聊天机器人以及支持语音的桌面应用程序。Examples of client applications include social media apps, chat bots, and speech-enabled desktop applications.

使用认知服务语言理解 (LUIS) 的 3 个客户端应用程序的概念图像Conceptual image of 3 client applications working with Cognitive Services Language Understanding (LUIS)

在聊天机器人中使用 LUISUse LUIS in a chat bot

LUIS 应用一旦发布,客户端应用程序即可向 LUIS 自然语言处理终结点 API 发送话语(文本)并接收结果作为 JSON 响应。Once the LUIS app is published, a client application sends utterances (text) to the LUIS natural language processing endpoint API and receives the results as JSON responses. LUIS 的常用客户端应用程序是聊天机器人。A common client application for LUIS is a chat bot.

使用聊天机器人通过自然语言理解 (NLP) 来预测用户文本的 LUIS 的概念图像 来预测用户文本的 LUIS 的概念图像Conceptual imagery of LUIS working with Chat bot to predict user text with natural language understanding (NLP)

步骤Step 操作Action
11 客户端应用程序将用户_话语_(采用自己的词汇的文本)“我想要呼叫 HR 代表”作为 HTTP 请求发送The client application sends the user utterance (text in their own words), "I want to call my HR rep." 给 LUIS 终结点。to the LUIS endpoint as an HTTP request.
22 LUIS 将学习过的模型应用到自然语言文本,以便提供有关用户输入的智能理解。LUIS applies the learned model to the natural language text to provide intelligent understanding about the user input. LUIS 返回包含得分最高意向“HRContact”的 JSON 格式的响应。LUIS returns a JSON-formatted response, with a top intent, "HRContact". JSON 终结点响应至少包含查询话语和得分最高的意向。The minimum JSON endpoint response contains the query utterance, and the top scoring intent. 它还可以提取数据,例如“联系人类型”实体。It can also extract data such as the Contact Type entity.
33 客户端应用程序根据 JSON 响应来决定如何处理用户的请求。The client application uses the JSON response to make decisions about how to fulfill the user's requests.

LUIS 应用提供的智能有助于客户端应用程序进行智能选择。The LUIS app provides intelligence so the client application can make smart choices. LUIS 不提供这些选择。LUIS doesn't provide those choices.

自然语言处理Natural language processing

LUIS 应用包含一个特定于域的自然语言模型。A LUIS app contains a domain-specific natural language model. 可通过预构建的域模型启动 LUIS 应用、构建你自己的模型,还可将预构建的域的各个部分与自己的自定义信息进行混合。You can start the LUIS app with a prebuilt domain model, build your own model, or blend pieces of a prebuilt domain with your own custom information.

  • 预构建的模型 LUIS 具有多个预构建的域模型,它们自带意向、话语和预构建的实体。Prebuilt model LUIS has many prebuilt domain models including intents, utterances, and prebuilt entities. 即使不使用预构建的模型中的意向和话语,也能使用预构建的实体。You can use the prebuilt entities without having to use the intents and utterances of the prebuilt model.

  • 自定义实体 LUIS 提供多种方式来自行标识自定义的意向和实体,比如机器学习到的实体、特定实体或文本实体,以及机器学习到的实体和文本实体的组合。Custom Entities LUIS gives you several ways to identify your own custom intents and entities including machine-learned entities, specific or literal entities, and a combination of machine-learned and literal.

构建 LUIS 模型Build the LUIS model

使用创作 API 或 LUIS 门户构建模型。Build the model with the authoring APIs or with the LUIS portal.

LUIS 模型从称为 意向 的用户意向的类别开始。The LUIS model begins with categories of user intentions called intents. 每个意向都需要用户 话语 的示例。Each intent needs examples of user utterances. 每个话语都可以提供各种数据,这些数据需要通过 实体 来提取。Each utterance can provide a variety of data that needs to be extracted with entities.

示例用户话语Example user utterance 意向Intent 实体Entities
“预订到西雅图的航班?”"Book a flight to Seattle?" BookFlightBookFlight 西雅图Seattle
“你的店铺何时开门?”"When does your store open?" 店铺营业时间和位置StoreHoursAndLocation 开门open
“安排下午 1 点与分销部的何石谈话”"Schedule a meeting at 1pm with Bob in Distribution" 安排谈话ScheduleMeeting 下午 1 点,何石1pm, Bob

查询预测终结点Query prediction endpoint

在生成模型并将其发布到终结点以后,客户端应用程序会将话语发送到已发布的预测终结点 API。After the model is built and published to the endpoint, the client application sends utterances to the published prediction endpoint API. API 将模型应用于要分析的文本。The API applies the model to the text for analysis. API 使用 JSON 格式的预测结果进行响应。The API responds with the prediction results in a JSON format.

JSON 终结点响应至少包含查询话语和得分最高的意向。The minimum JSON endpoint response contains the query utterance, and the top scoring intent. 它还可以提取数据,例如下面的“联系人类型”实体。It can also extract data such as the following Contact Type entity.

{
  "query": "I want to call my HR rep.",
  "topScoringIntent": {
    "intent": "HRContact",
    "score": 0.921233
  },
  "entities": [
    {
      "entity": "call",
      "type": "Contact Type",
      "startIndex": 10,
      "endIndex": 13,
      "score": 0.7615982
    }
  ]
}

改进模型预测Improve model prediction

在 LUIS 模型发布和接收实时用户话语之后,LUIS 提供了多种方式来提升预测的准确性:针对终结点话语的主动学习、针对专业领域字词内容的短语列表,以及用于减少所需话语数的模式After a LUIS model is published and receives real user utterances, LUIS provides several methods to improve prediction accuracy: active learning of endpoint utterances, phrase lists for domain word inclusion, and patterns to reduce the number of utterances needed.

开发生命周期Development lifecycle

LUIS 提供工具、版本控制以及与其他 LUIS 创建者的协作,以便在客户端应用程序和语言模型级别集成到完整的开发生命周期。LUIS provides tools, versioning, and collaboration with other LUIS authors to integrate into the full development life cycle at the level of the client application and the language model.

实现 LUISImplementing LUIS

作为 REST API,LUIS 可以与任何发送 HTTP 请求的产品、服务或框架配合使用。LUIS, as a REST API, can be used with any product, service, or framework that makes an HTTP request. 以下列表包含与 LUIS 配合使用的顶级 Azure 产品和服务。The following list contains the top Azure products and services used with LUIS.

通过机器人快速轻松地使用 LUIS 的工具:Tools to quickly and easily use LUIS with a bot:

  • LUIS CLI:NPM 包以独立命令行工具或导入的形式提供创作和预测。LUIS CLI The NPM package provides authoring and prediction with as either a stand-alone command line tool or as import.
  • LUISGen:LUISGen 是一个用于从导出的 LUIS 模型生成强类型 C# 和 typescript 源代码的工具。LUISGen LUISGen is a tool for generating strongly typed C# and typescript source code from an exported LUIS model.
  • 启用调度时,可以使用调度程序模型通过父应用使用多个 LUIS 和 QnA Maker 应用。Dispatch allows several LUIS and QnA Maker apps to be used from a parent app using dispatcher model.
  • LUDown:LUDown 是一个命令行工具,可帮助你管理机器人的语言模型。LUDown LUDown is a command line tool that helps manage language models for your bot.

与 LUIS 配合使用的其他认知服务:Other Cognitive Services used with LUIS:

  • QnA Maker 可将多种类型的文本组合到一个问题答案知识库中。QnA Maker allows several types of text to combine into a question and answer knowledge base.

使用 LUIS 的示例:Samples using LUIS:

后续步骤Next steps

使用预构建的自定义的域创作新的 LUIS 应用。Author a new LUIS app with a prebuilt or custom domain. 查询公用 IoT 应用的预测终结点Query the prediction endpoint of a public IoT app.