安裝和執行 LUIS Docker 容器Install and run LUIS docker containers

Language Understanding (LUIS)容器會載入您已定型或已發行的 Language Understanding 模型。The Language Understanding (LUIS) container loads your trained or published Language Understanding model. Docker 容器是LUIS 應用程式,可讓您從容器的 API 端點存取查詢預測。As a LUIS app, the docker container provides access to the query predictions from the container's API endpoints. 您可以從容器收集查詢記錄,並將它們上傳回到 Language Understanding 應用程式,以改善應用程式的預測精確度。You can collect query logs from the container and upload them 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 容器,請注意下列必要條件:To run the LUIS container, note the following prerequisites:

必要項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 連線,以及傳送帳單資料至 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.
Azure Cognitive 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.
* 已定型或發佈的應用程式,並封裝為掛接形式連同相關聯的應用程式識別碼輸入容器中。* 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. 如果您要從撰寫 api取得 LUIS 的已封裝應用程式,則也需要您的_撰寫金鑰_。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} :此識別碼可用來選取應用程式。{APPLICATION_ID}: This ID is used to select the App. 格式為 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxThe format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

{API_KEY} :此金鑰可用來啟動容器。{API_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.

{ENDPOINT_URI} :[總覽] 頁面上所提供的端點。{ENDPOINT_URI}: The endpoint as provided on the Overview page.

撰寫金鑰和端點金鑰有不同的用途。The authoring key and endpoint key have different purposes. 請勿將其交替使用。Do not use them interchangeably.

正在搜集必要的參數Gathering required parameters

所有必要的認知服務容器都有三個主要參數。There are three primary parameters for all Cognitive Services' containers that are required. 使用者授權合約(EULA)必須存在,且值為 acceptThe end-user license agreement (EULA) must be present with a value of accept. 此外,也需要端點 URL 和 API 金鑰。Additionally, both an Endpoint URL and API Key are needed.

端點 URI {ENDPOINT_URI}Endpoint URI {ENDPOINT_URI}

[端點URI] 值可在對應認知服務資源的 [Azure 入口網站總覽] 頁面上取得。The Endpoint URI value is available on the Azure portal Overview page of the corresponding Cognitive Service resource. 流覽至 [總覽] 頁面,將滑鼠停留在端點上, 隨即會出現 Copy to clipboard 圖示。Navigate to the Overview page, hover over the Endpoint, and a Copy to clipboard icon will appear. 視需要複製並使用。Copy and use where needed.

收集端點 uri 以供稍後使用

金鑰 {API_KEY}Keys {API_KEY}

此金鑰用來啟動容器,並可在對應認知服務資源的 Azure 入口網站的 [金鑰] 頁面上取得。This key is used to start the container, and is available on the Azure portal's Keys page of the corresponding Cognitive Service resource. 流覽至 [金鑰] 頁面,然後按一下 [Copy to clipboard ] 圖示。Navigate to the Keys page, and click on the Copy to clipboard icon.

取得兩個金鑰的其中一個供稍後使用

重要

這些訂用帳戶金鑰可用來存取您的認知服務 API。These subscription keys are used to access your Cognitive Service API. 請勿共用您的金鑰。Do not share your keys. 以安全的方式儲存它們,例如使用 Azure Key Vault。Store them securely, for example, using Azure Key Vault. 我們也建議您定期重新產生這些金鑰。We also recommend regenerating these keys regularly. 進行 API 呼叫時,只需要一個金鑰。Only one key is necessary to make an API call. 重新產生第一個金鑰時,您可以使用第二個金鑰繼續存取服務。When regenerating the first key, you can use the second key for continued access to the service.

撰寫套件檔案的 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 1核心,2 GB 記憶體1 core, 2-GB memory 1核心,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. 例如,下列命令會列出每個已下載之容器映像的識別碼、存放庫和標籤,並將它格式化為表格: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
<image-id>       <repository-path/name>    <tag-name>

如何使用容器How to use the container

容器位於主機電腦上時,請透過下列程序來使用容器。Once the container is on the host computer, use the following process to work with the container.

使用 Language Understanding (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 the 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、POSTGET, POST 僅限容器Container only {APPLICATION_ID}_v{APPLICATION_VERSION}.gz
預備環境Staging GET、POSTGET, POST Azure 和容器Azure and container {APPLICATION_ID}_STAGING.gz
生產Production GET、POSTGET, 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 應用程式的應用程式識別碼。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

若要下載已發行的封裝,請參閱這裡的 API 檔To download the published package, refer to the API documentation here. 如果成功下載,回應會是 LUIS 套件檔案。If successfully downloaded, 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 應用程式的應用程式識別碼。The application ID of the trained LUIS app.
{APPLICATION_VERSION}{APPLICATION_VERSION} 已定型之 LUIS 應用程式的應用程式版本。The application version of the trained LUIS app.
{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

若要下載已定型的套件,請參閱這裡的 API 檔To download the trained package, refer to the API documentation here. 如果成功下載,回應會是 LUIS 套件檔案。If successfully downloaded, 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. 如需如何取得{ENDPOINT_URI}{API_KEY}值的詳細資訊,請參閱收集必要的參數Refer to gathering required parameters for details on how to get the {ENDPOINT_URI} and {API_KEY} values.

命令的範例可供使用。docker runExamples of the docker run command are available.

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={ENDPOINT_URI} ^
ApiKey={API_KEY}
  • 這個範例會使用C:磁片磁碟機上的目錄,以避免在 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 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 金鑰,也可以在 [azure 資源金鑰] 頁面上取得。The ApiKey value is the Key from the Azure Resources 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.

容器支援的端點 ApiEndpoint APIs supported by the container

容器的 V2 和V3 (預覽)版本都可供使用。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.

針對容器 API 請使用主機 http://localhost:5000Use the host, http://localhost:5000, for container APIs.

封裝類型Package type 方法Method 路由Route 查詢參數Query parameters
已發行Published GETPOSTGET, 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、POSTGET, 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 stringstring 使用者的語句。The user's utterance.
timezoneOffset numbernumber TimezoneOffset 可讓您變更時區 (預先建置的實體 datetimeV2 所使用的時區)。The timezoneOffset allows you to change the timezone used by the prebuilt entity datetimeV2.
verbose booleanboolean 設為 true 時,會傳回所有意圖及其分數。Returns all intents and their scores when set to true. 預設值為 false,只會傳回最高分意圖。Default is false, which returns only the top intent.
staging booleanboolean 設為 true 時,會從預備環境的結果中傳回查詢。Returns query from staging environment results if set to true.
log booleanboolean 記錄查詢,可供後續的主動式學習使用。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"

若要對預備環境進行查詢,請將 staging 查詢字串參數值變更為 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}是容器識別碼。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. 找出有問題之容器的外部 IP位址和公開端口, 然後開啟您最愛的網頁瀏覽器。Locate the External IP address and exposed port of the container in question, and open your favorite web browser. 使用下列各種要求 Url 來驗證容器是否正在執行。Use the various request URLs below to validate the container is running. 下面所列的範例要求 url http://localhost:5000是, 但您的特定容器可能會有所不同。The example request URLs listed below are http://localhost:5000, but your specific container may vary. 請記住, 您會依賴容器的外部 IP位址和公開的埠。Keep in mind that you're to rely on your container's External IP address and exposed port.

要求 URLRequest URL 用途Purpose
http://localhost:5000/ 容器會提供首頁。The container provides a home page.
http://localhost:5000/status 使用 HTTP GET 要求, 以驗證容器是否正在執行, 而不會造成端點查詢。Requested with an HTTP 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 容器會為端點提供一組完整的檔, 並使用 [試用] 功能。The container provides a full set of documentation for the endpoints and a Try it out 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+CTo 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.

提示

如需更多疑難排解資訊和指引,請參閱認知服務容器的常見問題(FAQ)For more troubleshooting information and guidance, see Cognitive Services containers frequently asked questions (FAQ).

帳務Billing

LUIS 容器會使用您 Azure 帳戶上的_認知服務_資源,將帳單資訊傳送至 azure。The LUIS container sends billing information to Azure, using a Cognitive Services resource on your Azure account.

至容器的查詢會使用於 Azure 資源的定價層計費<ApiKey>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.
此選項的值必須設定為 佈建的資源中指定的 API 金鑰BillingThe 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.
此選項的值必須設定為接受The 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:

  • 新的預建網域:這些企業導向的網域包括實體、範例語句和模式。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 應用程式移除不受支援的相依性。To export for container, you must remove unsupported dependencies from your LUIS app. 當您嘗試匯出容器時,LUIS 入口網站會報告您需要移除的這些不支援的功能。When you attempt to export for container, the LUIS portal reports these unsupported features that 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.2 tokenizer支援德文。German is only supported with the 1.0.2 tokenizer.
所有文化特性皆不支援的實體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.
Bing 拼字檢查Bing spell check 在容器中不支援外部相依性。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

在本文中,您已了解下載、安裝及執行 Language Understanding (LUIS) 容器的概念和工作流程。In this article, you learned concepts and workflow for downloading, installing, and running Language Understanding (LUIS) containers. 摘要說明:In summary:

  • Language Understanding (LUIS) 提供了一個適用於 Docker 的 Linux 容器,具備端點語句查詢預測的功能。Language Understanding (LUIS) provides one Linux container for Docker providing endpoint query predictions of utterances.
  • 容器映像可從 Microsoft Container Registry (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