本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
创建要查询的推理端点
推理端点允许您查询模型训练过程构造的一个特定模型。端点附加到训练过程能够生成的给定类型中性能最佳的模型。然后,端点能够接受来自 Neptune 的 Gremlin 查询,并返回该模型对查询中输入的预测。创建推理端点后,它会一直处于活动状态,直到您将其删除。
管理 Neptune ML 的推理端点
对从 Neptune 导出的数据完成模型训练后,可以使用如下命令创建推理端点:
- AWS CLI
-
aws neptunedata create-ml-endpoint \ --endpoint-url https://your-neptune-endpoint:port\ --id "(a unique ID for the new endpoint)" \ --ml-model-training-job-id "(the model-training job-id of a completed job)"有关更多信息,请参阅《 AWS CLI 命令参考》create-ml-endpoint中的。
- SDK
-
import boto3 from botocore.config import Config client = boto3.client( 'neptunedata', endpoint_url='https://your-neptune-endpoint:port', config=Config(read_timeout=None, retries={'total_max_attempts': 1}) ) response = client.create_ml_endpoint( id='(a unique ID for the new endpoint)', mlModelTrainingJobId='(the model-training job-id of a completed job)' ) print(response) - awscurl
-
awscurl https://your-neptune-endpoint:port/ml/endpoints \ --regionus-east-1\ --service neptune-db \ -X POST \ -H 'Content-Type: application/json' \ -d '{ "id" : "(a unique ID for the new endpoint)", "mlModelTrainingJobId": "(the model-training job-id of a completed job)" }'注意
此示例假设您的 AWS 证书是在您的环境中配置的。
us-east-1替换为 Neptune 集群的区域。 - curl
-
curl \ -X POST https://your-neptune-endpoint:port/ml/endpoints \ -H 'Content-Type: application/json' \ -d '{ "id" : "(a unique ID for the new endpoint)", "mlModelTrainingJobId": "(the model-training job-id of a completed job)" }'
您也可以通过已完成的模型转换任务创建的模型创建推理端点,方法大致相同:
- AWS CLI
-
aws neptunedata create-ml-endpoint \ --endpoint-url https://your-neptune-endpoint:port\ --id "(a unique ID for the new endpoint)" \ --ml-model-transform-job-id "(the model-transform job-id of a completed job)"有关更多信息,请参阅《 AWS CLI 命令参考》create-ml-endpoint中的。
- SDK
-
import boto3 from botocore.config import Config client = boto3.client( 'neptunedata', endpoint_url='https://your-neptune-endpoint:port', config=Config(read_timeout=None, retries={'total_max_attempts': 1}) ) response = client.create_ml_endpoint( id='(a unique ID for the new endpoint)', mlModelTransformJobId='(the model-transform job-id of a completed job)' ) print(response) - awscurl
-
awscurl https://your-neptune-endpoint:port/ml/endpoints \ --regionus-east-1\ --service neptune-db \ -X POST \ -H 'Content-Type: application/json' \ -d '{ "id" : "(a unique ID for the new endpoint)", "mlModelTransformJobId": "(the model-transform job-id of a completed job)" }'注意
此示例假设您的 AWS 证书是在您的环境中配置的。
us-east-1替换为 Neptune 集群的区域。 - curl
-
curl \ -X POST https://your-neptune-endpoint:port/ml/endpoints \ -H 'Content-Type: application/json' \ -d '{ "id" : "(a unique ID for the new endpoint)", "mlModelTransformJobId": "(the model-transform job-id of a completed job)" }'
endpoints 命令中解释了如何使用这些命令的详细信息,以及有关如何获取端点状态、如何删除端点以及如何列出所有推理端点的信息。
自定义模型开发
推理查询