marquesafonso commited on
Commit
e606528
1 Parent(s): d8260c5

add model and config files

Browse files
Files changed (6) hide show
  1. README.md +82 -0
  2. classes.txt +10 -0
  3. config.json +75 -0
  4. pytorch_model.bin +3 -0
  5. special_tokens_map.json +8 -0
  6. tokenizer_config.json +15 -0
README.md CHANGED
@@ -1,3 +1,85 @@
1
  ---
2
  license: mit
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language:
4
+ - pt
5
  ---
6
+ # bertimbau-large-ner-selective
7
+
8
+ 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.
9
+
10
+ For this model card the we used the <mark style="background-color: #d3d3d3"> **BERT-CRF (total scenario, 10 classes)** </mark> model available in the [ner_evaluation](https://github.com/neuralmind-ai/portuguese-bert/tree/master/ner_evaluation) folder of the original Bertimbau repo.
11
+
12
+ Available classes are:
13
+ + PESSOA
14
+ + ORGANIZACAO
15
+ + LOCAL
16
+ + TEMPO
17
+ + VALOR
18
+ + ABSTRACCAO
19
+ + ACONTECIMENTO
20
+ + COISA
21
+ + OBRA
22
+ + OUTRO
23
+
24
+ ## Usage
25
+
26
+ ```
27
+ # Load model directly
28
+ from transformers import AutoTokenizer, AutoModelForTokenClassification
29
+
30
+ tokenizer = AutoTokenizer.from_pretrained("marquesafonso/bertimbau-large-ner-selective")
31
+ model = AutoModelForTokenClassification.from_pretrained("marquesafonso/bertimbau-large-ner-selective")
32
+
33
+ ```
34
+
35
+ ## Example
36
+
37
+ ```
38
+ from transformers import pipeline
39
+
40
+ pipe = pipeline("ner", model="marquesafonso/bertimbau-large-ner-selective", aggregation_strategy='simple')
41
+
42
+ 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."
43
+
44
+ result = pipe([sentence])
45
+
46
+ print(f"{sentence}\n{result}")
47
+
48
+ # 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.
49
+ # [[
50
+ # {'entity_group': 'PESSOA', 'score': 0.99694395, 'word': 'Ederson', 'start': 9, 'end': 16},
51
+ # {'entity_group': 'PESSOA', 'score': 0.9918462, 'word': 'Rúben Dias', 'start': 28, 'end': 38},
52
+ # {'entity_group': 'ORGANIZACAO', 'score': 0.96376556, 'word': 'Manchester City', 'start': 69, 'end': 84},
53
+ # {'entity_group': 'PESSOA', 'score': 0.9993823, 'word': 'Gonçalo Ramos', 'start': 104, 'end': 117},
54
+ # {'entity_group': 'ORGANIZACAO', 'score': 0.9033079, 'word': 'Benfica', 'start': 157, 'end': 164}
55
+ # ]]
56
+ ```
57
+
58
+ ## Acknowledgements
59
+
60
+ 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):
61
+
62
+ ```
63
+ @InProceedings{souza2020bertimbau,
64
+ author="Souza, F{\'a}bio and Nogueira, Rodrigo and Lotufo, Roberto",
65
+ editor="Cerri, Ricardo and Prati, Ronaldo C.",
66
+ title="BERTimbau: Pretrained BERT Models for Brazilian Portuguese",
67
+ booktitle="Intelligent Systems",
68
+ year="2020",
69
+ publisher="Springer International Publishing",
70
+ address="Cham",
71
+ pages="403--417",
72
+ isbn="978-3-030-61377-8"
73
+ }
74
+
75
+
76
+ @article{souza2019portuguese,
77
+ title={Portuguese Named Entity Recognition using BERT-CRF},
78
+ author={Souza, F{\'a}bio and Nogueira, Rodrigo and Lotufo, Roberto},
79
+ journal={arXiv preprint arXiv:1909.10649},
80
+ url={http://arxiv.org/abs/1909.10649},
81
+ year={2019}
82
+ }
83
+ ```
84
+
85
+ Note that the authors - Fabio Capuano de Souza, Rodrigo Nogueira, Roberto de Alencar Lotufo - have used an MIT LICENSE for their work.
classes.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ PESSOA
2
+ ORGANIZACAO
3
+ LOCAL
4
+ TEMPO
5
+ VALOR
6
+ ABSTRACCAO
7
+ ACONTECIMENTO
8
+ COISA
9
+ OBRA
10
+ OUTRO
config.json ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "neuralmind/bert-large-portuguese-cased",
3
+ "architectures": [
4
+ "BertForTokenClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "directionality": "bidi",
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 768,
11
+ "id2label": {
12
+ "0": "O",
13
+ "1": "B-PESSOA",
14
+ "2": "I-PESSOA",
15
+ "3": "B-ORGANIZACAO",
16
+ "4": "I-ORGANIZACAO",
17
+ "5": "B-LOCAL",
18
+ "6": "I-LOCAL",
19
+ "7": "B-TEMPO",
20
+ "8": "I-TEMPO",
21
+ "9": "B-VALOR",
22
+ "10": "I-VALOR",
23
+ "11": "B-ABSTRACCAO",
24
+ "12": "I-ABSTRACCAO",
25
+ "13": "B-ACONTECIMENTO",
26
+ "14": "I-ACONTECIMENTO",
27
+ "15": "B-COISA",
28
+ "16": "I-COISA",
29
+ "17": "B-OBRA",
30
+ "18": "I-OBRA",
31
+ "19": "B-OUTRO",
32
+ "20": "I-OUTRO"
33
+ },
34
+ "initializer_range": 0.02,
35
+ "intermediate_size": 3072,
36
+ "label2id": {
37
+ "B-LOCAL": 5,
38
+ "B-ORGANIZACAO": 3,
39
+ "B-PESSOA": 1,
40
+ "B-TEMPO": 7,
41
+ "B-VALOR": 9,
42
+ "B-ABSTRACCAO": 11,
43
+ "B-ACONTECIMENTO": 13,
44
+ "B-COISA": 15,
45
+ "B-OBRA": 17,
46
+ "B-OUTRO": 19,
47
+ "I-LOCAL": 6,
48
+ "I-ORGANIZACAO": 4,
49
+ "I-PESSOA": 2,
50
+ "I-TEMPO": 8,
51
+ "I-VALOR": 10,
52
+ "I-ABSTRACCAO": 12,
53
+ "I-ACONTECIMENTO": 14,
54
+ "I-COISA": 16,
55
+ "I-OBRA": 18,
56
+ "I-OUTRO": 20,
57
+ "O": 0
58
+ },
59
+ "layer_norm_eps": 1e-12,
60
+ "max_position_embeddings": 512,
61
+ "model_type": "bert",
62
+ "num_attention_heads": 12,
63
+ "num_hidden_layers": 12,
64
+ "num_labels": 21,
65
+ "output_attentions": false,
66
+ "output_hidden_states": true,
67
+ "pooler_fc_size": 768,
68
+ "pooler_num_attention_heads": 12,
69
+ "pooler_num_fc_layers": 3,
70
+ "pooler_size_per_head": 128,
71
+ "pooler_type": "first_token_transform",
72
+ "torchscript": false,
73
+ "type_vocab_size": 2,
74
+ "vocab_size": 29794
75
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:84e7ada7c449c648d6f92b8efb9f03064dd55a33b146993fb126324e6797bcb8
3
+ size 435807397
special_tokens_map.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
8
+
tokenizer_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "clean_up_tokenization_spaces": true,
3
+ "cls_token": "[CLS]",
4
+ "do_basic_tokenize": true,
5
+ "do_lower_case": false,
6
+ "mask_token": "[MASK]",
7
+ "model_max_length": 1000000000000000019884624838656,
8
+ "never_split": null,
9
+ "pad_token": "[PAD]",
10
+ "sep_token": "[SEP]",
11
+ "strip_accents": null,
12
+ "tokenize_chinese_chars": true,
13
+ "tokenizer_class": "BertTokenizer",
14
+ "unk_token": "[UNK]"
15
+ }