Commit
·
633b758
1
Parent(s):
bf48981
Update README.md
Browse files
README.md
CHANGED
|
@@ -33,3 +33,62 @@ for text in abstract_dict.values():
|
|
| 33 |
ab_ids, ab_dis, ab_locs, ab_epis, ab_stats = extract_abs.abstract_extraction(sample, NER_pipeline, GARD_dict, max_length)
|
| 34 |
print('\n',sample, '\n',ab_ids, ab_dis, ab_locs, ab_epis, ab_stats)
|
| 35 |
~~~
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
ab_ids, ab_dis, ab_locs, ab_epis, ab_stats = extract_abs.abstract_extraction(sample, NER_pipeline, GARD_dict, max_length)
|
| 34 |
print('\n',sample, '\n',ab_ids, ab_dis, ab_locs, ab_epis, ab_stats)
|
| 35 |
~~~
|
| 36 |
+
|
| 37 |
+
# PENDING DOCUMENTATION:
|
| 38 |
+
# bert-base-NER
|
| 39 |
+
## Model description
|
| 40 |
+
**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).
|
| 41 |
+
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.
|
| 42 |
+
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.
|
| 43 |
+
## Intended uses & limitations
|
| 44 |
+
#### How to use
|
| 45 |
+
You can use this model with Transformers *pipeline* for NER.
|
| 46 |
+
```python
|
| 47 |
+
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
| 48 |
+
from transformers import pipeline
|
| 49 |
+
tokenizer = AutoTokenizer.from_pretrained("dslim/bert-base-NER")
|
| 50 |
+
model = AutoModelForTokenClassification.from_pretrained("dslim/bert-base-NER")
|
| 51 |
+
nlp = pipeline("ner", model=model, tokenizer=tokenizer)
|
| 52 |
+
example = "My name is Wolfgang and I live in Berlin"
|
| 53 |
+
ner_results = nlp(example)
|
| 54 |
+
print(ner_results)
|
| 55 |
+
```
|
| 56 |
+
#### Limitations and bias
|
| 57 |
+
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.
|
| 58 |
+
## Training data
|
| 59 |
+
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.
|
| 60 |
+
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:
|
| 61 |
+
Abbreviation|Description
|
| 62 |
+
-|-
|
| 63 |
+
O|Outside of a named entity
|
| 64 |
+
B-MIS |Beginning of a miscellaneous entity right after another miscellaneous entity
|
| 65 |
+
I-MIS | Miscellaneous entity
|
| 66 |
+
B-PER |Beginning of a person’s name right after another person’s name
|
| 67 |
+
I-PER |Person’s name
|
| 68 |
+
B-ORG |Beginning of an organization right after another organization
|
| 69 |
+
I-ORG |organization
|
| 70 |
+
B-LOC |Beginning of a location right after another location
|
| 71 |
+
I-LOC |Location
|
| 72 |
+
### CoNLL-2003 English Dataset Statistics
|
| 73 |
+
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.
|
| 74 |
+
#### # of training examples per entity type
|
| 75 |
+
Dataset|LOC|MISC|ORG|PER
|
| 76 |
+
-|-|-|-|-
|
| 77 |
+
Train|7140|3438|6321|6600
|
| 78 |
+
Dev|1837|922|1341|1842
|
| 79 |
+
Test|1668|702|1661|1617
|
| 80 |
+
#### # of articles/sentences/tokens per dataset
|
| 81 |
+
Dataset |Articles |Sentences |Tokens
|
| 82 |
+
-|-|-|-
|
| 83 |
+
Train |946 |14,987 |203,621
|
| 84 |
+
Dev |216 |3,466 |51,362
|
| 85 |
+
Test |231 |3,684 |46,435
|
| 86 |
+
## Training procedure
|
| 87 |
+
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.
|
| 88 |
+
## Eval results
|
| 89 |
+
metric|dev|test
|
| 90 |
+
-|-|-
|
| 91 |
+
f1 |95.1 |91.3
|
| 92 |
+
precision |95.0 |90.7
|
| 93 |
+
recall |95.3 |91.9
|
| 94 |
+
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).
|