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