-
Notifications
You must be signed in to change notification settings - Fork 25.5k
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
Load Biobert pre-trained weights into Bert model with Pytorch bert hugging face run_classifier.py code #457
Comments
Have you tried the solutions discussed in the other issues on this topic: |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi @thomwolf , I followed the instructions here to convert the checkpoint and then placing the files (pytorch_model.bin, bert_config.json, and vocab.txt) in one folder to compress it. I did not need to ignore any weights as mentioned in any solutions you mentioned above ( #312 or #239 ) I copied the compressed folder to the home folder of 'pytorch-transformers'. Then I ran the following command from there itself to run the example code ( Then, I am trying to run the example code given by running the following command,
But, I get the same error as mentioned in the main discussion:
at this location:
Can you please tell what to change. |
Try to pass the extracted folder of your converted bioBERT model to the Here's a short example:
Then pass the folder name to the from pytorch_transformers import BertModel
model = BertModel.from_pretrained('biobert_v1.1_pubmed') |
How we load a tensor as a pretrained model in bert |
@stefan-it As per new transformers-cli convert --model_type bert \
--tf_checkpoint biobert_v1.1_pubmed/model.ckpt-1000000 \
--config biobert_v1.1_pubmed/bert_config.json \
--pytorch_dump_output biobert_v1.1_pubmed/pytorch_model.bin |
Hello!
My folder (biobert_v1.0_pmc) was originally 5 files: |
Tnank you very much! It did help me! |
Thank you every one, this works fine now! |
Dear all, |
Dear all, |
@stefan-it @nipunsadvilkar Thank you for your solutions. |
These are the steps I followed to get Biobert working with the existing Bert hugging face pytorch code.
I downloaded the pre-trained weights 'biobert_pubmed_pmc.tar.gz' from the Releases page.
I ran this command to convert the tf checkpoint to pytorch model
This created a file 'biobert.model' in the specified path.
As mentioned in this link , I compressed 'biobert.model' created above and 'biobert/pubmed_pmc_470k/bert_config.json' together into a biobert_model.tar.gz
I then ran the run_classifier.py of hugging face bert with the following command, using the tar.gz created above.
I get the error
in the line
Am I doing something wrong?
I just wanted to run run_classifier.py code provided by hugging face with biobert pretrained weights in the same way that we run bert with it. Is there a way to do this?
The text was updated successfully, but these errors were encountered: