transformers pytorch bert token-classification generated_from_trainer dataset:louisguitton/dev-ner-ontonotes base_model:google-bert/bert-base-cased base_model:finetune:google-bert/bert-base-cased license:apache-2.0 autotrain_compatible endpoints_compatible region:us
---
base_model: bert-base-cased
datasets:
- louisguitton/dev-ner-ontonotes
library_name: transformers
license: apache-2.0
metrics:
- precision
- recall
- f1
- accuracy
pipeline_tag: token-classification
tags:
- generated_from_trainer
model-index:
- name: dev-ner-ontonote-bert-finetuned
  results: []
---

<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->

# dev-ner-ontonote-bert-finetuned

This model is a fine-tuned version of [bert-base-cased](https://huggingface.co/bert-base-cased) on the [dev-ner-ontone](https://huggingface.co/datasets/louisguitton/dev-ner-ontonotes) dataset.

It achieves the following results on the evaluation set:

- Loss: 0.0241
- Precision: 0.9404
- Recall: 0.9668
- F1: 0.9535
- Accuracy: 0.9937

## Model description

NER Model to identify one or more of the following entities from any given sentence

['CARDINAL', 'DATE', 'EVENT', 'FAC', 'GPE', 'LANGUAGE', 'LAW', 'LOC', 'MONEY', 'NORP', 'ORDINAL', 'ORG', 'PERCENT', 'PERSON', 'PRODUCT', 'QUANTITY', 'TIME', 'WORK_OF_ART']

## Intended uses & limitations

Can be used for named entity recognition for information extraction/retrieval. The limitation of this work is that since it uses BERT as it's pretrained backbone all the limitations and biases there get carried forward in this model.

Also, in the training data, we had only a very small number of examples of a few entities. To be precise this is the distribution of the data

```
{'GPE': 2268, 'PERSON': 2020, 'ORG': 1740, 'DATE': 1507, 'CARDINAL': 938, 'NORP': 847, 'MONEY': 274, 'ORDINAL': 232, 'TIME': 214, 'LOC': 204, 'PERCENT': 177, 'EVENT': 143, 'WORK_OF_ART': 142, 'FAC': 115, 'QUANTITY': 100, 'PRODUCT': 72, 'LAW': 40, 'LANGUAGE': 33}
```

Hence tokenwise, the model will underperform on entities related to language or law etc.

## Training and evaluation data

Here is a snapshot of the dataset stats

```
DatasetDict({
    train: Dataset({
        features: ['text', 'entities', 'entities-suggestion', 'entities-suggestion-metadata', 'external_id', 'metadata'],
        num_rows: 8528
    })
    validation: Dataset({
        features: ['text', 'entities', 'entities-suggestion', 'entities-suggestion-metadata', 'external_id', 'metadata'],
        num_rows: 8528
    })
})
```

For more detailed information, refer [this page](https://huggingface.co/datasets/louisguitton/dev-ner-ontonotes)

## Training procedure

### Training hyperparameters

The following hyperparameters were used during training:
- learning_rate: 2e-05
- train_batch_size: 32
- eval_batch_size: 32
- seed: 42
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 5

### Training results

| Training Loss | Epoch | Step | Validation Loss | Precision | Recall | F1     | Accuracy |
|:-------------:|:-----:|:----:|:---------------:|:---------:|:------:|:------:|:--------:|
| No log        | 1.0   | 267  | 0.1113          | 0.7576    | 0.7973 | 0.7769 | 0.9689   |
| 0.2811        | 2.0   | 534  | 0.0559          | 0.8732    | 0.9087 | 0.8906 | 0.9847   |
| 0.2811        | 3.0   | 801  | 0.0360          | 0.9147    | 0.9478 | 0.9309 | 0.9904   |
| 0.063         | 4.0   | 1068 | 0.0275          | 0.9333    | 0.9600 | 0.9465 | 0.9928   |
| 0.063         | 5.0   | 1335 | 0.0241          | 0.9404    | 0.9668 | 0.9535 | 0.9937   |


### Framework versions

- Transformers 4.27.4
- Pytorch 2.3.1
- Datasets 2.20.0
- Tokenizers 0.13.3
