🚀 格雷特爾GLiNER:用於PII/PHI檢測的微調模型
格雷特爾GLiNER模型是GLiNER基礎模型knowledgator/gliner-bi-large-v1.0
的微調版本,專門用於檢測個人身份信息(PII)和受保護健康信息(PHI)。它有助於在各個行業和文檔類型中實現符合隱私要求的實體識別。若需瞭解GLiNER基礎模型的更多信息,包括其架構和一般能力,請參考GLiNER模型卡片。
🚀 快速開始
本模型在gretelai/gretel-pii-masking-en-v1
數據集上進行了微調,該數據集提供了豐富多樣的包含PII和PHI實體的合成文檔片段。模型的訓練、驗證和評估過程如下:
- 訓練:使用合成數據集的訓練分割。
- 驗證:使用驗證集監控性能,以調整訓練參數。
- 評估:使用PII/PHI實體註釋作為真實標籤,在測試集上評估最終性能。
如需瞭解數據集的詳細統計信息,包括領域和實體類型分佈,請訪問Hugging Face上的數據集文檔。
✨ 主要特性
所有經過微調的格雷特爾GLiNER模型在準確率、精確率、召回率和F1分數方面都比其基礎模型有顯著提高:
模型 |
準確率 |
精確率 |
召回率 |
F1分數 |
gretelai/gretel-gliner-bi-small-v1.0 |
0.89 |
0.98 |
0.91 |
0.94 |
gretelai/gretel-gliner-bi-base-v1.0 |
0.91 |
0.98 |
0.92 |
0.95 |
gretelai/gretel-gliner-bi-large-v1.0 |
0.91 |
0.99 |
0.93 |
0.95 |
📦 安裝指南
確保你已經安裝了Python,然後安裝或更新gliner
包:
pip install gliner -U
💻 使用示例
基礎用法
使用GLiNER類和from_pretrained
方法加載經過微調的格雷特爾GLiNER模型。以下是一個使用gretelai/gretel-gliner-bi-base-v1.0
模型進行PII/PHI檢測的示例:
from gliner import GLiNER
model = GLiNER.from_pretrained("gretelai/gretel-gliner-bi-large-v1.0")
text = """
Purchase Order
----------------
Date: 10/05/2023
----------------
Customer Name: CID-982305
Billing Address: 1234 Oak Street, Suite 400, Springfield, IL, 62704
Phone: (312) 555-7890 (555-876-5432)
Email: janedoe@company.com
"""
labels = [
"medical_record_number",
"date_of_birth",
"ssn",
"date",
"first_name",
"email",
"last_name",
"customer_id",
"employee_id",
"name",
"street_address",
"phone_number",
"ipv4",
"credit_card_number",
"license_plate",
"address",
"user_name",
"device_identifier",
"bank_routing_number",
"date_time",
"company_name",
"unique_identifier",
"biometric_identifier",
"account_number",
"city",
"certificate_license_number",
"time",
"postcode",
"vehicle_identifier",
"coordinate",
"country",
"api_key",
"ipv6",
"password",
"health_plan_beneficiary_number",
"national_id",
"tax_id",
"url",
"state",
"swift_bic",
"cvv",
"pin"
]
entities = model.predict_entities(text, labels, threshold=0.7)
for entity in entities:
print(f"{entity['text']} => {entity['label']}")
預期輸出:
CID-982305 => customer_id
1234 Oak Street, Suite 400 => street_address
Springfield => city
IL => state
62704 => postcode
(312) 555-7890 => phone_number
555-876-5432 => phone_number
janedoe@company.com => email
📚 詳細文檔
格雷特爾GLiNER非常適合需要檢測和編輯敏感信息的應用場景:
- 醫療保健:自動從醫療記錄中提取和編輯患者信息。
- 金融:識別和保護金融數據,如賬戶號碼和交易細節。
- 網絡安全:檢測日誌和安全報告中的敏感信息。
- 法律:處理合同和法律文件,以保護客戶信息。
- 數據隱私合規:通過準確識別PII/PHI,確保數據處理過程符合GDPR和HIPAA等法規要求。
📄 許可證
本項目採用Apache 2.0許可證。
📖 引用方式
如果您在研究或應用中使用了此數據集,請按以下方式引用:
@dataset{gretel-pii-masking-en-v1,
author = {Gretel AI},
title = {GLiNER Models for PII Detection through Fine-Tuning on Gretel-Generated Synthetic Documents},
year = {2024},
month = {10},
publisher = {Gretel},
howpublished = {https://huggingface.co/gretelai/gretel-pii-masking-en-v1}
}
如有疑問、問題或需要更多信息,請訪問我們的合成數據Discord社區,或聯繫gretel.ai。