您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

安装并运行 LUIS docker 容器Install and run LUIS docker containers

语言理解 (LUIS) 容器可将已训练或已发布的语言理解模型(也称为 LUIS 应用)加载到 docker 容器中并提供对容器的 API 终结点中的查询预测的访问权限。The Language Understanding (LUIS) container loads your trained or published Language Understanding model, also know as a LUIS app, into a docker container and provides access to the query predictions from the container's API endpoints. 可以从容器中收集查询日志并将这些日志上传回语言理解应用以提高应用的预测准确性。You can collect query logs from the container and upload these back to the Language Understanding app to improve the app's prediction accuracy.

以下视频演示如何使用此容器。The following video demonstrates using this container.

认知服务的容器演示Container demonstration for Cognitive Services

如果没有 Azure 订阅,请在开始之前创建一个免费帐户If you don't have an Azure subscription, create a free account before you begin.

必备组件Prerequisites

若要运行 LUIS 容器,必须具有以下各项:In order to run the LUIS container, you must have the following:

需要Required 目的Purpose
Docker 引擎Docker Engine 需要在主计算机上安装 Docker 引擎。You need the Docker Engine installed on a host computer. Docker 提供用于在 macOSWindowsLinux 上配置 Docker 环境的包。Docker provides packages that configure the Docker environment on macOS, Windows, and Linux. 有关 Docker 和容器的基础知识,请参阅 Docker 概述For a primer on Docker and container basics, see the Docker overview.

必须将 Docker 配置为允许容器连接 Azure 并向其发送账单数据。Docker must be configured to allow the containers to connect with and send billing data to Azure.

在 Windows 上,还必须将 Docker 配置为支持 Linux 容器。On Windows, Docker must also be configured to support Linux containers.

熟悉 DockerFamiliarity with Docker 应对 Docker 概念有基本的了解,例如注册表、存储库、容器和容器映像,以及基本的 docker 命令的知识。You should have a basic understanding of Docker concepts, like registries, repositories, containers, and container images, as well as knowledge of basic docker commands.
AzureCognitive Services资源和 LUIS打包应用程序文件Azure Cognitive Services resource and LUIS packaged app file 若要使用容器,必须具有:In order to use the container, you must have:

* A_认知服务_Azure 资源和关联的计费密钥计费终结点 URI。* A Cognitive Services Azure resource and the associated billing key the billing endpoint URI. 这两个值的资源概述和密钥页上可用,并且要求来启动该容器。Both values are available on the Overview and Keys pages for the resource and are required to start the container. 需将 luis/v2.0 路由添加到终结点 URI,如以下 BILLING_ENDPOINT_URI 示例所示。You need to add the luis/v2.0 routing to the endpoint URI as shown in the following BILLING_ENDPOINT_URI example.
* 已训练或已发布的应用,作为已安装的输入打包到具有其关联的应用 ID 的容器。* A trained or published app packaged as a mounted input to the container with its associated App ID. 可以从 LUIS 门户或创作 Api 获取打包的文件。You can get the packaged file from the LUIS portal or the Authoring APIs. 如果要获取 LUIS 从封装的应用程序创作 Api,您还需要您_创作密钥_。If you are getting LUIS packaged app from the authoring APIs, you will also need your Authoring Key.

这些要求用于将命令行参数传递到以下变量:These requirements are used to pass command-line arguments to the following variables:

{AUTHORING_KEY} :此密钥用于从云中的 LUIS 服务获取打包的应用并将查询日志上传回云。{AUTHORING_KEY}: This key is used to get the packaged app from the LUIS service in the cloud and upload the query logs back to the cloud. 格式为 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxThe format is xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.

{APPLICATION_ID} :此 ID 用于选择应用。{APPLICATION_ID}: This ID is used to select the App. 格式为 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxThe format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

{ENDPOINT_KEY} :此密钥用于启动容器。{ENDPOINT_KEY}: This key is used to start the container. 可以在两个位置找到终结点密钥。You can find the endpoint key in two places. 第一个是 Azure 门户中的_认知服务_资源的键列表。The first is the Azure portal within the Cognitive Services resource's keys list. 也可以在 LUIS 门户的“密钥和终结点”设置页上找到终结点密钥。The endpoint key is also available in the LUIS portal on the Keys and Endpoint settings page. 请勿使用初学者密钥。Do not use the starter key.

