-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot find the NER Model #10
Comments
I am trying to replicate your NER results with hugginface take your base model as pre-trained and using BertForTokenClassification then train the model for NER but it is not converging. Can you elaborate me on that? |
Hi @kemalaraz , yes, there are no fine-tuned models stored on the model hub at the moment, only the ones with a normal lm head. For fine-tuning I used FARM, with corresponding configuration files in the Could you just paste the fine-tuning command that you've used with the |
Hello again @stefan-it ,
The code above didnt converge I stuck at 0.020... loss and 0.40 around for f1 score..
I can go with the FARM also but when I executed that code above for farm the f1 score is %55. What am I missing here :) |
Sorry to bother you this much but I also tried with different datasets still no luck.. |
Hi @kemalaraz , I'm currently working on an evaluation for the WikiANN (balanced) dataset, so you could use this dataset as well to test the implementation: Dataset can be retrieved from here and the dataset needs to be pre-processed, e.g. with:
Just use It's important that the final dataset format is:
There's a token/label pair for each line, delimited by a space. An empty line denotes a space. Just make sure, that the dataset format is ok. The 55% depends on the dataset, e.g. when your dataset is not balanced, or very noise (like the WNUT NER datasets) this would explain the bad result. However, you should try to train on |
Thank you so much for your interest, I ll try your suggestions and get back to you. Btw I got 55% with the dataset that you wrote on another issue which you said you plan to evaluate the model for ner with https://github.com/UKPLab/linspector/tree/master/extrinsic this dataset. I used the same set and parsed it one word and token at a time however got bad results. In addition to that the dataset should be like Büyük B-ORG however when preparing the input for the bert it should be "This is a sentence" and output " 'O' ,'O' ..." right? |
I am sorry but that dataset didnt work as well. I hope you put your trained model for NER to this repo otherwise it seems impossible to replicate your results. Thanks |
Hi @kemalaraz, could you try to reproduce the NER results with the following commands: Download WikiANN dataJust clone the latest version of Transformers install it via mkdir tr-data
cd tr-data
for file in train.txt dev.txt test.txt labels.txt
do
wget https://schweter.eu/storage/turkish-bert-wikiann/$file
done
cd .. It will download the pre-processed datasets with training, dev and test splits and put them in a Run pre-trainingAfter downloading the dataset, pre-training can be started. Just set the following environment variables: export MAX_LENGTH=128
export BERT_MODEL=dbmdz/bert-base-turkish-cased
export OUTPUT_DIR=tr-model
export BATCH_SIZE=32
export NUM_EPOCHS=3
export SAVE_STEPS=625
export SEED=1 Then run pre-training: python3 run_ner.py --data_dir ./tr-data \
--model_type bert \
--labels ./tr-data/labels.txt \
--model_name_or_path $BERT_MODEL \
--output_dir $OUTPUT_DIR-$SEED \
--max_seq_length $MAX_LENGTH \
--num_train_epochs $NUM_EPOCHS \
--per_gpu_train_batch_size $BATCH_SIZE \
--save_steps $SAVE_STEPS \
--seed $SEED \
--do_train \
--do_eval \
--do_predict \
--fp16 This will fine-tune the Turkish BERT model for 3 epochs. Results should be around: cat tr-model-1/eval_results.txt
cat tr-model-1/test_results.txt In my experiment I got 92.60% on the development set and 92.19% on the test set. I hope I can upload fine-tuned models this week. |
I applied the same experiment with Stefan to reproduce the same resulta. However, I got errror |
Works like a charm, cheers bud, however I still wonder with which dataset you used to get 95% on NER task? |
With my experiments, I got the similar results with @stefan-it as follows Eval Results: precision = 0.916400580551524 Test Results: |
When I load the trained model with:
and test it on another dataset I am getting really bad results. I can give you more information if you want or share the model and stuff with you. Can you please help me on that? |
Could you post an example sentence or more sentences from your dataset, so that I can test it 🤔 |
I trained and uploaded fine-tuned model to the transformers repo as savasy/bert-base-turkish-ner-cased please check the following code
output looks like this |
I got the dataset from https://github.com/UKPLab/linspector/blob/master/extrinsic/data/ner/tr/test.txt and getting bad results. @savasy thank you for your interest and for the example :) I trained the model there is no problem with that I am trying the model with various datasets that are unseen to the model and not getting good results but I will double check everything again when I have time. But again thank you :) |
The NER dataset in the linspector repo was automatically annotated - just found the paper: https://arxiv.org/abs/1702.02363 When looking at the test set, I could find some tagging errors: Tirol X B-X B-LOCATION
ve X B-X O
Vorarlberg'i X B-X O
Avusturya X B-X B-LOCATION
İmparatorluğu'na X B-X O
bırakan X B-X O
Bavyera X B-X B-LOCATION
, X B-X O
Aschaffenburg X B-X B-MISC
ile X B-X O
Hessen X B-X B-LOCATION
Darmstadt'ın X B-X O
bir X B-X O
kısmını X B-X O
elde X B-X O
etti X B-X O
. X B-X O So e.g. "Aschaffenburg" is clearly a location, "Darmstadt" and "Vorarlberg" as well. @savasy Thanks for uploading the model 👍 I just used it to tag the sentence, and "Aschaffenburg", "Darmstadt" and "Vorarlberg" are tagged as locations. |
You are welcome @stefan-it @kemalaraz |
You can get that from this link however I haven't tried the model on that dataset I ma working on a different project right now, will write a parser for enamex format and then try that.nerdata.txt |
Thank you, it is fairly enough data I will give it a try |
The performance for the data given by @kemalaraz is as follows
|
Hi @kemalaraz and @stefan-it is it from the paper below ? |
Hi @savasy , I checked that dataset and it should be idential to the one that I've used for the NER experiments :) |
It seems huggingface repository contains only the base model, I couldn't find the model and tokenizer related to the model for named entity recognition. Where can I find the trained NER model and if it is not too much to ask how can I load and use it easily?
The text was updated successfully, but these errors were encountered: