選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

訓練自訂實體識別器 (API)

焦點模式
訓練自訂實體識別器 (API) - Amazon Comprehend

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

若要建立和訓練自訂實體辨識模型,請使用 Amazon Comprehend CreateEntityRecognizer API 操作

使用 訓練自訂實體識別器 AWS Command Line Interface

下列範例示範搭配 使用 CreateEntityRecognizer操作和其他相關聯的 APIs AWS CLI。

這些範例已針對 Unix、Linux 和 macOS 格式化。用於 Windows 時,請以插入號 (^) 取代每一行結尾處的 Unix 接續字元斜線 (\)。

使用 CLI create-entity-recognizer 命令建立自訂實體識別器。如需有關 input-data-config 參數的資訊,請參閱《Amazon Comprehend API 參考》中的 CreateEntityRecognizer

aws comprehend create-entity-recognizer \ --language-code en \ --recognizer-name test-6 \ --data-access-role-arn "arn:aws:iam::account number:role/service-role/AmazonComprehendServiceRole-role" \ --input-data-config "EntityTypes=[{Type=PERSON}],Documents={S3Uri=s3://Bucket Name/Bucket Path/documents}, Annotations={S3Uri=s3://Bucket Name/Bucket Path/annotations}" \ --region region

使用 CLI list-entity-recognizers 命令列出區域中的所有實體識別符。

aws comprehend list-entity-recognizers \ --region region

使用 CLI describe-entity-recognizer 命令檢查自訂實體識別器的任務狀態。

aws comprehend describe-entity-recognizer \ --entity-recognizer-arn arn:aws:comprehend:region:account number:entity-recognizer/test-6 \ --region region

使用 訓練自訂實體識別器 適用於 Java 的 AWS SDK

此範例會使用 Java 建立自訂實體識別器並訓練模型

如需使用 Java 的 Amazon Comprehend 範例,請參閱 Amazon Comprehend Java 範例

使用 Python 訓練自訂實體識別器 (Boto3)

執行個體化 Boto3 開發套件:

import boto3 import uuid comprehend = boto3.client("comprehend", region_name="region")

建立實體識別符:

response = comprehend.create_entity_recognizer( RecognizerName="Recognizer-Name-Goes-Here-{}".format(str(uuid.uuid4())), LanguageCode="en", DataAccessRoleArn="Role ARN", InputDataConfig={ "EntityTypes": [ { "Type": "ENTITY_TYPE" } ], "Documents": { "S3Uri": "s3://Bucket Name/Bucket Path/documents" }, "Annotations": { "S3Uri": "s3://Bucket Name/Bucket Path/annotations" } } ) recognizer_arn = response["EntityRecognizerArn"]

列出所有辨識器:

response = comprehend.list_entity_recognizers()

等待辨識器達到 TRAINED 狀態:

while True: response = comprehend.describe_entity_recognizer( EntityRecognizerArn=recognizer_arn ) status = response["EntityRecognizerProperties"]["Status"] if "IN_ERROR" == status: sys.exit(1) if "TRAINED" == status: break time.sleep(10)
隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。