{BILLING_ENDPOINT} :例如:https://westus.api.cognitive.microsoft.com/luis/v2.0{BILLING_ENDPOINT}: An example is: https://westus.api.cognitive.microsoft.com/luis/v2.0.

创作密钥和终结点密钥具有不同的用途。The authoring key and endpoint key have different purposes. 请勿互换使用。Do not use them interchangeably.

包文件的创作 ApiAuthoring APIs for package file

创作 Api 的打包应用程序:Authoring APIs for packaged apps:

主计算机The host computer

主机是运行 Docker 容器且基于 x64 的计算机。The host is a x64-based computer that runs the Docker container. 它可以是本地计算机或 Azure 中的 Docker 托管服务,例如:It can be a computer on your premises or a Docker hosting service in Azure, such as:

容器要求和建议Container requirements and recommendations

此容器支持设置的最小值和建议值:This container supports minimum and recommended values for the settings:

容器Container 最小值Minimum 建议Recommended TPSTPS
(最小值, 最大值)(Minimum, Maximum)
LUISLUIS 单核,2 GB 内存1 core, 2 GB memory 单核,4 GB 内存1 core, 4 GB memory 20,4020,40
  • 每个核心必须至少为 2.6 千兆赫 (GHz) 或更快。Each core must be at least 2.6 gigahertz (GHz) or faster.
  • TPS - 每秒事务数TPS - transactions per second

核心和内存对应于 --cpus--memory 设置,用作 docker run 命令的一部分。Core and memory correspond to the --cpus and --memory settings, which are used as part of the docker run command.

使用 docker pull 获取容器映像Get the container image with docker pull

使用 docker pull 命令从 mcr.microsoft.com/azure-cognitive-services/luis 存储库下载容器映像:Use the docker pull command to download a container image from the mcr.microsoft.com/azure-cognitive-services/luis repository:

docker pull mcr.microsoft.com/azure-cognitive-services/luis:latest

使用 docker pull 命令下载容器映像。Use the docker pull command to download a container image.

有关可用标记的完整说明(如上述命令中使用的 latest),请参阅 Docker Hub 上的 LUISFor a full description of available tags, such as latest used in the preceding command, see LUIS on Docker Hub.

提示

可以使用 docker images 命令列出下载的容器映像。You can use the docker images command to list your downloaded container images. 例如,以下命令以表格列出每个下载的容器映像的 ID、存储库和标记:For example, the following command lists the ID, repository, and tag of each downloaded container image, formatted as a table:

docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}"

IMAGE ID            REPOSITORY              TAG
ebbee78a6baa       <container-name>         latest

如何使用容器How to use the container

一旦容器位于主计算机上,请通过以下过程使用容器。Once the container is on the host computer, use the following process to work with the container.

使用语言理解 (LUIS) 容器的过程

  1. 通过 LUIS 门户或 LUIS API 导出容器的包Export package for container from LUIS portal or LUIS APIs.
  2. 将包文件移动到主计算机上的所需 输入目录中。Move package file into the required input directory on the host computer. 请勿重命名、更改、覆盖或解压缩 LUIS 包文件。Do not rename, alter, overwrite, or decompress LUIS package file.
  3. 使用所需的输入装入点 和计费设置运行容器Run the container, with the required input mount and billing settings. 提供 docker run 命令的多个示例More examples of the docker run command are available.
  4. 查询容器的预测终结点Querying the container's prediction endpoint.
  5. 使用完此容器后,从 LUIS 门户的输出装入点导入终结点日志停止容器。When you are done with the container, import the endpoint logs from the output mount in the LUIS portal and stop the container.
  6. 在“查看终结点话语” 页上使用 LUIS 门户的主动学习改进应用。Use LUIS portal's active learning on the Review endpoint utterances page to improve the app.

无法更改正在容器中运行的应用。The app running in the container can't be altered. 若要更改容器中的应用,必须使用 LUIS 门户或使用 LUIS 创作 API 更改 LUIS 服务中的应用。In order the change the app in the container, you need to change the app in the LUIS service using the LUIS portal or use the LUIS authoring APIs. 然后进行训练和/或发布,下载新包并再次运行该容器。Then train and/or publish, then download a new package and run the container again.

容器内的 LUIS 应用无法导出回 LUIS 服务。The LUIS app inside the container can't be exported back to the LUIS service. 只能上传查询日志。Only the query logs can be uploaded.

