🚀 法律领域葡萄牙语命名实体识别(NER)模型
本项目的legal-bert-lgpd
是一款应用于法律领域的葡萄牙语命名实体识别(NER)模型,它能够将文本中的标记分类到以下类别中,在遵循巴西数据保护法(LGPD)的前提下,为法律文本处理提供了有效的支持。
🚀 快速开始
模型基本信息
属性 |
详情 |
基础模型 |
pierreguillou/ner-bert-large-cased-pt-lenerbr |
数据集 |
carolina-c4ai/corpus-carolina |
语言 |
葡萄牙语 |
评估指标 |
精确率、召回率、F1值、准确率 |
标签 |
由训练器生成、法律相关 |
模型评估结果
任务类型 |
数据集 |
F1值 |
精确率 |
召回率 |
准确率 |
损失值 |
标记分类 |
carolina-c4ai/corpus-carolina |
0.9470445768148197 |
0.9544794827813696 |
0.9191397849462366 |
0.9470445768148197 |
0.939724603793193 |
✨ 主要特性
该模型能够对法律文本中的多种实体进行分类,具体分类标签如下:
标签 |
姓名(NOME) |
日期(DATA) |
地址(ENDERECO) |
邮政编码(CEP) |
个人身份号码(CPF) |
电话号码(TELEFONE) |
电子邮件(EMAIL) |
金额(DINHEIRO) |
💻 使用示例
基础用法
import torch
from transformers import pipeline, AutoTokenizer
MODEL_NAME = "celiudos/legal-bert-lgpd"
tokenizer = AutoTokenizer.from_pretrained(
MODEL_NAME,
model_max_length=512,
)
pipe = pipeline(
"ner",
tokenizer=tokenizer,
model=MODEL_NAME,
stride=100,
aggregation_strategy="first",
device=0 if torch.cuda.is_available() else -1,
)
pipe(
"Anotação de Responsabilidade Técnica Nº 1055330634101 de 12 de janeiro de 2013 relativa à Lei Federal Nº 531. Trata-se de representação referente a possível falsificação documentação técnica registrada pelo CREA-SP, feita pelo senhor Francis Pantele da Cozzi, CPF: 412.612.341-32, telefone (31) 951358433, email fran@bol.com, atinente à sua contratação pela senhora Marinalva Bete Raz, CPF: 049.567.041-22, telefone (61) 9412 3333, mulher branca, opinião política conservadora, religião evangélica. Marinalva Bete Raz reclama por indenização por danos morais no dia 14.05.2013 no valor de R$ 82.662,00 (Oitenta e dois mil, seiscentos e sessenta e dois reais) relacionado ao endereço IP 192.168.01 e ao endereço constante no CEP 59123-222, Rua dos Pioneiros, nº 450, Jardim Esmeralda, Campo Grande, MS."
)
输出示例
[
{
"entity_group": "DATA",
"score": 0.9828296,
"word": "12 de janeiro de 2013",
"start": 57,
"end": 78
},
{
"entity_group": "NOME",
"score": 0.95766664,
"word": "Francis Pantele da Cozzi",
"start": 234,
"end": 258
},
{
"entity_group": "CPF",
"score": 0.9954297,
"word": "412. 612. 341 - 32",
"start": 265,
"end": 279
},
{
"entity_group": "TELEFONE",
"score": 0.5634508,
"word": "31 )",
"start": 291,
"end": 294
},
{
"entity_group": "EMAIL",
"score": 0.9973985,
"word": "fran @ bol. com",
"start": 312,
"end": 324
},
{
"entity_group": "NOME",
"score": 0.96683884,
"word": "Marinalva Bete Raz",
"start": 366,
"end": 384
},
{
"entity_group": "CPF",
"score": 0.99713326,
"word": "049. 567. 041 - 22",
"start": 391,
"end": 405
},
{
"entity_group": "TELEFONE",
"score": 0.90854883,
"word": "( 61 ) 9412 3333",
"start": 416,
"end": 430
},
{
"entity_group": "NOME",
"score": 0.9364093,
"word": "Marinalva Bete Raz",
"start": 499,
"end": 517
},
{
"entity_group": "DATA",
"score": 0.9986375,
"word": "14",
"start": 566,
"end": 568
},
{
"entity_group": "DATA",
"score": 0.9968226,
"word": "05",
"start": 569,
"end": 571
},
{
"entity_group": "DATA",
"score": 0.9992943,
"word": "2013",
"start": 572,
"end": 576
},
{
"entity_group": "DINHEIRO",
"score": 0.99847966,
"word": "R $ 82. 662, 00",
"start": 589,
"end": 601
},
{
"entity_group": "CEP",
"score": 0.9977593,
"word": "59123 - 222",
"start": 728,
"end": 737
},
{
"entity_group": "ENDERECO",
"score": 0.9711078,
"word": "Rua dos Pioneiros",
"start": 739,
"end": 756
},
{
"entity_group": "ENDERECO",
"score": 0.9741938,
"word": "Jardim Esmeralda",
"start": 766,
"end": 782
},
{
"entity_group": "ENDERECO",
"score": 0.9352198,
"word": "Campo Grande, MS",
"start": 784,
"end": 800
}
]
高级用法
import gradio as gr
def ner(text):
return {"text": text, "entities": pipe(text)}
gr.Interface(
ner,
gr.Textbox(placeholder="Enter sentence here..."),
gr.HighlightedText(),
live=True,
examples=[
"Anotação de Responsabilidade Técnica Nº 1055330634101 de 12 de janeiro de 2013 relativa à Lei Federal Nº 531. Trata-se de representação referente a possível falsificação documentação técnica registrada pelo CREA-SP, feita pelo senhor Francis Pantele da Cozzi, CPF: 412.612.341-32, telefone (31) 951358433, email fran@bol.com.",
],
).launch()
🔧 技术细节
训练配置
Num examples = 3,971
Num Epochs = 5
Instantaneous batch size per device = 16
Total train batch size (w. parallel, distributed & accumulation) = 16
Gradient Accumulation steps = 1
Total optimization steps = 1,245
Number of trainable parameters = 333,364,241