Skip to content
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

Luke NER Fine Tuning on Custom Entities. #113

Open
ahmadaii opened this issue Mar 5, 2022 · 12 comments
Open

Luke NER Fine Tuning on Custom Entities. #113

ahmadaii opened this issue Mar 5, 2022 · 12 comments

Comments

@ahmadaii
Copy link

ahmadaii commented Mar 5, 2022

Hi, I am trying to fine tune luke base model and prepared conll like dataset with two columns (one for tokens and other for labels). The training runs smoothly but asserts no entity label when trying to make predictions.
Can I really know what changes in the code are supposed to be making luke ner solution useful for custom ner with different number of classes.

@elonmusk-01
Copy link

Screenshot from 2022-03-05 01-41-43

@elonmusk-01
Copy link

That's how my dataset looks like;
Screenshot from 2022-03-06 21-20-16

@elonmusk-01
Copy link

I have made one change in the code according to my entity numbers:
Screenshot from 2022-03-04 12-38-31

@elonmusk-01
Copy link

So can I get what I have to do additionally? Is my dataset structure CORRECT?

@ikuyamada
Copy link
Member

ikuyamada commented Mar 9, 2022

Hi @ahmadaii,
If I correctly remember, the assertion (assert not entity_labels) aims to confirm that all gold entity spans in the dataset are detected after preprocessing (i.e., sentence and subword tokenization). entity_labels should be empty if all gold entity spans are detected.
Also, there is another implementation of our NER model based on AllenNLP, which may be easier to work with.

@elonmusk-01
Copy link

Alright. Is there any separate script for converting luke ner model to transformers or I have to use same script provided for converting re model??

@ikuyamada
Copy link
Member

Actually, LUKE was added to the Transformers library after the experiments conducted in our paper. Therefore, the examples available in this repository do not support the Transformers library.

@elonmusk-01
Copy link

@ikuyamada I am referring to this script that was provided to convert luke re model to be used in transformers. Now I have fine tuned luke large model for NER task on my custom data. Is there any similar script for ner?

@binhna
Copy link

binhna commented Mar 18, 2022

@elonmusk-01 Check out this script, although you need to modify few things to make it work

@NiteshMethani
Copy link

@binhna Were you able to run that script on custom dataset?
I tried but I am getting this error:
TypeError: forward() got an unexpected keyword argument 'ner_tags'

Any idea on how to fix it?

@binhna
Copy link

binhna commented Sep 7, 2022

@NiteshMethani I managed to get it running, but not this script though. You could try this one, but you still need to edit some code to get it running.
The result in my language is quite bad though 😕

@NiteshMethani
Copy link

@binhna Thanks for sharing the script. I too was able to run it but with no luck. My performance even on conll2003 is:
{'precision': 0.8916275430359938, 'recall': 0.4036486007793128, 'f1': 0.5557181175323092, 'accuracy': 0.8966561566544972}

These were my hyperparameters for training:
python run_luke_ner_no_trainer.py
--model_name_or_path studio-ousia/luke-base
--dataset_name conll2003
--task_name $TASK_NAME
--max_length 128
--per_device_train_batch_size 32
--learning_rate 2e-5
--num_train_epochs 3
--output_dir /tmp/$TASK_NAME/

I wonder what's the reason for such poor F1 score on conll.
Would appreciate any suggestions @Ryou0634 @binhna @ikuyamada

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants