Skip to content

Commit 536aee9

Browse files
authored
Move the TF NER example (huggingface#10276)
1 parent cbadb52 commit 536aee9

File tree

3 files changed

+65
-65
lines changed

3 files changed

+65
-65
lines changed

examples/legacy/token-classification/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,71 @@ On the test dataset the following results could be achieved:
129129
10/04/2019 00:42:42 - INFO - __main__ - recall = 0.8624150210424085
130130
```
131131

132+
#### Run the Tensorflow 2 version
133+
134+
To start training, just run:
135+
136+
```bash
137+
python3 run_tf_ner.py --data_dir ./ \
138+
--labels ./labels.txt \
139+
--model_name_or_path $BERT_MODEL \
140+
--output_dir $OUTPUT_DIR \
141+
--max_seq_length $MAX_LENGTH \
142+
--num_train_epochs $NUM_EPOCHS \
143+
--per_device_train_batch_size $BATCH_SIZE \
144+
--save_steps $SAVE_STEPS \
145+
--seed $SEED \
146+
--do_train \
147+
--do_eval \
148+
--do_predict
149+
```
150+
151+
Such as the Pytorch version, if your GPU supports half-precision training, just add the `--fp16` flag. After training, the model will be both evaluated on development and test datasets.
152+
153+
#### Evaluation
154+
155+
Evaluation on development dataset outputs the following for our example:
156+
```bash
157+
precision recall f1-score support
158+
159+
LOCderiv 0.7619 0.6154 0.6809 52
160+
PERpart 0.8724 0.8997 0.8858 4057
161+
OTHpart 0.9360 0.9466 0.9413 711
162+
ORGpart 0.7015 0.6989 0.7002 269
163+
LOCpart 0.7668 0.8488 0.8057 496
164+
LOC 0.8745 0.9191 0.8963 235
165+
ORGderiv 0.7723 0.8571 0.8125 91
166+
OTHderiv 0.4800 0.6667 0.5581 18
167+
OTH 0.5789 0.6875 0.6286 16
168+
PERderiv 0.5385 0.3889 0.4516 18
169+
PER 0.5000 0.5000 0.5000 2
170+
ORG 0.0000 0.0000 0.0000 3
171+
172+
micro avg 0.8574 0.8862 0.8715 5968
173+
macro avg 0.8575 0.8862 0.8713 5968
174+
```
175+
176+
On the test dataset the following results could be achieved:
177+
```bash
178+
precision recall f1-score support
179+
180+
PERpart 0.8847 0.8944 0.8896 9397
181+
OTHpart 0.9376 0.9353 0.9365 1639
182+
ORGpart 0.7307 0.7044 0.7173 697
183+
LOC 0.9133 0.9394 0.9262 561
184+
LOCpart 0.8058 0.8157 0.8107 1150
185+
ORG 0.0000 0.0000 0.0000 8
186+
OTHderiv 0.5882 0.4762 0.5263 42
187+
PERderiv 0.6571 0.5227 0.5823 44
188+
OTH 0.4906 0.6667 0.5652 39
189+
ORGderiv 0.7016 0.7791 0.7383 172
190+
LOCderiv 0.8256 0.6514 0.7282 109
191+
PER 0.0000 0.0000 0.0000 11
192+
193+
micro avg 0.8722 0.8774 0.8748 13869
194+
macro avg 0.8712 0.8774 0.8740 13869
195+
```
196+
132197
### Emerging and Rare Entities task: WNUT’17 (English NER) dataset
133198

134199
Description of the WNUT’17 task from the [shared task website](http://noisy-text.github.io/2017/index.html):

examples/token-classification/README.md

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -119,68 +119,3 @@ export NUM_EPOCHS=3
119119
export SAVE_STEPS=750
120120
export SEED=1
121121
```
122-
123-
#### Run the Tensorflow 2 version
124-
125-
To start training, just run:
126-
127-
```bash
128-
python3 run_tf_ner.py --data_dir ./ \
129-
--labels ./labels.txt \
130-
--model_name_or_path $BERT_MODEL \
131-
--output_dir $OUTPUT_DIR \
132-
--max_seq_length $MAX_LENGTH \
133-
--num_train_epochs $NUM_EPOCHS \
134-
--per_device_train_batch_size $BATCH_SIZE \
135-
--save_steps $SAVE_STEPS \
136-
--seed $SEED \
137-
--do_train \
138-
--do_eval \
139-
--do_predict
140-
```
141-
142-
Such as the Pytorch version, if your GPU supports half-precision training, just add the `--fp16` flag. After training, the model will be both evaluated on development and test datasets.
143-
144-
#### Evaluation
145-
146-
Evaluation on development dataset outputs the following for our example:
147-
```bash
148-
precision recall f1-score support
149-
150-
LOCderiv 0.7619 0.6154 0.6809 52
151-
PERpart 0.8724 0.8997 0.8858 4057
152-
OTHpart 0.9360 0.9466 0.9413 711
153-
ORGpart 0.7015 0.6989 0.7002 269
154-
LOCpart 0.7668 0.8488 0.8057 496
155-
LOC 0.8745 0.9191 0.8963 235
156-
ORGderiv 0.7723 0.8571 0.8125 91
157-
OTHderiv 0.4800 0.6667 0.5581 18
158-
OTH 0.5789 0.6875 0.6286 16
159-
PERderiv 0.5385 0.3889 0.4516 18
160-
PER 0.5000 0.5000 0.5000 2
161-
ORG 0.0000 0.0000 0.0000 3
162-
163-
micro avg 0.8574 0.8862 0.8715 5968
164-
macro avg 0.8575 0.8862 0.8713 5968
165-
```
166-
167-
On the test dataset the following results could be achieved:
168-
```bash
169-
precision recall f1-score support
170-
171-
PERpart 0.8847 0.8944 0.8896 9397
172-
OTHpart 0.9376 0.9353 0.9365 1639
173-
ORGpart 0.7307 0.7044 0.7173 697
174-
LOC 0.9133 0.9394 0.9262 561
175-
LOCpart 0.8058 0.8157 0.8107 1150
176-
ORG 0.0000 0.0000 0.0000 8
177-
OTHderiv 0.5882 0.4762 0.5263 42
178-
PERderiv 0.6571 0.5227 0.5823 44
179-
OTH 0.4906 0.6667 0.5652 39
180-
ORGderiv 0.7016 0.7791 0.7383 172
181-
LOCderiv 0.8256 0.6514 0.7282 109
182-
PER 0.0000 0.0000 0.0000 11
183-
184-
micro avg 0.8722 0.8774 0.8748 13869
185-
macro avg 0.8712 0.8774 0.8740 13869
186-
```

0 commit comments

Comments
 (0)