Amazon A2I 輸出資料 - Amazon SageMaker

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

Amazon A2I 輸出資料

當您的機器學習工作流程向 Amazon A2I 發送一個資料對象時,將建立一個人工循環,並且人工審核者會收到任務查看該資料對象。每個人工審核任務的輸出資料儲存在您的人工審核工作流程中指定的 Amazon Simple Storage Service (Amazon S3) 輸出儲存貯體中。在資料的路徑中,YYYY/MM/DD/hh/mm/ss 代表人工循環建立日期,包括年 (YYYY)、月 (MM) 和日 (DD),以及建立時間,包括小時 (hh)、分鐘 (mm) 和秒 (ss)。

s3://customer-output-bucket-specified-in-flow-definition/flow-definition-name/YYYY/MM/DD/hh/mm/ss/human-loop-name/output.json

輸出資料的內容取決於任務類型 (內建或自訂) 以及您使用的人力資源類型。您的輸出資料一律包括來自人力工作者的回應。此外,輸出資料可能包括有關人工循環、人工審核者 (工作者) 和資料物件的中繼資料。

使用下列區段以進一步了解不同任務類型和人力資源的 Amazon A2I 輸出資料格式。

內建任務類型中的輸出資料

Amazon A2I 內建任務類型包括 Amazon Textract 和 Amazon Rekognition。除了人工回應之外,其中一項任務的輸出資料還包括有關人工循環建立原因的詳細資訊,以及用來建立人工循環之整合式服務的相關資訊。使用下表以進一步了解所有內建任務類型的輸出資料結構描述。每個參數的取決於您與 Amazon A2I 搭配使用的服務。有關這些特定於服務的值的詳細資訊,請參閱本節中的第二個表。

參數 值類型 範例數值 描述
awsManagedHumanLoopRequestSource

字串

AWS/Rekognition/DetectModerationLabels/Image/V3AWS/Textract/AnalyzeDocument/Forms/V1 要求 Amazon A2I 建立人工迴圈的 API 作業和相關 AWS 服務。這是您用來設定 Amazon A2I 人工循環的 API 作業。
flowDefinitionArn

字串

arn:aws:sagemaker:us-west-2:111122223333:flow-definition/flow-definition-name

用於建立人工循環之人工審核工作流程 (流程定義) 的 Amazon Resource Number (ARN)。

humanAnswers

JSON 物件清單

{ "answerContent": { "AWS/Rekognition/DetectModerationLabels/Image/V3": { "moderationLabels": [...] } },
{ "answerContent": { "AWS/Textract/AnalyzeDocument/Forms/V1": { "blocks": [...] } },
JSON 物件的清單,其包含 answerContent 中的工作者回應。

此物件還會包含提交詳細資訊,以及如果使用私有人力資源,則會包含工作者中繼資料。如需進一步了解,請參閱追蹤工作者活動

對於從 Amazon Rekognition DetectModerationLabel 審核任務產生的人工循環輸出資料,此參數僅包含正面回應。例如,如果工作者選取無內容,則不會包含此回應。

humanLoopName

字串

'human-loop-name'

人工循環的名稱。
inputContent

JSON 物件

{ "aiServiceRequest": {...}, "aiServiceResponse": {...}, "humanTaskActivationConditionResults": {...}, "selectedAiServiceResponse": {...} }

要求建立人工迴圈時, AWS 服務傳送至 Amazon A2I 的輸入內容。

aiServiceRequest

JSON 物件

{ "document": {...}, "featureTypes": [...], "humanLoopConfig": {...} }
{ "image": {...}, "humanLoopConfig": {...} }

原始請求發送到與 Amazon A2I 集成的 AWS 服務。例如,如果您將 Amazon Rekognition 與 Amazon A2I 搭配使用,這會包括透過 API 作業 DetectModerationLabels 提出的請求。對於 Amazon Textract 整合,這包括透過 AnalyzeDocument 提出的請求。

aiServiceResponse

JSON 物件

{ "moderationLabels": [...], "moderationModelVersion": "3.0" }

{ "blocks": [...], "documentMetadata": {} }

來自 AWS 服務的完整響應。這是用於確定是否需要人工審核的資料。此對象可能包含不與人工審核者共享的有關資料對象的中繼資料。

selectedAiServiceResponse

JSON 物件

{ "moderationLabels": [...], "moderationModelVersion": "3.0" }

{ "blocks": [...], "documentMetadata": {} }

aiServiceResponse 的子集,其符合在 ActivationConditions 中的啟動條件。

當隨機抽樣推論或所有推論皆初始啟動條件時,aiServiceResponse 中列出的所有資料物件將會在 selectedAiServiceResponse 中列出。

humanTaskActivationConditionResults

JSON 物件

{ "Conditions": [...] }

inputContent 中的 JSON 物件,其包含建立人工循環的原因。這包括人工審核工作流程 (流程定義) 中包含的啟動條件 (Conditions) 的清單,以及每個條件的評估結果 - 此結果為 truefalse。要瞭解有關激活條件的詳細資訊,請參閱Amazon Augmented AI 中,適用於 JSON 結構描述的人工循環啟動條件

選取下表中的索引標籤,以了解任務類型特定參數,並查看每個內建任務類型的範例輸出資料程式碼區塊。

Amazon Textract Task Type Output Data

當您使用 Amazon Textract 內建整合時,在輸出資料中,您可以將 'AWS/Textract/AnalyzeDocument/Forms/V1' 視爲 awsManagedHumanLoopRequestSource 的值。

answerContent 參數包含一個 Block 物件,該物件包含傳送至 Amazon A2I 的所有區塊人工回應。

aiServiceResponse 參數還包含一個 Block 物件,該物件包含 Amazon Textract 對使用 AnalyzeDocument 傳送原始請求的回應。

要瞭解有關區塊物件中看到的參數的詳細資訊,請參閱區塊Amazon Textract 開發者指南

以下是 Amazon A2I 人工審核對 Amazon Textract 文件分析推論的輸出資料範例。

{ "awsManagedHumanLoopRequestSource": "AWS/Textract/AnalyzeDocument/Forms/V1", "flowDefinitionArn": "arn:aws:sagemaker:us-west-2:111122223333:flow-definition/flow-definition-name", "humanAnswers": [ { "answerContent": { "AWS/Textract/AnalyzeDocument/Forms/V1": { "blocks": [...] } }, "submissionTime": "2020-09-28T19:17:59.880Z", "workerId": "111122223333", "workerMetadata": { "identityData": { "identityProviderType": "Cognito", "issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_111111", "sub": "c6aa8eb7-9944-42e9-a6b9-111122223333" } } } ], "humanLoopName": "humnan-loop-name", "inputContent": { "aiServiceRequest": { "document": { "s3Object": { "bucket": "DOC-EXAMPLE-BUCKET1", "name": "document-demo.jpg" } }, "featureTypes": [ "TABLES", "FORMS" ], "humanLoopConfig": { "dataAttributes": { "contentClassifiers": [ "FreeOfPersonallyIdentifiableInformation" ] }, "flowDefinitionArn": "arn:aws:sagemaker:us-west-2:111122223333:flow-definition/flow-definition-name", "humanLoopName": "humnan-loop-name" } }, "aiServiceResponse": { "blocks": [...], "documentMetadata": { "pages": 1 } }, "humanTaskActivationConditionResults": { "Conditions": [ { "EvaluationResult": true, "Or": [ { "ConditionParameters": { "ImportantFormKey": "Mail address", "ImportantFormKeyAliases": [ "Mail Address:", "Mail address:", "Mailing Add:", "Mailing Addresses" ], "KeyValueBlockConfidenceLessThan": 100, "WordBlockConfidenceLessThan": 100 }, "ConditionType": "ImportantFormKeyConfidenceCheck", "EvaluationResult": true }, { "ConditionParameters": { "ImportantFormKey": "Mail address", "ImportantFormKeyAliases": [ "Mail Address:", "Mail address:", "Mailing Add:", "Mailing Addresses" ] }, "ConditionType": "MissingImportantFormKey", "EvaluationResult": false } ] } ] }, "selectedAiServiceResponse": { "blocks": [...] } } }
Amazon Rekognition Task Type Output Data

當您使用 Amazon Textract 內建整合時,在輸出資料中,您可以將字串 'AWS/Rekognition/DetectModerationLabels/Image/V3' 視爲 awsManagedHumanLoopRequestSource 的值。

answerContent 參數包含一個 moderationLabels 物件,其中包含傳送至 Amazon A2I 之所有審核標籤的人工回應。

aiServiceResponse參數還包括一個moderationLabels物件,其中包含 Amazon Rekognition 對傳送至DetectModerationLabels的原始請求的回應。

若要進一步了解您在區塊物件中看到的參數,請參閱 Amazon Rekognition 開發人員指南ModerationLabel中的。

以下是 Amazon A2I 人工審核對 Amazon Rekognition 影像內容審核推論的輸出資料範例。

{ "awsManagedHumanLoopRequestSource": "AWS/Rekognition/DetectModerationLabels/Image/V3", "flowDefinitionArn": "arn:aws:sagemaker:us-west-2:111122223333:flow-definition/flow-definition-name", "humanAnswers": [ { "answerContent": { "AWS/Rekognition/DetectModerationLabels/Image/V3": { "moderationLabels": [...] } }, "submissionTime": "2020-09-28T19:22:35.508Z", "workerId": "ef7294f850a3d9d1", "workerMetadata": { "identityData": { "identityProviderType": "Cognito", "issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_111111", "sub": "c6aa8eb7-9944-42e9-a6b9-111122223333" } } } ], "humanLoopName": "humnan-loop-name", "inputContent": { "aiServiceRequest": { "humanLoopConfig": { "flowDefinitionArn": "arn:aws:sagemaker:us-west-2:111122223333:flow-definition/flow-definition-name", "humanLoopName": "humnan-loop-name" }, "image": { "s3Object": { "bucket": "DOC-EXAMPLE-BUCKET1", "name": "example-image.jpg" } } }, "aiServiceResponse": { "moderationLabels": [...], "moderationModelVersion": "3.0" }, "humanTaskActivationConditionResults": { "Conditions": [ { "EvaluationResult": true, "Or": [ { "ConditionParameters": { "ConfidenceLessThan": 98, "ModerationLabelName": "Suggestive" }, "ConditionType": "ModerationLabelConfidenceCheck", "EvaluationResult": true }, { "ConditionParameters": { "ConfidenceGreaterThan": 98, "ModerationLabelName": "Female Swimwear Or Underwear" }, "ConditionType": "ModerationLabelConfidenceCheck", "EvaluationResult": false } ] } ] }, "selectedAiServiceResponse": { "moderationLabels": [ { "confidence": 96.7122802734375, "name": "Suggestive", "parentName": "" } ], "moderationModelVersion": "3.0" } } }

從自訂任務類型輸出資料

將 Amazon A2I 新增至自訂人工審核工作流程時,您會在從人工審核任務傳回的輸出資料中看到以下參數。

參數 值類型 描述

flowDefinitionArn

字串

用於建立人工循環之人工審核工作流程 (流程定義) 的 Amazon Resource Number (ARN)。

humanAnswers

JSON 物件清單

JSON 物件的清單,其包含 answerContent 中的工作者回應。此參數中的值由從工作者任務範本收到的輸出決定。

如果您使用的是私有人力資源,則會包含工作者中繼資料。如需進一步了解,請參閱追蹤工作者活動

humanLoopName

字串 人工循環的名稱。

inputContent

JSON 物件

在對 StartHumanLoop 的請求中將輸入內容傳送到 Amazon A2I。

以下是從與 Amazon A2I 和 Amazon Transcribe 的自訂整合輸出資料的範例。在此範例中,inputContent 由下列項目組成:

  • Amazon S3 中的 .mp4 檔案路徑和影片標題

  • 從 Amazon Transcribe 傳回的轉錄 (從 Amazon Transcribe 輸出資料剖析)

  • 工作者任務範本用來剪輯 .mp4 檔案,並向工作者顯示影片相關部分的開始和結束時間

{ "flowDefinitionArn": "arn:aws:sagemaker:us-west-2:111122223333:flow-definition/flow-definition-name", "humanAnswers": [ { "answerContent": { "transcription": "use lambda to turn your notebook" }, "submissionTime": "2020-06-18T17:08:26.246Z", "workerId": "ef7294f850a3d9d1", "workerMetadata": { "identityData": { "identityProviderType": "Cognito", "issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_111111", "sub": "c6aa8eb7-9944-42e9-a6b9-111122223333" } } } ], "humanLoopName": "human-loop-name", "inputContent": { "audioPath": "s3://DOC-EXAMPLE-BUCKET1/a2i_transcribe_demo/Fully-Managed Notebook Instances with Amazon SageMaker - a Deep Dive.mp4", "end_time": 950.27, "original_words": "but definitely use Lambda to turn your ", "start_time": 948.51, "video_title": "Fully-Managed Notebook Instances with Amazon SageMaker - a Deep Dive.mp4" } }

追蹤工作者活動

Amazon A2I 提供的資訊可讓您用來追蹤任務輸出資料中的個別工作者。若要識別處理人工審核任務的工作者,請使用 Amazon S3 的輸出資料中的以下內容:

  • acceptanceTime 是工作者接受任務的時間。此日期和時間戳記的格式為 YYYY-MM-DDTHH:MM:SS.mmmZ,分別是年份 (YYYY)、月份 (MM)、日期 (DD)、小時 (HH)、分鐘 (MM)、秒 (SS) 和毫秒 (mmm)。日期和時間使用T分隔。

  • submissionTime 是工作者使用提交按鈕提交其註釋的時間。此日期和時間戳記的格式為 YYYY-MM-DDTHH:MM:SS.mmmZ,分別是年份 (YYYY)、月份 (MM)、日期 (DD)、小時 (HH)、分鐘 (MM)、秒 (SS) 和毫秒 (mmm)。日期和時間使用T分隔。

  • timeSpentInSeconds 會報告工作者主動處理該任務的總時間 (以秒為單位)。此指標不包含工作者暫停或休息的時間。

  • 每個工作者的 workerId 都是唯一的。

  • 如果您使用私有人力資源,則您會在 workerMetadata 中看到下列內容。

    • identityProviderType 是用來管理私有人力資源的服務。

    • issuer 是 Amazon Cognito 使用者集區或 OpenID Connect (OIDC) 身分提供者 (IdP) 發行者,與指派給此人工審核任務的工作團隊相關聯。

    • 獨特的 sub 識別符指的是工作者。如果您使用 Amazon Cognito 建立人力資源,則可以使用 Amazon Cognito 擷取與此 ID 相關聯的工作者詳細資料 (例如名稱或使用者名稱)。要瞭解如何操作,請參閱管理和搜尋用戶帳戶Amazon Cognito 開發人員指南

以下是使用 Amazon Cognito 建立私有人力資源時可能會看到的輸出範例。這些會在 identityProviderType 中予以識別。

"submissionTime": "2020-12-28T18:59:58.321Z", "acceptanceTime": "2020-12-28T18:59:15.191Z", "timeSpentInSeconds": 40.543, "workerId": "a12b3cdefg4h5i67", "workerMetadata": { "identityData": { "identityProviderType": "Cognito", "issuer": "https://cognito-idp.aws-region.amazonaws.com/aws-region_123456789", "sub": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } }

以下是使用您的自有 OIDC IdP 建立私有人力資源時可能會看到的輸出範例:

"workerMetadata": { "identityData": { "identityProviderType": "Oidc", "issuer": "https://example-oidc-ipd.com/adfs", "sub": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } }

想瞭解更多如何使用私有人力資源,請參閱使用私有人力