从 LUIS 导出打包的应用Export packaged app from LUIS

LUIS 容器需要已训练或已发布的 LUIS 应用才能回复用户话语的预测查询。The LUIS container requires a trained or published LUIS app to answer prediction queries of user utterances. 若要获取 LUIS 应用,请使用已训练或已发布的包 API。In order to get the LUIS app, use either the trained or published package API.

默认位置是运行 docker run 命令的 input 子目录。The default location is the input subdirectory in relation to where you run the docker run command.

将包文件置于某个目录中,然后在运行 docker 容器时引用此目录作为输入装入点。Place the package file in a directory and reference this directory as the input mount when you run the docker container.

包类型Package types

输入装入点目录可以同时包含应用的 生产、过渡 和已训练 版本。The input mount directory can contain the Production, Staging, and Trained versions of the app simultaneously. 所有包均已装载。All the packages are mounted.

包类型Package Type 查询终结点 APIQuery Endpoint API 查询可用性Query availability 包文件名格式Package filename format
训练结束Trained 获取、发布Get, Post 仅容器Container only {APPLICATION_ID}_v{APPLICATION_VERSION}.gz
过渡Staging 获取、发布Get, Post Azure 和容器Azure and container {APPLICATION_ID}_STAGING.gz
生产Production 获取、发布Get, Post Azure 和容器Azure and container {APPLICATION_ID}_PRODUCTION.gz

重要

请勿重命名、更改、覆盖或解压缩 LUIS 包文件。Do not rename, alter, overwrite, or decompress the LUIS package files.

打包先决条件Packaging prerequisites

在打包 LUIS 应用程序之前,必须满足以下条件:Before packaging a LUIS application, you must have the following:

打包要求Packaging Requirements 详细信息Details
Azure 认知服务资源实例Azure Cognitive Services resource instance 支持的区域包括Supported regions include

美国西部 (westus)West US (westus)
西欧 (westeurope)West Europe (westeurope)
澳大利亚东部 (australiaeast)Australia East (australiaeast)
已训练或已发布的 LUIS 应用Trained or published LUIS app 没有不受支持的依赖项With no unsupported dependencies.
访问主计算机的文件系统Access to the host computer's file system 主计算机必须允许输入装入点The host computer must allow an input mount.

通过 LUIS 门户导出应用包Export app package from LUIS portal

LUIS 门户提供导出已训练或已发布的应用包的功能。The LUIS portal provides the ability to export the trained or published app's package.

通过 LUIS 门户导出已发布的应用包Export published app's package from LUIS portal

可从 “我的应用”列表页中获取已发布的应用包。The published app's package is available from the My Apps list page.

  1. 登录到 LUIS 门户Sign on to the LUIS portal.
  2. 选中列表中应用名称左侧的复选框。Select the checkbox to the left of the app name in the list.
  3. 从列表上方的上下文工具栏中选择 “导出”项。Select the Export item from the contextual toolbar above the list.
  4. 选择“导出容器 (GZIP)” 。Select Export for container (GZIP).
  5. 选择“生产槽”或“过渡槽”的环境 。Select the environment of Production slot or Staging slot.
  6. 将从浏览器下载包。The package is downloaded from the browser.

从“应用”页面的“导出”菜单导出容器的已发布包

通过 LUIS 门户导出已训练的应用包Export trained app's package from LUIS portal

可从 “版本”列表页中获取已训练的应用包。The trained app's package is available from the Versions list page.

  1. 登录到 LUIS 门户Sign on to the LUIS portal.
  2. 在列表中选择应用。Select the app in the list.
  3. 在应用的导航栏中选择“管理” 。Select Manage in the app's navigation bar.
  4. 在左侧导航栏中选择“版本” 。Select Versions in the left navigation bar.
  5. 选中列表中版本名称左侧的复选框。Select the checkbox to the left of the version name in the list.
  6. 从列表上方的上下文工具栏中选择 “导出”项。Select the Export item from the contextual toolbar above the list.
  7. 选择“导出容器 (GZIP)” 。Select Export for container (GZIP).
  8. 将从浏览器下载包。The package is downloaded from the browser.

从“版本”页面的“导出”菜单导出容器的已训练包

通过 API 导出已发布的应用包Export published app's package from API

使用以下 REST API 方法打包已发布的 LUIS 应用。Use the following REST API method, to package a LUIS app that you've already published. 使用 HTTP 规范下方的表将 API 调用中的占位符替换为自己相应的值。Substituting your own appropriate values for the placeholders in the API call, using the table below the HTTP specification.

