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

重要

现在,将对此服务的所有 HTTP 请求强制执行 TLS 1.2。TLS 1.2 is now enforced for all HTTP requests to this service.

语言理解 (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.

3 个客户端应用程序使用认知服务语言理解 (LUIS) 的概念图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.

LUIS 使用聊天机器人以通过自然语言理解 (NLP) 预测用户文本的概念图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 enables you to craft your custom language models to add intelligence to your application. 计算机学习的语言模型采用用户的非结构化输入文本,并以最相关意向 HRContact 返回 JSON 格式的响应。Machine learned language models take the user's unstructured input text and 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. 这些决策可能包括机器人框架代码中的决策树,以及对其他服务的调用。These decisions can include decision tree in the bot framework code and calls to other services.

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 应用包含一个特定于域的自然语言模型。Your 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 的好方法。Prebuilt domain models include the entire design for you and are a great way to start using LUIS quickly.

  • “自定义模型”LUIS 提供多种方法来识别自己的自定义模型,包括意向和实体。Custom model LUIS gives you several ways to identify your own custom models including intents, and entities. 实体包括机器学习的实体、特定实体或文本实体,以及机器学习的实体和文本实体的组合。Entities include machine-learning entities, specific or literal entities, and a combination of machine-learning 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 data that needs to be extracted.

示例用户话语Example user utterance IntentIntent 提取的数据Extracted data
Book a flight to Seattle? BookFlightBookFlight 西雅图Seattle
When does your store open? 店铺营业时间和位置StoreHoursAndLocation 开门open
Schedule a meeting at 1pm with Bob in Distribution 安排谈话ScheduleMeeting 下午 1 点,何石1pm, Bob

查询预测终结点Query prediction endpoint

在训练应用并将其发布到终结点以后,客户端应用程序会将言语发送到预测终结点 API。After your app is trained and published to the endpoint, the client application sends utterances to the prediction endpoint API. API 将模型应用到言语进行分析,并使用 JSON 格式的预测结果进行响应。The API applies the model to the utterance for analysis and 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 and overall sentiment.

{
    "query": "I want to call my HR rep",
    "prediction": {
        "normalizedQuery": "i want to call my hr rep",
        "topIntent": "HRContact",
        "intents": {
            "HRContact": {
                "score": 0.8582669
            }
        },
        "entities": {
            "Contact Type": [
                "call"
            ]
        },
        "sentiment": {
            "label": "negative",
            "score": 0.103343368
        }
    }
}

改进模型预测Improve model prediction

发布 LUIS 应用并收到真实用户言语后,LUIS 提供终结点言语的主动学习以提高预测准确性。After your LUIS app is published and receives real user utterances, LUIS provides active learning of endpoint utterances to improve prediction accuracy.

开发生命周期Development lifecycle

LUIS 提供工具、版本控制以及与其他 LUIS 创建者的协作,以便集成到完整的开发生命周期LUIS provides tools, versioning, and collaboration with other LUIS authors to integrate into the full development life cycle.

实现 LUISImplementing LUIS

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

LUIS 的顶级客户端应用程序是:The top client application for LUIS is:

通过机器人快速轻松地使用 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.
  • Bot Framework - Composer - 一个集成开发工具,供开发人员和多学科团队通过 Microsoft Bot Framework 构建机器人和聊天体验Bot framework - Composer - an integrated development tool for developers and multi-disciplinary teams to build bots and conversational experiences with the Microsoft Bot Framework

与 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.
  • 语音服务可将口述语言请求转化成文本。Speech service converts spoken language requests into text.
  • 可以使用聊天学习器,通过 LUIS 更快速地生成机器人聊天内容。Conversation learner allows you to build bot conversations quicker with LUIS.

使用 LUIS 的示例:Samples using LUIS:

后续步骤Next steps