🚀 格雷特尔GLiNER:用于PII/PHI检测的微调模型
格雷特尔GLiNER 模型是GLiNER基础模型 knowledgator/gliner-bi-base-v1.0
的微调版本,专门用于检测个人身份信息(PII)和受保护的健康信息(PHI)。格雷特尔GLiNER有助于在各个行业和文档类型中提供符合隐私要求的实体识别。
有关基础GLiNER模型的更多信息,包括其架构和一般功能,请参考 GLiNER模型卡片。
该模型在 gretelai/gretel-pii-masking-en-v1
数据集上进行了微调,该数据集提供了丰富多样的包含PII和PHI实体的合成文档片段。
- 训练:使用合成数据集的训练分割。
- 验证:使用验证集监控性能,以调整训练参数。
- 评估:使用PII/PHI实体注释作为真实标签,在测试集上评估最终性能。
有关数据集的详细统计信息,包括领域和实体类型分布,请访问 Hugging Face上的数据集文档。
🚀 快速开始
✨ 主要特性
- 基于GLiNER基础模型微调,专为PII和PHI检测设计。
- 有助于各行业和文档类型的隐私合规实体识别。
- 在准确性、精确性、召回率和F1分数方面相比基础模型有显著提升。
📦 安装指南
确保你已经安装了Python,然后安装或更新 gliner
包:
pip install gliner -U
💻 使用示例
基础用法
from gliner import GLiNER
model = GLiNER.from_pretrained("gretelai/gretel-gliner-bi-base-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模型在准确性、精确性、召回率和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等法规。
📄 许可证
本项目采用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。