BERT-NER icon indicating copy to clipboard operation
BERT-NER copied to clipboard

Key error 0 on evaluation set

Open bollampa opened this issue 4 years ago • 1 comments

Hello,

I built a sample model with only 18 records. The tokenization used was from spacy and the format is BILUO instead of BIO and I only have one class which is Org. I modified the get labels function and also verified the model config json file.

My labels looks like this,

["O", "B-ORG", "I-ORG", "L-ORG", "U-ORG", "[CLS]", "[SEP]"]

The training goes fine, but validation fails with the following error.

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 06/12/2020 14:07:59 - INFO - main - ***** Running evaluation ***** 06/12/2020 14:07:59 - INFO - main - Num examples = 18 06/12/2020 14:07:59 - INFO - main - Batch size = 8 Evaluating: 0%| | 0/3 [00:00<?, ?it/s] Traceback (most recent call last): File "run_ner.py", line 594, in main() File "run_ner.py", line 582, in main temp_2.append(label_map[logits[i][j]]) KeyError: 0

I have attached the train and valid files. Please point me in the right direction.

train.txt valid.txt

bollampa avatar Jun 12 '20 21:06 bollampa

I have the same issue. Have you resolved it?

I think you can treat 0's index as PAD tag/or O tag. And then compute scores exclude PAD/O tag.

heraclex12 avatar Oct 27 '20 17:10 heraclex12