NER model in the legal domain in Portuguese according to LGPD (Brazilian Law for Data Protection)
legal-bert-lgpd is a NER model (token classification) in the legal domain in Portuguese that classifies the tokens into the following classes:
Labels |
---|
NOME |
DATA |
ENDERECO |
CEP |
CPF |
TELEFONE |
DINHEIRO |
Usage
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 [email protected], 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."
)
Output
[
{
"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
}
]
Custom Input Usage
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 [email protected].",
],
).launch()
Train Configuration
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
- Downloads last month
- 83
Inference Providers
NEW
This model is not currently available via any of the supported third-party Inference Providers, and
HF Inference API was unable to determine this model's library.
Model tree for celiudos/legal-bert-lgpd
Dataset used to train celiudos/legal-bert-lgpd
Evaluation results
- F1 on carolina-c4ai/corpus-carolinaself-reported0.947
- Precision on carolina-c4ai/corpus-carolinaself-reported0.954
- Recall on carolina-c4ai/corpus-carolinaself-reported0.919
- Accuracy on carolina-c4ai/corpus-carolinaself-reported0.947
- Loss on carolina-c4ai/corpus-carolinaself-reported0.940