

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

# Amazon A2I 輸出資料
<a name="a2i-output-data"></a>

當您的機器學習工作流程向 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
```

輸出資料的內容取決於[任務類型](https://docs.aws.amazon.com/sagemaker/latest/dg/a2i-task-types-general.html) (內建或自訂) 以及您使用的[人力資源](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-management.html)類型。您的輸出資料一律包括來自人力工作者的回應。此外，輸出資料可能包括有關人工循環、人工審核者 (工作者) 和資料物件的中繼資料。

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

## 內建任務類型中的輸出資料
<a name="sms-output-data-textract"></a>

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


****  

| 參數 | 值類型 | 範例數值 | Description | 
| --- | --- | --- | --- | 
| awsManagedHumanLoopRequestSource |  String  | AWS/Rekognition/DetectModerationLabels/Image/V3 或 AWS/Textract/AnalyzeDocument/Forms/V1 | 請求 Amazon A2I 建立人工循環的 API 操作和相關 AWS 服務。這是您用來設定 Amazon A2I 人工循環的 API 作業。 | 
| flowDefinitionArn |  String  | arn:aws:sagemaker:us-west-2:111122223333:flow-definition/flow-definition-name |  用於建立人工循環之人工審核工作流程 (流程定義) 的 Amazon Resource Number (ARN)。  | 
| humanAnswers |  JSON 物件清單  | <pre>{<br />"answerContent": {<br />    "AWS/Rekognition/DetectModerationLabels/Image/V3": {<br />        "moderationLabels": [...]<br />    }<br />},</pre> 或<pre>{<br />    "answerContent": {<br />        "AWS/Textract/AnalyzeDocument/Forms/V1": {<br />            "blocks": [...]<br />    }<br />},</pre> | JSON 物件的清單，其包含 answerContent 中的工作者回應。此物件還會包含提交詳細資訊，以及如果使用私有人力資源，則會包含工作者中繼資料。如需詳細資訊，請參閱 [追蹤工作者活動](#a2i-worker-id-private)。對於從 Amazon Rekognition `DetectModerationLabel` 審核任務產生的人工循環輸出資料，此參數僅包含正面回應。例如，如果工作者選取*無內容*，則不會包含此回應。 | 
| humanLoopName |  String  |  `'human-loop-name'`  | 人工循環的名稱。 | 
| inputContent |  JSON 物件  |  <pre>{<br />    "aiServiceRequest": {...},<br />    "aiServiceResponse": {...},<br />    "humanTaskActivationConditionResults": {...},<br />    "selectedAiServiceResponse": {...}<br />}</pre>  |  請求建立人工迴圈時， AWS 服務傳送至 Amazon A2I 的輸入內容。  | 
| aiServiceRequest |  JSON 物件  | <pre>{<br />    "document": {...},<br />    "featureTypes": [...],<br />    "humanLoopConfig": {...}<br />}</pre>或 <pre>{<br />    "image": {...},<br />    "humanLoopConfig": {...}<br />}</pre> |  傳送至與 Amazon A2I 整合之 AWS 服務的原始請求。例如，如果您將 Amazon Rekognition 與 Amazon A2I 搭配使用，這會包括透過 API 作業 `DetectModerationLabels` 提出的請求。對於 Amazon Textract 整合，這包括透過 `AnalyzeDocument` 提出的請求。  | 
| aiServiceResponse |  JSON 物件  |  <pre>{<br />    "moderationLabels": [...],<br />    "moderationModelVersion": "3.0"<br />}</pre> 或 <pre>{<br />    "blocks": [...],<br />    "documentMetadata": {}<br />}</pre>  |   AWS 服務的完整回應。這是用於確定是否需要人工審核的資料。此對象可能包含不與人工審核者共享的有關資料對象的中繼資料。  | 
| selectedAiServiceResponse |  JSON 物件  |  <pre>{<br />    "moderationLabels": [...],<br />    "moderationModelVersion": "3.0"<br />}</pre> 或 <pre>{<br />    "blocks": [...],<br />    "documentMetadata": {}<br />}</pre>  |  `aiServiceResponse` 的子集，其符合在 `ActivationConditions` 中的啟動條件。 當隨機抽樣推論或所有推論皆初始啟動條件時，`aiServiceResponse` 中列出的所有資料物件將會在 `selectedAiServiceResponse` 中列出。  | 
| humanTaskActivationConditionResults |  JSON 物件  |  <pre>{<br />     "Conditions": [...]<br />}</pre>  |  `inputContent` 中的 JSON 物件，其包含建立人工循環的原因。這包括人工審核工作流程 (流程定義) 中包含的啟動條件 (`Conditions`) 的清單，以及每個條件的評估結果 - 此結果為 `true` 或 `false`。要瞭解有關激活條件的詳細資訊，請參閱[Amazon 增強版 AI 中，適用於 JSON 結構描述的人工循環啟動條件](a2i-human-fallback-conditions-json-schema.md)。  | 

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

------
#### [ Amazon Textract Task Type Output Data ]

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

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

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

要瞭解有關區塊物件中看到的參數的詳細資訊，請參閱[區塊](https://docs.aws.amazon.com/textract/latest/dg/API_Block.html)在*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": "amzn-s3-demo-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](https://docs.aws.amazon.com/rekognition/latest/dg/API_ModerationLabel.html)。

以下是 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": "amzn-s3-demo-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"
        }
    }
}
```

