如何偵測和修訂個人識別資訊 (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 只會傳回您指定的實體類別。

輸入:

注意

在此範例中,其只會傳回人員實體類型:

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 實體修訂的文字字串。

服務和資料限制

如需每分鐘和每秒可傳送的要求大小和數目的相關資訊,請參閱服務限制一文。

下一步

具名實體辨識概觀