🚀 格雷特爾GLiNER:用於PII/PHI檢測的微調模型
格雷特爾GLiNER模型是GLiNER基礎模型knowledgator/gliner-bi-small-v1.0
的微調版本,專門用於檢測個人身份信息(PII)和受保護的健康信息(PHI)。格雷特爾GLiNER有助於在各個行業和文檔類型中提供符合隱私要求的實體識別。
有關基礎GLiNER模型的更多信息,包括其架構和一般功能,請參考GLiNER模型卡片。
該模型在gretelai/gretel-pii-masking-en-v1
數據集上進行了微調,該數據集提供了豐富多樣的包含PII和PHI實體的合成文檔片段。
- 訓練:利用合成數據集的訓練分割進行訓練。
- 驗證:使用驗證集監控性能,以調整訓練參數。
- 評估:使用PII/PHI實體註釋作為真實標籤,在測試集上評估最終性能。
有關數據集的詳細統計信息,包括領域和實體類型分佈,請訪問Hugging Face上的數據集文檔。
🚀 快速開始
本部分將為你介紹格雷特爾GLiNER模型的基本情況,包括其用途、訓練數據以及評估方式等。
✨ 主要特性
- 微調模型:基於GLiNER基礎模型進行微調,專門用於PII和PHI檢測。
- 多行業適用:可在醫療、金融、網絡安全、法律等多個行業提供隱私合規的實體識別。
- 性能提升:在準確率、精確率、召回率和F1分數方面相比基礎模型有顯著提升。
📦 安裝指南
確保你已經安裝了Python,然後安裝或更新gliner
包:
pip install gliner -U
💻 使用示例
基礎用法
from gliner import GLiNER
model = GLiNER.from_pretrained("gretelai/gretel-gliner-bi-small-v1.0")
text = """
採購訂單
----------------
日期: 2023年10月5日
----------------
客戶姓名: CID-982305
賬單地址: 伊利諾伊州斯普林菲爾德市橡樹街1234號400室,郵編62704
電話: (312) 555-7890 (555-876-5432)
郵箱: 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模型在準確率、精確率、召回率和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 |
使用場景
格雷特爾GLiNER非常適合需要檢測和編輯敏感信息的應用場景:
- 醫療保健:自動從醫療記錄中提取和編輯患者信息。
- 金融:識別和保護金融數據,如賬戶號碼和交易細節。
- 網絡安全:檢測日誌和安全報告中的敏感信息。
- 法律:處理合同和法律文件,以保護客戶信息。
- 數據隱私合規:通過準確識別PII/PHI,確保數據處理過程符合GDPR和HIPAA等法規要求。
引用與使用
如果您在研究或應用中使用了此數據集,請按以下方式引用:
@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。
📄 許可證
本項目採用Apache-2.0許可證。