

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

# 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 上使用的服务。有关这些服务特定值的详细信息，请参阅本节中的第二个表。


****  

| 参数 | 值类型 | 示例值 | 说明 | 
| --- | --- | --- | --- | 
| awsManagedHumanLoopRequestSource |  字符串  | AWS/Rekognition/DetectModerationLabels/Image/V3 或 AWS/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 资源编号 (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> | 包含 answerContent 中工作人员回应的 JSON 对象的列表。此对象还包含提交详细信息，使用私有人力时，还会包括工作人员元数据。要了解更多信息，请参阅[跟踪工作人员活动](#a2i-worker-id-private)。对于来自 Amazon Rekognition `DetectModerationLabel` 审核任务生成的人工循环输出数据，此参数仅包含正面回应。例如，如果工作人员选择*没有内容*，则不会包括此回应。 | 
| humanLoopName |  字符串  |  `'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 A2 AWS I 集成的服务的原始请求。例如，如果您将 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>  |  与 `ActivationConditions` 中激活条件匹配的 `aiServiceResponse` 的子集。 在推理随机采样时，或者所有推理启动激活条件时，`aiServiceResponse` 中列出的所有数据对象在 `selectedAiServiceResponse` 中列出。  | 
| humanTaskActivationConditionResults |  JSON 对象  |  <pre>{<br />     "Conditions": [...]<br />}</pre>  |  `inputContent` 中的 JSON 对象，其中包含创造人工循环的原因。这包括在人工审核工作流（流定义）中包含的激活条件的列表 (`Conditions`)，以及每个条件的评估结果，此结果为 `true` 或 `false`。要详细了解激活条件，请参阅 [Amazon Augmented AI 中用于人工循环激活条件的 JSON 架构](a2i-human-fallback-conditions-json-schema.md)。  | 

在下表中选择一个选项卡以了解特定于任务类型的参数，并查看每种内置任务类型的示例输出数据代码块。

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

当您使用 Amazon Textract 内置集成时，在输出数据中，您会看到 `awsManagedHumanLoopRequestSource` 的值为 `'AWS/Textract/AnalyzeDocument/Forms/V1'`。

`answerContent` 参数包含 `Block` 对象，其中包括对发送给 Amazon A2I 的所有块的人工回应。

`aiServiceResponse` 参数还包括 `Block` 对象，其中包含 Amazon Textract 对发送到 `AnalyzeDocument` 的原始请求的响应。

要了解您在块对象中看到的参数的详细信息，请参阅《Amazon Textract 开发人员指南》**中的[块](https://docs.aws.amazon.com/textract/latest/dg/API_Block.html)。

以下是对 Amazon Textract 文档分析推理进行 Amazon A2I 人工审核的输出数据示例。

```
{
    "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 内置集成时，在输出数据中，您会看到字符串 `awsManagedHumanLoopRequestSource` 的值为 `'AWS/Rekognition/DetectModerationLabels/Image/V3'`。

`answerContent` 参数包含 `moderationLabels` 对象，其中包含对发送到 Amazon A2I 的所有审核标签的人工回应。

`aiServiceResponse` 参数还包括 `moderationLabels` 对象，其中包含 Amazon Rekognition 对发送到 `DetectModerationLabels` 的原始请求的响应。

要详细了解您在区块对象中看到的参数，请参阅 Amazon Rekognition 开发者指南。[ModerationLabel](https://docs.aws.amazon.com/rekognition/latest/dg/API_ModerationLabel.html)

以下是对 Amazon Rekognition 图像监管推理进行 Amazon A2I 人工审核的输出数据示例。

```
{
    "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 添加到自定义人工审核工作流时，在人工审核任务返回的输出数据中，您将看到以下参数。


****  

| 参数 | 值类型 | 说明 | 
| --- | --- | --- | 
|  `flowDefinitionArn`  |  字符串  |  用于创建人工循环的人工审核工作流（流定义）的 Amazon 资源编号 (ARN)。  | 
|  `humanAnswers`  |  JSON 对象列表  | 包含 answerContent 中工作人员回应的 JSON 对象的列表。此参数中的值由从[工作人员任务模板](https://docs.aws.amazon.com/sagemaker/latest/dg/a2i-instructions-overview.html)收到的输出决定。如果您使用的是私有人力，则包括工作人员元数据。要了解更多信息，请参阅[跟踪工作人员活动](#a2i-worker-id-private)。 | 
|  `humanLoopName`  | 字符串 | 人工循环的名称。 | 
|  `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 关联的工作人员的详细信息（例如姓名或用户名）。要了解如何操作，请参阅[《Amazon Cognito 开发人员指南》](https://docs.aws.amazon.com/cognito/latest/developerguide/)**中的[管理和搜索用户账户](https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-manage-user-accounts.html#manage-user-accounts-searching-user-attributes)。

在您使用 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)。