如何检测和编辑个人身份信息 (PII)

PII 功能可以评估非结构化文本,并跨多个预定义类别提取和编修文本中的敏感信息 (PII) 和健康状况信息 (PHI)。

开发选项

若要使用 PII 检测,需在应用程序中提交文本进行分析并处理 API 输出。 分析按原样执行,不会对数据所用的模型进行自定义。 可通过两种方式使用 PII 检测:

开发选项 说明
Language Studio Language Studio 是一个基于 Web 的平台,让你可以在没有 Azure 帐户的情况下尝试使用文本示例进行实体链接,并在注册时使用自己的数据。 有关详细信息,请参阅 Language Studio 网站Language Studio 快速入门
REST API 或客户端库 (Azure SDK) 使用 REST API 或以各种语言提供的客户端库将 PII 检测集成到应用程序中。 有关详细信息,请参阅 PII 检测快速入门

确定如何处理数据(可选)

指定 PII 检测模型

默认情况下,此功能将对文本使用最新的可用 AI 模型。 你还可以将 API 请求配置为使用特定模型版本

输入语言

提交要处理的文档时,可以指定编写这些文档时应采用哪种受支持的语言。如果未指定语言,则提取将默认为英语。 API 可能会在响应中返回偏移量,以支持不同的多语言和表情符号编码

提交数据

在收到请求时执行分析。 同步使用 PII 检测功能是无状态的。 不会在帐户中存储数据,结果会立即在响应中返回。

以异步方式使用此功能时,API 结果在引入请求时的 24 小时内可用,并在响应中指示。 在此时间段后,结果将被清除,并且不再可用于检索。

选择要返回的实体

此 API 会尝试检测给定文档语言的已定义实体类别。 如果要指定将检测并返回哪些实体,请使用可选的 piiCategories 参数指定相应的实体类别。 此参数还可以检测默认情况下未为文档语言启用的实体。 以下示例仅检测 Person。 可以指定一种或多种要返回的实体类型

提示

如果在指定实体类别时不包括 default,则 API 将仅返回指定的实体类别。

输入:

注意

在此示例中,API 将仅返回“人员”实体类型:

https://<your-language-resource-endpoint>/language/:analyze-text?api-version=2022-05-01

{
    "kind": "PiiEntityRecognition",
    "parameters": 
    {
        "modelVersion": "latest",
        "piiCategories" :
        [
            "Person"
        ]
    },
    "analysisInput":
    {
        "documents":
        [
            {
                "id":"1",
                "language": "en",
                "text": "We went to Contoso foodplace located at downtown Seattle last week for a dinner party, and we adore the spot! They provide marvelous food and they have a great menu. The chief cook happens to be the owner (I think his name is John Doe) and he is super nice, coming out of the kitchen and greeted us all. We enjoyed very much dining in the place! The pasta I ordered was tender and juicy, and the place was impeccably clean. You can even pre-order from their online menu at www.contosofoodplace.com, call 112-555-0176 or send email to order@contosofoodplace.com! The only complaint I have is the food didn't come fast enough. Overall I highly recommend it!"
            }
        ]
    }
}

输出:


{
    "kind": "PiiEntityRecognitionResults",
    "results": {
        "documents": [
            {
                "redactedText": "We went to Contoso foodplace located at downtown Seattle last week for a dinner party, and we adore the spot! They provide marvelous food and they have a great menu. The chief cook happens to be the owner (I think his name is ********) and he is super nice, coming out of the kitchen and greeted us all. We enjoyed very much dining in the place! The pasta I ordered was tender and juicy, and the place was impeccably clean. You can even pre-order from their online menu at www.contosofoodplace.com, call 112-555-0176 or send email to order@contosofoodplace.com! The only complaint I have is the food didn't come fast enough. Overall I highly recommend it!",
                "id": "1",
                "entities": [
                    {
                        "text": "John Doe",
                        "category": "Person",
                        "offset": 226,
                        "length": 8,
                        "confidenceScore": 0.98
                    }
                ],
                "warnings": []
            }
        ],
        "errors": [],
        "modelVersion": "2021-01-15"
    }
}

获取 PII 结果

从 PII 检测获得结果时,可以将结果流式传输到应用程序或将输出保存到本地系统上的文件中。 API 响应将包括识别的实体,包括其类别和子类别,以及置信度分数。 PII 实体经过编辑的文本字符串也将被返回。

服务和数据限制

有关每分钟和每秒可以发送的请求大小和数量信息,请参阅服务限制一文。

后续步骤

命名实体识别概述