PDF 注释文件 - Amazon Comprehend

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

PDF 注释文件

对于 PDF 批注,您可以使用 SageMaker Ground Truth 在增强的清单文件中创建带标签的数据集。Ground Truth 是一项数据标注服务,可帮助您(或您雇用的人力)为机器学习模型构建训练数据集。Amazon Comprehend 接受增强的清单文件作为自定义模型的训练数据。您可以在使用 Amazon Comprehend 控制台或 API 操作创建自定义实体识别器时提供这些文件。CreateEntityRecognizer

您可以使用 Ground Truth 内置作业类型“命名实体识别”来创建标注作业,让工作人员识别文本中的实体。要了解更多信息,请参阅《Amazon SageMaker 开发者指南》中的命名实体识别。要了解有关 Amazon G SageMaker round Truth 的更多信息,请参阅使用 Amazon G SageMaker round Truth 为数据添加标签

注意

使用 Ground Truth,您可以定义重叠的标签(与多个标签关联的文本)。但是,Amazon Comprehend 实体识别不支持重叠的标签。

增强清单文件采用 JSON 行格式。文件中的每一行都是一个完整的 JSON 对象,其中包含一个训练文档及其关联的标签。以下示例是一个增强的清单文件,用于训练实体识别器来检测文本中提及的个人的职业:

{"source":"Diego Ramirez is an engineer in the high tech industry.","NamedEntityRecognitionDemo":{"annotations":{"entities":[{"endOffset":13,"startOffset":0,"label":"ENGINEER"}],"labels":[{"label":"ENGINEER"}]}},"NamedEntityRecognitionDemo-metadata":{"entities":[{"confidence":0.92}],"job-name":"labeling-job/namedentityrecognitiondemo","type":"groundtruth/text-span","creation-date":"2020-05-14T21:45:27.175903","human-annotated":"yes"}} {"source":"J Doe is a judge on the Washington Supreme Court.","NamedEntityRecognitionDemo":{"annotations":{"entities":[{"endOffset":5,"startOffset":0,"label":"JUDGE"}],"labels":[{"label":"JUDGE"}]}},"NamedEntityRecognitionDemo-metadata":{"entities":[{"confidence":0.72}],"job-name":"labeling-job/namedentityrecognitiondemo","type":"groundtruth/text-span","creation-date":"2020-05-14T21:45:27.174910","human-annotated":"yes"}} {"source":"Our latest new employee, Mateo Jackson, has been a manager in the industry for 4 years.","NamedEntityRecognitionDemo":{"annotations":{"entities":[{"endOffset":38,"startOffset":26,"label":"MANAGER"}],"labels":[{"label":"MANAGER"}]}},"NamedEntityRecognitionDemo-metadata":{"entities":[{"confidence":0.91}],"job-name":"labeling-job/namedentityrecognitiondemo","type":"groundtruth/text-span","creation-date":"2020-05-14T21:45:27.174035","human-annotated":"yes"}}

此 JSON 行文件中的每一行都是一个完整的 JSON 对象,其中的属性包括文档文本、注释和 Ground Truth 中的其他元数据。以下示例是增强清单文件中的单个 JSON 对象,该对象已格式化以提高可读性:

{ "source": "Diego Ramirez is an engineer in the high tech industry.", "NamedEntityRecognitionDemo": { "annotations": { "entities": [ { "endOffset": 13, "startOffset": 0, "label": "ENGINEER" } ], "labels": [ { "label": "ENGINEER" } ] } }, "NamedEntityRecognitionDemo-metadata": { "entities": [ { "confidence": 0.92 } ], "job-name": "labeling-job/namedentityrecognitiondemo", "type": "groundtruth/text-span", "creation-date": "2020-05-14T21:45:27.175903", "human-annotated": "yes" } }

在此示例中,source 属性提供训练文档的文本,NamedEntityRecognitionDemo 属性为文本中的实体提供注释。NamedEntityRecognitionDemo 属性的名称是任意的,在 Ground Truth 中定义标注作业时,您可以提供自己选择的名称。

在此示例中,NamedEntityRecognitionDemo 属性是标签属性名称,它是提供 Ground Truth 工作人员分配给训练数据的标签的属性。当您向 Amazon Comprehend 提供训练数据时,您必须指定一个或多个标签属性名称。您指定的属性名称数量取决于您的增强清单文件是单个标注作业的输出还是链式标注作业的输出。

如果您的文件是单个标注作业的输出,请指定 Ground Truth 中创建作业时使用的单个标签属性名称。

如果您的文件是链式标注作业的输出,请为链中的一个或多个作业指定标签属性名称。每个标签属性名称都提供来自单个作业的注释。您最多可以为链式标注作业生成的增强清单文件指定 5 个此类属性。

在增强的清单文件中,标签属性名称通常紧随 source 键。如果该文件是链式作业的输出,则会有多个标签属性名称。当您向 Amazon Comprehend 提供训练数据时,请仅提供包含与您的模型相关的注释的属性。请勿指定以“-元数据”结尾的属性。

有关链式标签任务的更多信息以及它们产生的输出示例,请参阅《Amazon SageMaker 开发者指南》中的 “链接标签任务”。