

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 在 Amazon OpenSearch 无服务器上配置 Machine Learning
<a name="serverless-configure-machine-learning"></a>

## 机器学习
<a name="serverless-configure-machine-learning-what-is"></a>

机器学习（ML）通过机器学习算法和远程模型提供机器学习功能。通过访问这些模型，您可以运行多个人工智能工作流程，例如 RAG 或语义搜索。机器学习支持使用最新外部托管模型进行生成式人工智能使用案例的实验和生产部署，这些模型可通过连接器进行配置。配置连接器后，必须将其配置到模型并部署，才能执行预测。

## 连接器
<a name="serverless-configure-machine-learning-connectors"></a>

连接器便于访问在第三方机器学习平台上托管的模型。它们充当您的 OpenSearch 集群和远程模型之间的网关。有关更多信息，请参阅以下文档：
+ 在*OpenSearch 文档*网站上@@ [为第三方 ML 平台创建连接器](https://docs.opensearch.org/latest/ml-commons-plugin/remote-models/connectors/)
+ [用于外部平台的连接器](https://docs.amazonaws.cn/opensearch-service/latest/developerguide/ml-external-connector.html)
+ [连接器适用于 Amazon Web Services 服务](https://docs.amazonaws.cn/opensearch-service/latest/developerguide/ml-amazon-connector.html)
**重要**  
创建信任策略时，请添加**ml.opensearchservice.amazonaws.com**为 OpenSearch 服务原则。
跳过[连接器](https://docs.amazonaws.cn/opensearch-service/latest/developerguide/ml-amazon-connector.html)页面上显示如何在策略中配置域的步骤。
在[配置权限](https://docs.amazonaws.cn/opensearch-service/latest/developerguide/ml-amazon-connector.html#connector-sagemaker-prereq)步骤中添加 `iam:PassRole` 语句。
跳过 “ OpenSearch 控制面板” 中的 **“映射 ML 角色**” 步骤。无需配置后端角色。这适用于外部平台[的 Amazon Web Services 服务连接](https://docs.amazonaws.cn/opensearch-service/latest/developerguide/ml-amazon-connector.html)器和[外部平台的连接器](https://docs.amazonaws.cn/opensearch-service/latest/developerguide/ml-external-connector.html)。
在向集合端点发出的 SigV4 请求中，将服务名称设置为 **aoss** 而非 **es**。

##   模型
<a name="serverless-configure-machine-learning-models"></a>

模型是贯穿各类人工智能工作流程的核心功能。通常，您需要将连接器与模型关联，才能使用该连接器进行预测。模型处于已部署状态后，即可运行预测。有关更多信息，请参阅*OpenSearch 文档*网站[上的注册第三方平台上托管的模型](https://docs.opensearch.org/latest/ml-commons-plugin/api/model-apis/register-model/#register-a-model-hosted-on-a-third-party-platform)。

**注意**  
 OpenSearch Serverless 并非支持所有模型功能，例如本地模型。有关更多信息，请参阅 [不支持的 Machine Learning APIs 和功能](serverless-machine-learning-unsupported-features.md)。

## 配置机器学习的权限
<a name="serverless-configure-machine-learning-permissions"></a>

以下部分介绍机器学习（ML）所需的集合数据访问策略。*placeholder values*用您的具体信息替换。有关更多信息，请参阅 [受支持的策略权限](serverless-data-access.md#serverless-data-supported-permissions)。

```
{
    "Rules": [
        {
            "Resource": [
                "model/collection_name/*"
            ],
            "Permission": [
                "aoss:DescribeMLResource",
                "aoss:CreateMLResource",
                "aoss:UpdateMLResource",
                "aoss:DeleteMLResource",
                "aoss:ExecuteMLResource"
            ],
            "ResourceType": "model"
        }
    ],
    "Principal": [
        "arn:aws:iam::account_id:role/role_name"
    ],
    "Description": "ML full access policy for collection_name"
}
```
+ **aoss: Des** cribe MLResource-授予搜索和查询连接器、模型和模型组的权限。
+ **aoss: Cre** ate MLResource-授予创建连接器、模型和模型组的权限。
+ **aoss: Update MLResource**-授予更新连接器、模型和模型组的权限。
+ **aoss: Delete MLResource**-授予删除连接器、模型和模型组的权限。
+ **aoss: execute MLResource**-授予对模型执行预测的权限。