chamemaru dslim commited on
Commit
6222864
·
0 Parent(s):

Duplicate from dslim/bert-base-NER

Browse files

Co-authored-by: David S. Lim <dslim@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
2
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.h5 filter=lfs diff=lfs merge=lfs -text
5
+ *.tflite filter=lfs diff=lfs merge=lfs -text
6
+ *.tar.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.ot filter=lfs diff=lfs merge=lfs -text
8
+ *.onnx filter=lfs diff=lfs merge=lfs -text
9
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
10
+ model.safetensors filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ datasets:
4
+ - conll2003
5
+ license: mit
6
+ model-index:
7
+ - name: dslim/bert-base-NER
8
+ results:
9
+ - task:
10
+ type: token-classification
11
+ name: Token Classification
12
+ dataset:
13
+ name: conll2003
14
+ type: conll2003
15
+ config: conll2003
16
+ split: test
17
+ metrics:
18
+ - name: Accuracy
19
+ type: accuracy
20
+ value: 0.9118041001560013
21
+ verified: true
22
+ - name: Precision
23
+ type: precision
24
+ value: 0.9211550382257732
25
+ verified: true
26
+ - name: Recall
27
+ type: recall
28
+ value: 0.9306415698281261
29
+ verified: true
30
+ - name: F1
31
+ type: f1
32
+ value: 0.9258740048459675
33
+ verified: true
34
+ - name: loss
35
+ type: loss
36
+ value: 0.48325642943382263
37
+ verified: true
38
+ ---
39
+ # bert-base-NER
40
+
41
+ If my open source models have been useful to you, please consider supporting me in building small, useful AI models for everyone (and help me afford med school / help out my parents financially). Thanks!
42
+
43
+ <a href="https://www.buymeacoffee.com/dslim" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/arial-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
44
+
45
+ ## Model description
46
+
47
+ **bert-base-NER** is a fine-tuned BERT model that is ready to use for **Named Entity Recognition** and achieves **state-of-the-art performance** for the NER task. It has been trained to recognize four types of entities: location (LOC), organizations (ORG), person (PER) and Miscellaneous (MISC).
48
+
49
+ Specifically, this model is a *bert-base-cased* model that was fine-tuned on the English version of the standard [CoNLL-2003 Named Entity Recognition](https://www.aclweb.org/anthology/W03-0419.pdf) dataset.
50
+
51
+ If you'd like to use a larger BERT-large model fine-tuned on the same dataset, a [**bert-large-NER**](https://huggingface.co/dslim/bert-large-NER/) version is also available.
52
+
53
+ ### Available NER models
54
+ | Model Name | Description | Parameters |
55
+ |-------------------|-------------|------------------|
56
+ | [distilbert-NER](https://huggingface.co/dslim/distilbert-NER) **(NEW!)** | Fine-tuned DistilBERT - a smaller, faster, lighter version of BERT | 66M |
57
+ | [bert-large-NER](https://huggingface.co/dslim/bert-large-NER/) | Fine-tuned bert-large-cased - larger model with slightly better performance | 340M |
58
+ | [bert-base-NER](https://huggingface.co/dslim/bert-base-NER)-([uncased](https://huggingface.co/dslim/bert-base-NER-uncased)) | Fine-tuned bert-base, available in both cased and uncased versions | 110M |
59
+
60
+
61
+ ## Intended uses & limitations
62
+
63
+ #### How to use
64
+
65
+ You can use this model with Transformers *pipeline* for NER.
66
+
67
+ ```python
68
+ from transformers import AutoTokenizer, AutoModelForTokenClassification
69
+ from transformers import pipeline
70
+
71
+ tokenizer = AutoTokenizer.from_pretrained("dslim/bert-base-NER")
72
+ model = AutoModelForTokenClassification.from_pretrained("dslim/bert-base-NER")
73
+
74
+ nlp = pipeline("ner", model=model, tokenizer=tokenizer)
75
+ example = "My name is Wolfgang and I live in Berlin"
76
+
77
+ ner_results = nlp(example)
78
+ print(ner_results)
79
+ ```
80
+
81
+ #### Limitations and bias
82
+
83
+ This model is limited by its training dataset of entity-annotated news articles from a specific span of time. This may not generalize well for all use cases in different domains. Furthermore, the model occassionally tags subword tokens as entities and post-processing of results may be necessary to handle those cases.
84
+
85
+ ## Training data
86
+
87
+ This model was fine-tuned on English version of the standard [CoNLL-2003 Named Entity Recognition](https://www.aclweb.org/anthology/W03-0419.pdf) dataset.
88
+
89
+ The training dataset distinguishes between the beginning and continuation of an entity so that if there are back-to-back entities of the same type, the model can output where the second entity begins. As in the dataset, each token will be classified as one of the following classes:
90
+
91
+ Abbreviation|Description
92
+ -|-
93
+ O|Outside of a named entity
94
+ B-MISC |Beginning of a miscellaneous entity right after another miscellaneous entity
95
+ I-MISC | Miscellaneous entity
96
+ B-PER |Beginning of a person’s name right after another person’s name
97
+ I-PER |Person’s name
98
+ B-ORG |Beginning of an organization right after another organization
99
+ I-ORG |organization
100
+ B-LOC |Beginning of a location right after another location
101
+ I-LOC |Location
102
+
103
+
104
+ ### CoNLL-2003 English Dataset Statistics
105
+ This dataset was derived from the Reuters corpus which consists of Reuters news stories. You can read more about how this dataset was created in the CoNLL-2003 paper.
106
+ #### # of training examples per entity type
107
+ Dataset|LOC|MISC|ORG|PER
108
+ -|-|-|-|-
109
+ Train|7140|3438|6321|6600
110
+ Dev|1837|922|1341|1842
111
+ Test|1668|702|1661|1617
112
+ #### # of articles/sentences/tokens per dataset
113
+ Dataset |Articles |Sentences |Tokens
114
+ -|-|-|-
115
+ Train |946 |14,987 |203,621
116
+ Dev |216 |3,466 |51,362
117
+ Test |231 |3,684 |46,435
118
+
119
+ ## Training procedure
120
+
121
+ This model was trained on a single NVIDIA V100 GPU with recommended hyperparameters from the [original BERT paper](https://arxiv.org/pdf/1810.04805) which trained & evaluated the model on CoNLL-2003 NER task.
122
+
123
+ ## Eval results
124
+ metric|dev|test
125
+ -|-|-
126
+ f1 |95.1 |91.3
127
+ precision |95.0 |90.7
128
+ recall |95.3 |91.9
129
+
130
+ The test metrics are a little lower than the official Google BERT results which encoded document context & experimented with CRF. More on replicating the original results [here](https://github.com/google-research/bert/issues/223).
131
+
132
+ ### BibTeX entry and citation info
133
+
134
+ ```
135
+ @article{DBLP:journals/corr/abs-1810-04805,
136
+ author = {Jacob Devlin and
137
+ Ming{-}Wei Chang and
138
+ Kenton Lee and
139
+ Kristina Toutanova},
140
+ title = {{BERT:} Pre-training of Deep Bidirectional Transformers for Language
141
+ Understanding},
142
+ journal = {CoRR},
143
+ volume = {abs/1810.04805},
144
+ year = {2018},
145
+ url = {http://arxiv.org/abs/1810.04805},
146
+ archivePrefix = {arXiv},
147
+ eprint = {1810.04805},
148
+ timestamp = {Tue, 30 Oct 2018 20:39:56 +0100},
149
+ biburl = {https://dblp.org/rec/journals/corr/abs-1810-04805.bib},
150
+ bibsource = {dblp computer science bibliography, https://dblp.org}
151
+ }
152
+ ```
153
+ ```
154
+ @inproceedings{tjong-kim-sang-de-meulder-2003-introduction,
155
+ title = "Introduction to the {C}o{NLL}-2003 Shared Task: Language-Independent Named Entity Recognition",
156
+ author = "Tjong Kim Sang, Erik F. and
157
+ De Meulder, Fien",
158
+ booktitle = "Proceedings of the Seventh Conference on Natural Language Learning at {HLT}-{NAACL} 2003",
159
+ year = "2003",
160
+ url = "https://www.aclweb.org/anthology/W03-0419",
161
+ pages = "142--147",
162
+ }
163
+ ```
added_tokens.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {}
config.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_num_labels": 9,
3
+ "architectures": [
4
+ "BertForTokenClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "hidden_act": "gelu",
8
+ "hidden_dropout_prob": 0.1,
9
+ "hidden_size": 768,
10
+ "id2label": {
11
+ "0": "O",
12
+ "1": "B-MISC",
13
+ "2": "I-MISC",
14
+ "3": "B-PER",
15
+ "4": "I-PER",
16
+ "5": "B-ORG",
17
+ "6": "I-ORG",
18
+ "7": "B-LOC",
19
+ "8": "I-LOC"
20
+ },
21
+ "initializer_range": 0.02,
22
+ "intermediate_size": 3072,
23
+ "label2id": {
24
+ "B-LOC": 7,
25
+ "B-MISC": 1,
26
+ "B-ORG": 5,
27
+ "B-PER": 3,
28
+ "I-LOC": 8,
29
+ "I-MISC": 2,
30
+ "I-ORG": 6,
31
+ "I-PER": 4,
32
+ "O": 0
33
+ },
34
+ "layer_norm_eps": 1e-12,
35
+ "max_position_embeddings": 512,
36
+ "model_type": "bert",
37
+ "num_attention_heads": 12,
38
+ "num_hidden_layers": 12,
39
+ "output_past": true,
40
+ "pad_token_id": 0,
41
+ "type_vocab_size": 2,
42
+ "vocab_size": 28996
43
+ }
flax_model.msgpack ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a124466eab9adb43377d35d32afe77313fceeb16b74b106f3742884c666a2c1e
3
+ size 430913546
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b04492186cfb45a64908487a17a9f8d6ddec3a403ef39db5bca688f0fa702a34
3
+ size 433292294
onnx/added_tokens.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "[CLS]": 101,
3
+ "[MASK]": 103,
4
+ "[PAD]": 0,
5
+ "[SEP]": 102,
6
+ "[UNK]": 100
7
+ }
onnx/config.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "dslim/bert-base-NER",
3
+ "_num_labels": 9,
4
+ "architectures": [
5
+ "BertForTokenClassification"
6
+ ],
7
+ "attention_probs_dropout_prob": 0.1,
8
+ "classifier_dropout": null,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 768,
12
+ "id2label": {
13
+ "0": "O",
14
+ "1": "B-MISC",
15
+ "2": "I-MISC",
16
+ "3": "B-PER",
17
+ "4": "I-PER",
18
+ "5": "B-ORG",
19
+ "6": "I-ORG",
20
+ "7": "B-LOC",
21
+ "8": "I-LOC"
22
+ },
23
+ "initializer_range": 0.02,
24
+ "intermediate_size": 3072,
25
+ "label2id": {
26
+ "B-LOC": 7,
27
+ "B-MISC": 1,
28
+ "B-ORG": 5,
29
+ "B-PER": 3,
30
+ "I-LOC": 8,
31
+ "I-MISC": 2,
32
+ "I-ORG": 6,
33
+ "I-PER": 4,
34
+ "O": 0
35
+ },
36
+ "layer_norm_eps": 1e-12,
37
+ "max_position_embeddings": 512,
38
+ "model_type": "bert",
39
+ "num_attention_heads": 12,
40
+ "num_hidden_layers": 12,
41
+ "output_past": true,
42
+ "pad_token_id": 0,
43
+ "position_embedding_type": "absolute",
44
+ "transformers_version": "4.34.0",
45
+ "type_vocab_size": 2,
46
+ "use_cache": true,
47
+ "vocab_size": 28996
48
+ }
onnx/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:963039b81eec5b33e23d84826ccdf1e8f8ada776f320e692113034cfae384617
3
+ size 431172619
onnx/special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
onnx/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
onnx/tokenizer_config.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "additional_special_tokens": [],
45
+ "clean_up_tokenization_spaces": true,
46
+ "cls_token": "[CLS]",
47
+ "do_basic_tokenize": true,
48
+ "do_lower_case": false,
49
+ "mask_token": "[MASK]",
50
+ "max_len": 512,
51
+ "model_max_length": 512,
52
+ "never_split": null,
53
+ "pad_token": "[PAD]",
54
+ "sep_token": "[SEP]",
55
+ "strip_accents": null,
56
+ "tokenize_chinese_chars": true,
57
+ "tokenizer_class": "BertTokenizer",
58
+ "unk_token": "[UNK]"
59
+ }
onnx/vocab.txt ADDED
The diff for this file is too large to render. See raw diff
 
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4c0b01790e435da1337ea519d76e747427f2d3ee9c0e49b4952caa06298021f6
3
+ size 433316646
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
tf_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba8245e6eefa4057300e93caef9d8360192914c271f15c8bd112283d357a954b
3
+ size 433538860
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"do_lower_case": false, "max_len": 512, "init_inputs": []}
vocab.txt ADDED
The diff for this file is too large to render. See raw diff