🚀 格雷特尔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。