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

Use fine tuned model #142

Closed
seyyedjavadrazavi opened this issue Nov 17, 2022 · 6 comments
Closed

Use fine tuned model #142

seyyedjavadrazavi opened this issue Nov 17, 2022 · 6 comments

Comments

@seyyedjavadrazavi
Copy link

seyyedjavadrazavi commented Nov 17, 2022

I fine-tuned the bert model on my pc, then used the bert-score -r comments.txt -c all_tags.txt --model my_model --num_layers 9 code to use the fine-tuned model on bert score, but this error happened.

image

@Tiiiger
Copy link
Owner

Tiiiger commented Nov 17, 2022

hi @seyyedjavadrazavi ,

This is saying you didn't give it the correct path to the model folder. Please check you can load your model correctly by

from transformers import AutoModel

AutoModel.from_pretrained("<your model>")

@seyyedjavadrazavi
Copy link
Author

seyyedjavadrazavi commented Nov 18, 2022

Thanks for the quick reply.
I am new to this field and to fine-tune the bert used #61, #12, and #82 and finally because I want to fine-tune the bert in an unsupervised way, I used this link for fine-tuning and torch.save(model, 'C:/Users/Seyyed Javad Razavi/Desktop/New folder (2)/f_tune_analyticsvidhya/model_2') code to save the fine-tuned model which saved just a file with the name 'model_2' without any config file.
Now the problem is the code you mentioned is not work for me and this error happened.

image

@Tiiiger
Copy link
Owner

Tiiiger commented Nov 18, 2022

Hi @seyyedjavadrazavi ,

you should use the huggingface save_pretrained method for this

@seyyedjavadrazavi
Copy link
Author

seyyedjavadrazavi commented Nov 18, 2022

Thanks, @Tiiiger.
I did that and load the fine-tuned model by model = AutoModel.from_pretrained("./new_model/model/", from_tf=True) and used the score function P, R, F1 = score(crnt_tg, tags_name, model_type = model, num_layers = 10, device="cuda:0"), but the error was :

image

@felixgwu
Copy link
Collaborator

Hi @seyyedjavadrazavi ,

The argument model_type should be a string, please try this:

P, R, F1 = score(crnt_tg, tags_name, model_type = "./new_model/model/", num_layers = 10, device="cuda:0")

@seyyedjavadrazavi
Copy link
Author

@felixgwu
Thanks a lot.
It works now.

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

3 participants