GET /luis/api/v2.0/package/{APPLICATION_ID}/slot/{APPLICATION_ENVIRONMENT}/gzip HTTP/1.1
Host: {AZURE_REGION}.api.cognitive.microsoft.com
Ocp-Apim-Subscription-Key: {AUTHORING_KEY}
占位符Placeholder Value
{APPLICATION_ID}{APPLICATION_ID} 已发布 LUIS 应用的应用程序 ID。The application ID of the published LUIS app.
{APPLICATION_ENVIRONMENT}{APPLICATION_ENVIRONMENT} 已发布 LUIS 应用的环境。The environment of the published LUIS app. 使用以下值之一:Use one of the following values:
PRODUCTION
STAGING
{AUTHORING_KEY}{AUTHORING_KEY} 已发布 LUIS 应用的 LUIS 帐户的创作密钥。The authoring key of the LUIS account for the published LUIS app.
可以从 LUIS 门户的“用户设置” 页面中获取创作密钥。You can get your authoring key from the User Settings page on the LUIS portal.
{AZURE_REGION}{AZURE_REGION} 相应的 Azure 区域:The appropriate Azure region:

westus - 美国西部westus - West US
westeurope - 西欧westeurope - West Europe
australiaeast - 澳大利亚东部australiaeast - Australia East

使用以下 CURL 命令下载已发布的包,用你自己的值进行替换:Use the following CURL command to download the published package, substituting your own values:

curl -X GET \
https://{AZURE_REGION}.api.cognitive.microsoft.com/luis/api/v2.0/package/{APPLICATION_ID}/slot/{APPLICATION_ENVIRONMENT}/gzip  \
 -H "Ocp-Apim-Subscription-Key: {AUTHORING_KEY}" \
 -o {APPLICATION_ID}_{APPLICATION_ENVIRONMENT}.gz

如果成功,则响应是 LUIS 包文件。If successful, the response is a LUIS package file. 将文件保存在为容器的输入装入点指定的存储位置中。Save the file in the storage location specified for the input mount of the container.

通过 API 导出已训练的应用包Export trained app's package from API

使用以下 REST API 方法打包已训练的 LUIS 应用程序。Use the following REST API method, to package a LUIS application that you've already trained. 使用 HTTP 规范下方的表将 API 调用中的占位符替换为自己相应的值。Substituting your own appropriate values for the placeholders in the API call, using the table below the HTTP specification.

GET /luis/api/v2.0/package/{APPLICATION_ID}/versions/{APPLICATION_VERSION}/gzip HTTP/1.1
Host: {AZURE_REGION}.api.cognitive.microsoft.com
Ocp-Apim-Subscription-Key: {AUTHORING_KEY}
占位符Placeholder Value
{APPLICATION_ID}{APPLICATION_ID} 已训练 LUIS 应用程序的应用程序 ID。The application ID of the trained LUIS application.
{APPLICATION_VERSION}{APPLICATION_VERSION} 已训练 LUIS 应用程序的应用程序版本。The application version of the trained LUIS application.
{AUTHORING_KEY}{AUTHORING_KEY} 已发布 LUIS 应用的 LUIS 帐户的创作密钥。The authoring key of the LUIS account for the published LUIS app.
可以从 LUIS 门户的“用户设置” 页面中获取创作密钥。You can get your authoring key from the User Settings page on the LUIS portal.
{AZURE_REGION}{AZURE_REGION} 相应的 Azure 区域:The appropriate Azure region:

westus - 美国西部westus - West US
westeurope - 西欧westeurope - West Europe
australiaeast - 澳大利亚东部australiaeast - Australia East

使用以下 CURL 命令下载已训练的包:Use the following CURL command to download the trained package:

curl -X GET \
https://{AZURE_REGION}.api.cognitive.microsoft.com/luis/api/v2.0/package/{APPLICATION_ID}/versions/{APPLICATION_VERSION}/gzip  \
 -H "Ocp-Apim-Subscription-Key: {AUTHORING_KEY}" \
 -o {APPLICATION_ID}_v{APPLICATION_VERSION}.gz

如果成功,则响应是 LUIS 包文件。If successful, the response is a LUIS package file. 将文件保存在为容器的输入装入点指定的存储位置中。Save the file in the storage location specified for the input mount of the container.

