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