dslim/bert-large-NER
163172k
1---2language: en3datasets:4- conll20035license: mit6model-index:7- name: dslim/bert-large-NER8 results:9 - task:10 type: token-classification11 name: Token Classification12 dataset:13 name: conll200314 type: conll200315 config: conll200316 split: test17 metrics:18 - name: Accuracy19 type: accuracy20 value: 0.903168875372275921 verified: true22 - name: Precision23 type: precision24 value: 0.92002506832860425 verified: true26 - name: Recall27 type: recall28 value: 0.919368867858882529 verified: true30 - name: F131 type: f132 value: 0.919696851044576133 verified: true34 - name: loss35 type: loss36 value: 0.508505046367645337 verified: true38---39# bert-large-NER40 41If 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 description46 47**bert-large-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 49Specifically, this model is a *bert-large-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 51If you'd like to use a smaller BERT model fine-tuned on the same dataset, a [**bert-base-NER**](https://huggingface.co/dslim/bert-base-NER/) version is also available. 52 53 54## Intended uses & limitations55 56#### How to use57 58You can use this model with Transformers *pipeline* for NER.59 60```python61from transformers import AutoTokenizer, AutoModelForTokenClassification62from transformers import pipeline63 64tokenizer = AutoTokenizer.from_pretrained("dslim/bert-large-NER")65model = AutoModelForTokenClassification.from_pretrained("dslim/bert-large-NER")66 67nlp = pipeline("ner", model=model, tokenizer=tokenizer)68example = "My name is Wolfgang and I live in Berlin"69 70ner_results = nlp(example)71print(ner_results)72```73 74#### Limitations and bias75 76This 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. 77 78## Training data79 80This model was fine-tuned on English version of the standard [CoNLL-2003 Named Entity Recognition](https://www.aclweb.org/anthology/W03-0419.pdf) dataset. 81 82The 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:83 84Abbreviation|Description85-|-86O|Outside of a named entity87B-MIS |Beginning of a miscellaneous entity right after another miscellaneous entity88I-MIS | Miscellaneous entity89B-PER |Beginning of a person’s name right after another person’s name90I-PER |Person’s name91B-ORG |Beginning of an organization right after another organization92I-ORG |organization93B-LOC |Beginning of a location right after another location94I-LOC |Location95 96 97### CoNLL-2003 English Dataset Statistics98This 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. 99#### # of training examples per entity type100Dataset|LOC|MISC|ORG|PER101-|-|-|-|-102Train|7140|3438|6321|6600103Dev|1837|922|1341|1842104Test|1668|702|1661|1617105#### # of articles/sentences/tokens per dataset106Dataset |Articles |Sentences |Tokens107-|-|-|-108Train |946 |14,987 |203,621109Dev |216 |3,466 |51,362110Test |231 |3,684 |46,435111 112## Training procedure113 114This 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. 115 116## Eval results117metric|dev|test118-|-|-119f1 |95.7 |91.7120precision |95.3 |91.2121recall |96.1 |92.3122 123The 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).124 125### BibTeX entry and citation info126 127```128@article{DBLP:journals/corr/abs-1810-04805,129 author = {Jacob Devlin and130 Ming{-}Wei Chang and131 Kenton Lee and132 Kristina Toutanova},133 title = {{BERT:} Pre-training of Deep Bidirectional Transformers for Language134 Understanding},135 journal = {CoRR},136 volume = {abs/1810.04805},137 year = {2018},138 url = {http://arxiv.org/abs/1810.04805},139 archivePrefix = {arXiv},140 eprint = {1810.04805},141 timestamp = {Tue, 30 Oct 2018 20:39:56 +0100},142 biburl = {https://dblp.org/rec/journals/corr/abs-1810-04805.bib},143 bibsource = {dblp computer science bibliography, https://dblp.org}144}145```146```147@inproceedings{tjong-kim-sang-de-meulder-2003-introduction,148 title = "Introduction to the {C}o{NLL}-2003 Shared Task: Language-Independent Named Entity Recognition",149 author = "Tjong Kim Sang, Erik F. and150 De Meulder, Fien",151 booktitle = "Proceedings of the Seventh Conference on Natural Language Learning at {HLT}-{NAACL} 2003",152 year = "2003",153 url = "https://www.aclweb.org/anthology/W03-0419",154 pages = "142--147",155}156```157 