通过 docker run 运行容器Run the container with docker run

使用 docker run 命令运行容器。Use the docker run command to run the container. 该命令使用以下参数:The command uses the following parameters:

占位符Placeholder Value
{ENDPOINT_KEY}{ENDPOINT_KEY} 此密钥用于启动容器。This key is used to start the container. 请勿使用初学者密钥。Do not use the starter key.
{BILLING_ENDPOINT}{BILLING_ENDPOINT} 计费的终结点值是可在 Azure 门户上Cognitive Services概述页。The billing endpoint value is available on the Azure portal's Cognitive Services Overview page. 您需要添加luis/v2.0路由到终结点 URI,如下面的示例中所示: https://westus.api.cognitive.microsoft.com/luis/v2.0You need to add the luis/v2.0 routing to the endpoint URI as shown in the following example: https://westus.api.cognitive.microsoft.com/luis/v2.0.

在以下示例 docker run 命令中,请将这些参数替换为自己的值。Replace these parameters with your own values in the following example docker run command. 在 Windows 控制台中运行该命令。Run the command in the Windows console.

docker run --rm -it -p 5000:5000 ^
--memory 4g ^
--cpus 2 ^
--mount type=bind,src=c:\input,target=/input ^
--mount type=bind,src=c:\output\,target=/output ^
mcr.microsoft.com/azure-cognitive-services/luis ^
Eula=accept ^
Billing={BILLING_ENDPOINT} ^
ApiKey={ENDPOINT_KEY}
  • 此示例使用现成的 directoryc:驱动器以避免在 Windows 上的任何权限冲突。This example uses the directory off the c: drive to avoid any permission conflicts on Windows. 如果需要使用特定目录作为输入目录,则需要授予 docker 服务权限。If you need to use a specific directory as the input directory, you may need to grant the docker service permission.
  • 除非非常熟悉 docker 容器,否则不要更改参数顺序。Do not change the order of the arguments unless you are very familiar with docker containers.
  • 如果使用不同的操作系统,使用正确的控制台终端,文件夹语法进行装载和行继续符为您的系统。If you are using a different operating system, use the correct console/terminal, folder syntax for mounts, and line continuation character for your system. 这些示例假定具有行继续符的 Windows 控制台^These examples assume a Windows console with a line continuation character ^. 由于容器是 Linux 操作系统,目标装入使用 Linux 样式文件夹语法。Because the container is a Linux operating system, the target mount uses a Linux-style folder syntax.

此命令:This command:

  • 从 LUIS 容器映像运行容器Runs a container from the LUIS container image
  • 从位于容器主机上的 c:\input 中的输入装入点加载 LUIS 应用Loads LUIS app from input mount at c:\input, located on container host
  • 分配两个 CPU 内核和 4 千兆字节 (GB) 的内存Allocates two CPU cores and 4 gigabytes (GB) of memory
  • 公开 TCP 端口 5000,并为容器分配伪 TTYExposes TCP port 5000 and allocates a pseudo-TTY for the container
  • 将容器和 LUIS 日志保存到位于容器主机上的 c:\output 中的输出装入点Saves container and LUIS logs to output mount at c:\output, located on container host
  • 退出后自动删除容器。Automatically removes the container after it exits. 容器映像在主计算机上仍然可用。The container image is still available on the host computer.

提供 docker run 命令的多个示例More examples of the docker run command are available.

重要

必须指定 EulaBillingApiKey 选项运行容器;否则,该容器不会启动。The Eula, Billing, and ApiKey options must be specified to run the container; otherwise, the container won't start. 有关详细信息,请参阅计费For more information, see Billing. ApiKey 值是 LUIS 门户中“密钥和终结点”页面中的“密钥” ,也可以在 Azure Cognitive Services资源密钥页上找到。The ApiKey value is the Key from the Keys and Endpoints page in the LUIS portal and is also available on the Azure Cognitive Services resource keys page.

在同一主机上运行多个容器Run multiple containers on the same host

若要使用公开端口运行多个容器,请确保在运行每个容器时使用不同的公开端口。If you intend to run multiple containers with exposed ports, make sure to run each container with a different exposed port. 例如,在端口 5000 上运行第一个容器,在端口 5001 上运行第二个容器。For example, run the first container on port 5000 and the second container on port 5001.

