在远程环境中训练好适配器后,可以使用一个简单的 Gradio 应用与模型进行交互。
通过命令面板执行 AI Toolkit: Provision Azure Container Apps for inference
来设置远程推理所需的 Azure 资源。在此过程中,您需要选择自己的 Azure 订阅和资源组。
默认情况下,推理的订阅和资源组应与微调时使用的保持一致。推理将使用相同的 Azure 容器应用环境,并访问存储在 Azure Files 中的模型和模型适配器,这些是在微调步骤中生成的。
如果您希望修改推理代码或重新加载推理模型,请执行 AI Toolkit: Deploy for inference
命令。此命令会将最新代码同步到 ACA 并重新启动副本。
部署成功后,模型即可通过此端点进行评估。
您可以通过 VSCode 通知中显示的“Go to Inference Endpoint”按钮访问推理 API。此外,Web API 端点可以在 ACA_APP_ENDPOINT
中找到,位于 ./infra/inference.config.json
和输出面板中。
注意: 推理端点可能需要几分钟才能完全运行。
文件夹 | 内容 |
---|---|
infra |
包含远程操作所需的所有配置。 |
infra/provision/inference.parameters.json |
保存用于配置 Azure 推理资源的 bicep 模板参数。 |
infra/provision/inference.bicep |
包含用于配置 Azure 推理资源的模板。 |
infra/inference.config.json |
配置文件,由 AI Toolkit: Provision Azure Container Apps for inference 命令生成。作为其他远程命令面板的输入。 |
配置 AI Toolkit
为推理配置 Azure 容器应用` command.
You can find configuration parameters in ./infra/provision/inference.parameters.json
file. Here are the details:
Parameter | Description |
---|---|
defaultCommands |
This is the commands to initiate a web API. |
maximumInstanceCount |
This parameter sets the maximum capacity of GPU instances. |
location |
This is the location where Azure resources are provisioned. The default value is the same as the chosen resource group's location. |
storageAccountName , fileShareName acaEnvironmentName , acaEnvironmentStorageName , acaAppName , acaLogAnalyticsName |
These parameters are used to name the Azure resources for provision. By default, they will be same to the fine-tuning resource name. You can input a new, unused resource name to create your own custom-named resources, or you can input the name of an already existing Azure resource if you'd prefer to use that. For details, refer to the section Using existing Azure Resources. |
By default, the inference provision use the same Azure Container App Environment, Storage Account, Azure File Share, and Azure Log Analytics that were used for fine-tuning. A separate Azure Container App is created solely for the inference API.
If you have customized the Azure resources during the fine-tuning step or want to use your own existing Azure resources for inference, specify their names in the ./infra/inference.parameters.json
文件。然后,从命令面板运行 AI Toolkit: Provision Azure Container Apps for inference
命令。此操作会更新指定的资源,并创建任何缺失的资源。
例如,如果您已有一个现有的 Azure 容器环境,那么您的 ./infra/finetuning.parameters.json
文件应如下所示:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
...
"acaEnvironmentName": {
"value": "<your-aca-env-name>"
},
"acaEnvironmentStorageName": {
"value": null
},
...
}
}
如果您更倾向于手动配置 Azure 资源,可以使用 ./infra/provision
folders. If you have already set up and configured all the Azure resources without using the AI Toolkit command palette, you can simply enter the resource names in the inference.config.json
文件中提供的 bicep 文件。
例如:
{
"SUBSCRIPTION_ID": "<your-subscription-id>",
"RESOURCE_GROUP_NAME": "<your-resource-group-name>",
"STORAGE_ACCOUNT_NAME": "<your-storage-account-name>",
"FILE_SHARE_NAME": "<your-file-share-name>",
"ACA_APP_NAME": "<your-aca-name>",
"ACA_APP_ENDPOINT": "<your-aca-endpoint>"
}
免责声明:
本文档使用 AI 翻译服务 Co-op Translator 进行翻译。虽然我们努力确保翻译的准确性,但请注意,自动翻译可能会包含错误或不准确之处。原始语言的文档应被视为权威来源。对于关键信息,建议使用专业人工翻译。我们不对因使用此翻译而导致的任何误解或误读承担责任。