Azure AI 語言是一項雲端式服務,它將自然語言處理 (NLP) 功能應用於文字型資料。 PII 功能可以在多個預先定義的類別中評估非結構化文字、提取和修訂敏感資訊(PII)及健康資訊(PHI)。
開發選項
若要使用 PII 偵測,您可以提交文字以進行分析,並在您的應用程式中處理 API 輸出。 分析是按原樣執行,對針對您的資料所使用的模型不會進行自訂。 有兩種使用 PII 偵測的方式:
開發選項 | 說明 |
---|---|
Azure AI Foundry | Azure AI Foundry 是一個網頁式平臺,可讓您在註冊時,搭配文字範例使用個人識別資訊偵測。 如需詳細資訊,請參閱 Azure AI Foundry 網站或Azure AI Foundry 檔。 |
REST API 或用戶端程式庫 (Azure SDK) | 使用 REST API 或以各種語言提供的用戶端程式庫,將 PII 偵測整合至您的應用程式。 如需詳細資訊,請參閱 PII 偵測快速入門。 |
指定 PII 偵測模型
根據預設,此功能會使用您文字上最新的可用 AI 模型。 您也可以將 API 要求設定為使用特定的模型版本。
輸入語言
當您提交要處理的輸入文字時,可以指定撰寫文件所使用的支援語言 (部分內容可能是機器或 AI 翻譯)。 如果您未指定語言,則擷取預設為英文。 API 可能會在回應中傳回位移,以支援不同的多語系和表情符號編碼。
修訂原則 (僅限 2024-11-5-preview 版)
在 版本 2024-11-5-preview
中,您可以定義 redactionPolicy
參數,以反映修訂文字時要使用的修訂原則。 原則欄位支援三種原則類型:
DoNotRedact
-
MaskWithCharacter
(預設值) MaskWithEntityType
此 DoNotRedact
原則允許使用者在不包含 redactedText
欄位的情況下返回回應,即“John Doe 從 424-878-9192 收到電話”。
該 MaskWithRedactionCharacter
政策允許 redactedText
使用字元(例如“*”)來遮罩,保留原始文本的長度和偏移量,即“********收到來自************的來電”。 這是現有的行為。
另外還有一個稱為 redactionCharacter
的選擇性欄位,而如果您使用 MaskWithCharacter
原則,則可在其中輸入要用於修訂的字元
此 MaskWithEntityType
原則可讓您使用偵測到的實體類型遮罩偵測到的 PII 實體文字,也就是 “[PERSON_1] 從 [PHONENUMBER_1]] 收到呼叫。
選取要傳回的實體
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": "PiiEntityRecognition",
"parameters": {
"redactionPolicy": {
"policyKind": "MaskWithCharacter"
//MaskWithCharacter|MaskWithEntityType|DoNotRedact
"redactionCharacter": "*"
}
輸出:
{
"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 應用到您的域名
為了調整與適應客戶用來識別實體的自訂詞彙(也稱為「上下文」), entitySynonyms
此功能可讓客戶針對特定實體類型定義自己的同義字。 這項功能的目標是協助在客戶的輸入中偵測模型不熟悉但客戶使用的內容中的實體,並藉由在偵測過程中確保客戶的獨特詞彙能被辨識和正確關聯。
客戶可以透過此選項 valueExclusionPolicy
來調整 PII 服務,以便在某些情況下,即使有些用詞屬於他們感興趣且應偵測的 PII 類別,也不予偵測和遮蔽這些特定字詞。 例如,警察部門可能希望在大部分情況下刪除個人識別符,但「員警」、「嫌疑人」、「證人」等字詞除外。
客戶現在可以透過指定自己的正則表達式(regex),使用辨識組態檔來調整 PII 服務的偵測功能。 如需了解如何安裝和執行個人標識資訊(PII)偵測容器的指南,請參閱我們的容器操作指南。
如需更詳細的教學課程,請參閱將 PII 調整到您的領域指南。
提交資料
分析會在接收要求時執行。 以同步方式使用 PII 偵測功能是無狀態的。 您的帳戶中不會儲存任何資料,且結果會在回應中立即傳回。
以非同步方式使用此功能時,API 結果可從要求擷取的時間起 24 小時內供使用,且會在回應中指出。 在這段時間之後,結果將會予以清除,且無法再供擷取。
取得 PII 結果
當您取得 PII 偵測的結果時,可以將結果串流至應用程式,或將輸出儲存到本機系統上的檔案。 API 回應包含 已辨識的實體,包括其類別和子類別,以及信賴分數。 也會傳回具有 PII 實體修訂的文字字串。
服務和資料限制
如需每分鐘和每秒可傳送的要求大小和數目的相關資訊,請參閱服務限制一文。