可以让此容器和其他 Azure 认知服务容器一起运行在该主机上。You can have this container and a different Azure Cognitive Services container running on the HOST together. 此外,还可以让同一认知服务容器的多个容器一起运行。You also can have multiple containers of the same Cognitive Services container running.

终结点 Api 支持的容器Endpoint APIs supported by the container

这两个 V2 和V3 (预览)与容器提供的 API 版本。Both V2 and V3 (Preview) versions of the API are available with the container.

查询容器的预测终结点Query the container's prediction endpoint

容器提供了基于 REST 的查询预测终结点 API。The container provides REST-based query prediction endpoint APIs. 已发布(过渡或生产)应用的终结点包含的路由与已训练应用的终结点不同 。Endpoints for published (staging or production) apps have a different route than endpoints for trained apps.

使用主机 https://localhost:5000,以获得容器 API。Use the host, https://localhost:5000, for container APIs.

包类型Package type 方法Method 路由Route 查询参数Query parameters
已发布Published 获取发布Get, Post /luis/v2.0/apps/{appId}?/luis/v2.0/apps/{appId}? q={q}q={q}
&staging&staging
[&timezoneOffset][&timezoneOffset]
[&verbose][&verbose]
[&log][&log]
训练结束Trained 获取、发布Get, Post /luis/v2.0/apps/{appId}/versions/{versionId}?/luis/v2.0/apps/{appId}/versions/{versionId}? q={q}q={q}
[&timezoneOffset][&timezoneOffset]
[&verbose][&verbose]
[&log][&log]

查询参数配置查询响应的返回方式以及返回内容:The query parameters configure how and what is returned in the query response:

查询参数Query parameter TypeType 目的Purpose
q 字符串string 用户的话语。The user's utterance.
timezoneOffset 数字number 通过 timezoneOffset 可以更改时区,该时区由预生成实体 datetimeV2 使用。The timezoneOffset allows you to change the timezone used by the prebuilt entity datetimeV2.
verbose 布尔值boolean 设置为 true 时,返回所有意向及其分数。Returns all intents and their scores when set to true. 默认值为 false 时,仅返回评分最高的意向。Default is false, which returns only the top intent.
staging 布尔值boolean 设置为 true 时,返回过渡环境结果中的查询。Returns query from staging environment results if set to true.
log 布尔值boolean 记录查询,以便以后用于主动学习Logs queries, which can be used later for active learning. 默认值为 true。Default is true.

查询已发布的应用Query published app

用于查询已发布应用的容器的示例 CURL 命令是:An example CURL command for querying the container for a published app is:

curl -X GET \
"http://localhost:5000/luis/v2.0/apps/{APPLICATION_ID}?q=turn%20on%20the%20lights&staging=false&timezoneOffset=0&verbose=false&log=true" \
-H "accept: application/json"

若要对过渡 环境执行查询,请将过渡 查询字符串参数值更改为 true:To make queries to the Staging environment, change the staging query string parameter value to true:

staging=true

查询已训练的应用Query trained app

用于查询已训练应用的容器的示例 CURL 命令是:An example CURL command for querying the container for a trained app is:

curl -X GET \
"http://localhost:5000/luis/v2.0/apps/{APPLICATION_ID}/versions/{APPLICATION_VERSION}?q=turn%20on%20the%20lights&timezoneOffset=0&verbose=false&log=true" \
-H "accept: application/json"

版本名称最多包含 10 个字符,并且仅包含 URL 中允许的字符。The version name has a maximum of 10 characters and contains only characters allowed in a URL.

导入终结点日志以供主动学习Import the endpoint logs for active learning

如果为 LUIS 容器指定了输出装入点,则应用查询日志文件将保存在输出目录中,其中 {INSTANCE_ID} 是容器 ID。If an output mount is specified for the LUIS container, app query log files are saved in the output directory, where {INSTANCE_ID} is the container ID. 应用查询日志包含提交到 LUIS 容器的每个预测查询的查询、响应和时间戳。The app query log contains the query, response, and timestamps for each prediction query submitted to the LUIS container.

以下位置显示了容器的日志文件的嵌套目录结构。The following location shows the nested directory structure for the container's log files.

/output/luis/{INSTANCE_ID}/

从 LUIS 门户中选择应用,然后选择“导入终结点日志” 以上传这些日志。From the LUIS portal, select your app, then select Import endpoint logs to upload these logs.

导入容器的日志文件以供主动学习