------

## 從自訂任務類型輸出資料
<a name="sms-output-data-custom"></a>

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


****  

| 參數 | 值類型 | Description | 
| --- | --- | --- | 
|  `flowDefinitionArn`  |  String  |  用於建立人工循環之人工審核工作流程 (流程定義) 的 Amazon Resource Number (ARN)。  | 
|  `humanAnswers`  |  JSON 物件清單  | JSON 物件的清單，其包含 answerContent 中的工作者回應。此參數中的值由從[工作者任務範本](https://docs.aws.amazon.com/sagemaker/latest/dg/a2i-instructions-overview.html)收到的輸出決定。如果您使用的是私有人力資源，則會包含工作者中繼資料。如需詳細資訊，請參閱 [追蹤工作者活動](#a2i-worker-id-private)。 | 
|  `humanLoopName`  | String | 人工循環的名稱。 | 
|  `inputContent`  |  JSON 物件  |  在對 [https://docs.aws.amazon.com/augmented-ai/2019-11-07/APIReference/API_StartHumanLoop.html](https://docs.aws.amazon.com/augmented-ai/2019-11-07/APIReference/API_StartHumanLoop.html) 的請求中將輸入內容傳送到 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://amzn-s3-demo-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"
    }
}
```

## 追蹤工作者活動
<a name="a2i-worker-id-private"></a>

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` 都是唯一的。
+ 如果您使用[私有人力資源](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-private.html)，則您會在 `workerMetadata` 中看到下列內容。
  + `identityProviderType` 是用來管理私有人力資源的服務。
  + `issuer` 是 Amazon Cognito 使用者集區或 OpenID Connect (OIDC) 身分提供者 (IdP) 發行者，與指派給此人工審核任務的工作團隊相關聯。
  + 獨特的 `sub` 識別符指的是工作者。如果您使用 Amazon Cognito 建立人力資源，則可以使用 Amazon Cognito 擷取與此 ID 相關聯的工作者詳細資料 (例如名稱或使用者名稱)。要瞭解如何操作，請參閱[管理和搜尋用戶帳戶](https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-manage-user-accounts.html#manage-user-accounts-searching-user-attributes)在*[Amazon Cognito 開發人員指南](https://docs.aws.amazon.com/cognito/latest/developerguide/)*。

以下是使用 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"
        }
}
```

想瞭解更多如何使用私有人力資源，請參閱[私有人力資源](sms-workforce-private.md)。