philschmid HF staff commited on
Commit
b0a40a0
1 Parent(s): 1324908

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +124 -0
README.md ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ datasets:
4
+ - conll2003
5
+ license: mit
6
+ ---
7
+
8
+ # ONNX convert of bert-base-NER
9
+
10
+ ## Conversion of [bert-base-NER](https://huggingface.co/dslim/bert-base-NER)
11
+
12
+
13
+ ## Model description
14
+
15
+ **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).
16
+
17
+ 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.
18
+
19
+ 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.
20
+
21
+
22
+ ## Intended uses & limitations
23
+
24
+ #### How to use
25
+
26
+ You can use this model with Transformers *pipeline* for NER.
27
+
28
+ ```python
29
+ from transformers import AutoTokenizer, AutoModelForTokenClassification
30
+ from transformers import pipeline
31
+
32
+ tokenizer = AutoTokenizer.from_pretrained("dslim/bert-base-NER")
33
+ model = AutoModelForTokenClassification.from_pretrained("dslim/bert-base-NER")
34
+
35
+ nlp = pipeline("ner", model=model, tokenizer=tokenizer)
36
+ example = "My name is Wolfgang and I live in Berlin"
37
+
38
+ ner_results = nlp(example)
39
+ print(ner_results)
40
+ ```
41
+
42
+ #### Limitations and bias
43
+
44
+ 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.
45
+
46
+ ## Training data
47
+
48
+ 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.
49
+
50
+ 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:
51
+
52
+ Abbreviation|Description
53
+ -|-
54
+ O|Outside of a named entity
55
+ B-MIS |Beginning of a miscellaneous entity right after another miscellaneous entity
56
+ I-MIS | Miscellaneous entity
57
+ B-PER |Beginning of a person’s name right after another person’s name
58
+ I-PER |Person’s name
59
+ B-ORG |Beginning of an organization right after another organization
60
+ I-ORG |organization
61
+ B-LOC |Beginning of a location right after another location
62
+ I-LOC |Location
63
+
64
+
65
+ ### CoNLL-2003 English Dataset Statistics
66
+ 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.
67
+ #### # of training examples per entity type
68
+ Dataset|LOC|MISC|ORG|PER
69
+ -|-|-|-|-
70
+ Train|7140|3438|6321|6600
71
+ Dev|1837|922|1341|1842
72
+ Test|1668|702|1661|1617
73
+ #### # of articles/sentences/tokens per dataset
74
+ Dataset |Articles |Sentences |Tokens
75
+ -|-|-|-
76
+ Train |946 |14,987 |203,621
77
+ Dev |216 |3,466 |51,362
78
+ Test |231 |3,684 |46,435
79
+
80
+ ## Training procedure
81
+
82
+ 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.
83
+
84
+ ## Eval results
85
+ metric|dev|test
86
+ -|-|-
87
+ f1 |95.1 |91.3
88
+ precision |95.0 |90.7
89
+ recall |95.3 |91.9
90
+
91
+ 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).
92
+
93
+ ### BibTeX entry and citation info
94
+
95
+ ```
96
+ @article{DBLP:journals/corr/abs-1810-04805,
97
+ author = {Jacob Devlin and
98
+ Ming{-}Wei Chang and
99
+ Kenton Lee and
100
+ Kristina Toutanova},
101
+ title = {{BERT:} Pre-training of Deep Bidirectional Transformers for Language
102
+ Understanding},
103
+ journal = {CoRR},
104
+ volume = {abs/1810.04805},
105
+ year = {2018},
106
+ url = {http://arxiv.org/abs/1810.04805},
107
+ archivePrefix = {arXiv},
108
+ eprint = {1810.04805},
109
+ timestamp = {Tue, 30 Oct 2018 20:39:56 +0100},
110
+ biburl = {https://dblp.org/rec/journals/corr/abs-1810-04805.bib},
111
+ bibsource = {dblp computer science bibliography, https://dblp.org}
112
+ }
113
+ ```
114
+ ```
115
+ @inproceedings{tjong-kim-sang-de-meulder-2003-introduction,
116
+ title = "Introduction to the {C}o{NLL}-2003 Shared Task: Language-Independent Named Entity Recognition",
117
+ author = "Tjong Kim Sang, Erik F. and
118
+ De Meulder, Fien",
119
+ booktitle = "Proceedings of the Seventh Conference on Natural Language Learning at {HLT}-{NAACL} 2003",
120
+ year = "2003",
121
+ url = "https://www.aclweb.org/anthology/W03-0419",
122
+ pages = "142--147",
123
+ }
124
+ ```