上传日志后,在 LUIS 门户中查看终结点话语。After the log is uploaded, review the endpoint utterances in the LUIS portal.

验证容器是否正在运行Validate that a container is running

有几种方法可用于验证容器是否正在运行。There are several ways to validate that the container is running.

请求Request 目的Purpose
http://localhost:5000/ 容器提供主页。The container provides a home page.
http://localhost:5000/status 使用 GET 进行了请求,从而在不会导致终结点查询的情况下验证容器是否正在运行。Requested with GET, to validate that the container is running without causing an endpoint query. 此请求可用于 Kubernetes 运行情况和就绪情况探测This request can be used for Kubernetes liveness and readiness probes.
http://localhost:5000/swagger 容器提供终结点以及 Try it now 功能的整套文档。The container provides a full set of documentation for the endpoints and a Try it now feature. 使用此功能可以将设置输入到基于 Web 的 HTML 表单并进行查询,而无需编写任何代码。With this feature, you can enter your settings into a web-based HTML form and make the query without having to write any code. 查询返回后,将提供示例 CURL 命令,用于演示所需的 HTTP 标头和正文格式。After the query returns, an example CURL command is provided to demonstrate the HTTP headers and body format that's required.

容器的主页

停止容器Stop the container

若要关闭容器,请在运行容器的命令行环境中按 Ctrl+C 。To shut down the container, in the command-line environment where the container is running, press Ctrl+C.

故障排除Troubleshooting

如果运行启用了输出装入点和日志记录的容器,该容器会生成有助于排查启动或运行容器时发生的问题的日志文件。If you run the container with an output mount and logging enabled, the container generates log files that are helpful to troubleshoot issues that happen while starting or running the container.

计费Billing

LUIS 容器使用 Azure 帐户中的认知服务 资源向 Azure 发送账单信息。The LUIS container sends billing information to Azure, using a Cognitive Services resource on your Azure account.

对该容器的查询在用于 <ApiKey> 的 Azure 资源的定价层计费。Queries to the container are billed at the pricing tier of the Azure resource that's used for the <ApiKey>.

如果未连接到计费终结点进行计量,则 Azure 认知服务容器不会被许可运行。Azure Cognitive Services containers aren't licensed to run without being connected to the billing endpoint for metering. 必须始终让容器可以向计费终结点传送计费信息。You must enable the containers to communicate billing information with the billing endpoint at all times. 认知服务容器不会将客户数据(例如,正在分析的图像或文本)发送给 Microsoft。Cognitive Services containers don't send customer data, such as the image or text that's being analyzed, to Microsoft.

连接到 AzureConnect to Azure

容器需要计费参数值才能运行。The container needs the billing argument values to run. 这些值使容器可以连接到计费终结点。These values allow the container to connect to the billing endpoint. 容器约每 10 到 15 分钟报告一次使用情况。The container reports usage about every 10 to 15 minutes. 如果容器未在允许的时间范围内连接到 Azure,容器将继续运行,但不会为查询提供服务,直到计费终结点恢复。If the container doesn't connect to Azure within the allowed time window, the container continues to run but doesn't serve queries until the billing endpoint is restored. 尝试连接按 10 到 15 分钟的相同时间间隔进行 10 次。The connection is attempted 10 times at the same time interval of 10 to 15 minutes. 如果无法在 10 次尝试内连接到计费终结点,容器将停止运行。If it can't connect to the billing endpoint within the 10 tries, the container stops running.

计费参数Billing arguments

必须使用有效值指定所有以下三个选项,才能使 docker run 命令启动容器:For the docker run command to start the container, all three of the following options must be specified with valid values:

选项Option 说明Description
ApiKey 用于跟踪计费信息的认知服务资源的 API 密钥。The API key of the Cognitive Services resource that's used to track billing information.
必须将此选项的值设置为 Billing 中指定的已预配资源的 API 密钥。The value of this option must be set to an API key for the provisioned resource that's specified in Billing.
Billing 用于跟踪计费信息的认知服务资源的终结点。The endpoint of the Cognitive Services resource that's used to track billing information.
必须将此选项的值设置为已预配的 Azure 资源的终结点 URI。The value of this option must be set to the endpoint URI of a provisioned Azure resource.
Eula 表示已接受容器的许可条款。Indicates that you accepted the license for the container.
此选项的值必须设置为 acceptThe value of this option must be set to accept.

