File size: 2,891 Bytes
2f84858
 
2800b54
 
2f84858
264e9ec
 
8eaf58c
 
 
 
 
 
dd61a25
8eaf58c
 
 
 
 
 
 
 
 
 
dd61a25
8eaf58c
 
b7c43aa
8eaf58c
 
 
 
 
 
 
 
b7c43aa
 
 
 
 
 
 
8eaf58c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
license: mit
language:
- pt
---
# bertimbau-large-ner

This model card aims to simplify the use of the [portuguese Bert, a.k.a, Bertimbau](https://github.com/neuralmind-ai/portuguese-bert) for the Named Entity Recognition task. 

For this model card the we used the BERT-CRF (selective scenario, 5 classes) model available in the [ner_evalutaion](https://github.com/neuralmind-ai/portuguese-bert/tree/master/ner_evaluation) folder of the original Bertimbau repo.

## Usage

```
# Load model directly
from transformers import AutoTokenizer, AutoModelForTokenClassification

tokenizer = AutoTokenizer.from_pretrained("marquesafonso/bertimbau-large-ner")
model = AutoModelForTokenClassification.from_pretrained("marquesafonso/bertimbau-large-ner")

```

## Example

```
from transformers import pipeline

pipe = pipeline("ner", model="marquesafonso/bertimbau-large-ner", aggregation_strategy='simple')

sentence = "Acima de Ederson, abaixo de Rúben Dias. É entre os dois jogadores do Manchester City que se vai colocar Gonçalo Ramos no ranking de vendas mais avultadas do Benfica."

result = pipe([sentence])

print(f"{sentence}\n{result}")

# Acima de Ederson, abaixo de Rúben Dias. É entre os dois jogadores do Manchester City que se vai colocar Gonçalo Ramos no ranking de vendas mais avultadas do Benfica.
# [[
#     {'entity_group': 'PESSOA', 'score': 0.99694395, 'word': 'Ederson', 'start': 9, 'end': 16},
#     {'entity_group': 'PESSOA', 'score': 0.9918462, 'word': 'Rúben Dias', 'start': 28, 'end': 38},
#     {'entity_group': 'ORGANIZACAO', 'score': 0.96376556, 'word': 'Manchester City', 'start': 69, 'end': 84},
#     {'entity_group': 'PESSOA', 'score': 0.9993823, 'word': 'Gonçalo Ramos', 'start': 104, 'end': 117},
#     {'entity_group': 'ORGANIZACAO', 'score': 0.9033079, 'word': 'Benfica', 'start': 157, 'end': 164}
# ]]
```

## Acknowledgements

This work is an adaptation of [portuguese Bert, a.k.a, Bertimbau](https://github.com/neuralmind-ai/portuguese-bert). You may check and/or cite their [work](http://arxiv.org/abs/1909.10649):

```
@InProceedings{souza2020bertimbau,
    author="Souza, F{\'a}bio and Nogueira, Rodrigo and Lotufo, Roberto",
    editor="Cerri, Ricardo and Prati, Ronaldo C.",
    title="BERTimbau: Pretrained BERT Models for Brazilian Portuguese",
    booktitle="Intelligent Systems",
    year="2020",
    publisher="Springer International Publishing",
    address="Cham",
    pages="403--417",
    isbn="978-3-030-61377-8"
}


@article{souza2019portuguese,
    title={Portuguese Named Entity Recognition using BERT-CRF},
    author={Souza, F{\'a}bio and Nogueira, Rodrigo and Lotufo, Roberto},
    journal={arXiv preprint arXiv:1909.10649},
    url={http://arxiv.org/abs/1909.10649},
    year={2019}
}
```

Note that the authors - Fabio Capuano de Souza, Rodrigo Nogueira, Roberto de Alencar Lotufo - have used an MIT LICENSE for their work.