LOSS is skyrocketing when trying to train a NER classifier with transformers #9090
-
Hello. I'm trying to train a SpaCy NER classifier for Ukrainian language (https://github.com/lang-uk/ner-uk) using https://huggingface.co/youscan/ukr-roberta-base roberta embeddings. I've used config, generated on the SpaCy website
I've tried to increase initial learning rate a bit (from On my first run it seems that model didn't train at all. On the second run it looks anything but promising too. I'm attaching my config below:
|
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 17 replies
-
train_test_data.zip |
Beta Was this translation helpful? Give feedback.
-
P/R/F1 scores of 0 generally suggest an issue with the data rather than a hyperparameter problem. I would suggest trying a CPU model but it looks like we don't have those for Ukranian. What's the output of |
Beta Was this translation helpful? Give feedback.
-
Aha, one obvious thing is that I need to explicitly set path to the file with train and dev data, not a path to the folder that contains both (some models I've used to train worked with directory, autodiscovering the data files) |
Beta Was this translation helpful? Give feedback.
-
I've regenerated data files like that now, dropping -n 10 param: !python -m spacy convert /gdrive/MyDrive/NER_UK/train.txt.iob /tmp
!python -m spacy convert /gdrive/MyDrive/NER_UK/test.txt.iob /tmp and specified correct paths to train/dev. No improvement:
Doesn't look like it converges at all. What do I need to train CPU model? Some kind of vectors? How can I train them myself? |
Beta Was this translation helpful? Give feedback.
-
Hello and thanks for the detailed answers! I've also trained a model using CPU config (and fasttext vectors I had for Ukrainian) and got F1 around 0.8 (which is comparable to the other models like MITIE/Flair/Stanza, but a bit lower). So I assume, my data is okay. Speaking of number of tokens, is it related to the
I'll give it a try as soon as I realize how to change my config for that (any guidance is more than welcome)! |
Beta Was this translation helpful? Give feedback.
-
Those files I've uploaded initially was made with -n 10. Check files below. Thanks for the hint on frozen components, will give it a try |
Beta Was this translation helpful? Give feedback.
-
Close but no cigar:
|
Beta Was this translation helpful? Give feedback.
-
I actually tried all 4 possible combinations. Putting transformers in frozen_components always ending up like this:
|
Beta Was this translation helpful? Give feedback.
-
Just in case, my notebook: And my config: |
Beta Was this translation helpful? Give feedback.
-
I'm glad to let you know that somehow the problem disappeared.
|
Beta Was this translation helpful? Give feedback.
I'm glad to let you know that somehow the problem disappeared.
I ran it today with my old configs using new version of spacy and spacy-transformers and voila: