File size: 2,891 Bytes
a38dba2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f09891
826f2fa
34d5be3
a38dba2
 
 
 
 
 
 
 
 
 
 
 
 
9f09891
a38dba2
826f2fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a38dba2
 
34d5be3
 
a38dba2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
library_name: transformers
license: apache-2.0
base_model: bert-base-uncased
tags:
- generated_from_trainer
model-index:
- name: bert-finetuned-ner
  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. -->

# bert-finetuned-ner

This model is a fine-tuned version of [bert-base-uncased](https://huggingface.co/bert-base-uncased) on the None dataset.
It achieves the following results on the evaluation set:
- Loss: 0.2481
- Model Preparation Time: 0.0021

```ipython
                   precision    recall  f1-score   support

   B-COMMENT       0.88      0.90      0.89       767
      B-NAME       0.91      0.91      0.91      1050
       B-QTY       0.99      0.99      0.99       836
 B-RANGE_END       0.93      1.00      0.96        13
      B-UNIT       0.99      0.99      0.99       706
   I-COMMENT       0.93      0.96      0.95      1499
      I-NAME       0.92      0.84      0.88       572
       OTHER       0.88      0.82      0.85       439

    accuracy                           0.93      5882
   macro avg       0.93      0.93      0.93      5882
weighted avg       0.93      0.93      0.93      5882
```

## Usage

```ipython
In [40]: from transformers import pipeline

In [41]: 

In [41]: classifier = pipeline("token-classification", "AXKuhta/bert-finetuned-ner")
Loading weights: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 199/199 [00:00<00:00, 9724.08it/s]

In [42]: classifier.tokenizer.tokenize("mozzarella")
Out[42]: ['mozzarella']

In [43]: classifier("1 pound broccoli", aggregation_strategy="simple")
Out[43]: 
[{'entity_group': 'QTY',
  'score': np.float32(0.9997178),
  'word': '1',
  'start': 0,
  'end': 1},
 {'entity_group': 'UNIT',
  'score': np.float32(0.99991345),
  'word': 'pound',
  'start': 2,
  'end': 7},
 {'entity_group': 'NAME',
  'score': np.float32(0.999385),
  'word': 'broccoli',
  'start': 8,
  'end': 16}]
```

## Training procedure

See  bert_finetune_fin.ipynb

### Training hyperparameters

The following hyperparameters were used during training:
- learning_rate: 4e-05
- train_batch_size: 16
- eval_batch_size: 16
- seed: 42
- optimizer: Use OptimizerNames.ADAMW_TORCH_FUSED with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
- lr_scheduler_type: linear
- num_epochs: 6


### Framework versions

- Transformers 5.6.2
- Pytorch 2.11.0+cu126
- Datasets 3.6.0
- Tokenizers 0.22.2