有关这些选项的详细信息,请参阅配置容器For more information about these options, see Configure containers.

支持的 latest 容器依赖项Supported dependencies for latest container

在 2019 //Build 上发布的最新容器将支持:The latest container, released at 2019 //Build, will support:

  • 必应拼写检查:使用 &spellCheck=true&bing-spell-check-subscription-key={bingKey} 查询字符串参数向查询预测终结点发出的请求。Bing spell check: requests to the query prediction endpoint with the &spellCheck=true&bing-spell-check-subscription-key={bingKey} query string parameters. 若要了解详细信息,请参阅必应拼写检查 v7 教程Use the Bing Spell Check v7 tutorial to learn more. 如果使用此功能,则容器会将话语发送到必应拼写检查 V7 资源。If this feature is used, the container sends the utterance to your Bing Spell Check V7 resource.
  • 新的预生成的域:这些聚焦于企业的域包括实体、示例话语以及模式。New prebuilt domains: these enterprise-focused domains include entities, example utterances, and patterns. 扩展这些供自己使用的域。Extend these domains for your own use.

不支持的 latest 容器依赖项Unsupported dependencies for latest container

如果 LUIS 应用有不受支持的依赖项,则在删除这些不受支持的功能之前,无法针对容器进行导出If your LUIS app has unsupported dependencies, you won't be able to export for container until you remove the unsupported features. 尝试针对容器进行导出时,LUIS 门户会报告需删除的不受支持的功能。When you attempt to export for container, the LUIS portal reports the unsupported features you need to remove.

如果 LUIS 应用程序不包括 以下任何依赖项,则可以使用该应用程序:You can use a LUIS application if it doesn't include any of the following dependencies:

不受支持的应用配置Unsupported app configurations 详细信息Details
不受支持的容器区域性Unsupported container cultures 荷兰语 (nl-NL)Dutch (nl-NL)
日语 (ja-JP)Japanese (ja-JP)
1.0.1 tokenizer 或更高版本支持德语。German is only supported with the 1.0.1 tokenizer or later.
所有区域性不支持的实体Unsupported entities for all cultures 所有区域性的 KeyPhrase 预生成实体KeyPhrase prebuilt entity for all cultures
英语 (EN-US) 区域性不支持的实体Unsupported entities for English (en-US) culture GeographyV2 预生成实体GeographyV2 prebuilt entities
语音启动Speech priming 容器中不支持外部依赖项。External dependencies are not supported in the container.
情绪分析Sentiment analysis 容器中不支持外部依赖项。External dependencies are not supported in the container.

博客文章Blog posts

开发人员示例Developer samples

可在 GitHub 存储库中查看开发人员示例。Developer samples are available at our GitHub repository.

观看网络研讨会View webinar

加入网络研讨会了解:Join the webinar to learn about:

  • 如何将认知服务部署到任何使用 Docker 的计算机How to deploy Cognitive Services to any machine using Docker
  • 如何将认知服务部署到 AKSHow to deploy Cognitive Services to AKS

摘要Summary

在本文中,我们已学习相关的概念,以及语言理解 (LUIS) 容器的下载、安装和运行工作流。In this article, you learned concepts and workflow for downloading, installing, and running Language Understanding (LUIS) containers. 综上所述:In summary:

  • 语言理解 (LUIS) 为 Docker 提供一个 Linux 容器,用于提供话语的终结点查询预测。Language Understanding (LUIS) provides one Linux container for Docker providing endpoint query predictions of utterances.
  • 从 Microsoft 容器注册表 (MCR) 下载容器映像。Container images are downloaded from the Microsoft Container Registry (MCR).
  • 容器映像在 Docker 中运行。Container images run in Docker.
  • 可以使用 REST API 来通过指定容器的主机 URI 查询容器终结点。You can use REST API to query the container endpoints by specifying the host URI of the container.
  • 必须在实例化容器时指定账单信息。You must specify billing information when instantiating a container.

重要

如果未连接到 Azure 进行计量,则无法授权并运行认知服务容器。Cognitive Services containers are not licensed to run without being connected to Azure for metering. 客户需要始终让容器向计量服务传送账单信息。Customers need to enable the containers to communicate billing information with the metering service at all times. 认知服务容器不会将客户数据(例如,正在分析的图像或文本)发送给 Microsoft。Cognitive Services containers do not send customer data (for example, the image or text that is being analyzed) to Microsoft.

后续步骤Next steps