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

Huggingface support for Tensorflow? #96

Open
jacklxc opened this issue Jul 7, 2020 · 8 comments
Open

Huggingface support for Tensorflow? #96

jacklxc opened this issue Jul 7, 2020 · 8 comments

Comments

@jacklxc
Copy link

jacklxc commented Jul 7, 2020

It seems that SciBERT only supports Huggingface with PyTorch backend only, but not Tensorflow backend. Can you also provide the SciBERT support for Huggingface Tensorflow backend, or is there any workaround for this purpose? Thank you!

@ibeltagy
Copy link
Collaborator

ibeltagy commented Jul 7, 2020

I am not familiar with how HF TF support works, but as far as I understand, we don't need to do anything specific on the model side to make it work on one or the other. I would expect something like TFBertModel.from_pretrained('allenai/scibert_scivocab_uncased') to work out of the box

@jacklxc
Copy link
Author

jacklxc commented Jul 7, 2020

Hi @ibeltagy, as far as I have tried, TFBertModel.from_pretrained('allenai/scibert_scivocab_uncased') or TFAutoModel.from_pretrained('allenai/scibert_scivocab_uncased') throws an error saying the path is not correct. However the similar operation for PyTorch introduced here works without error.

@vasudev13
Copy link

Hi, when working with huggingface/transformers as under

from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("allenai/scibert_scivocab_uncased")
model = AutoModel.from_pretrained("allenai/scibert_scivocab_uncased")

the following error occurs:


OSError: Can't load config for 'allenai/scibert_scivocab_uncased'. Make sure that:

- 'allenai/scibert_scivocab_uncased' is a correct model identifier listed on 'https://huggingface.co/models'

- or 'allenai/scibert_scivocab_uncased' is the correct path to a directory containing a config.json file

Similar error occurs when using TFBertModel as well. @ibeltagy would be great if you can guide on how to work around the above

Thanks a lot.

@dalgaard
Copy link

dalgaard commented May 14, 2021

Hi,

I am facing the same issues as reported by @jacklxc, @ibeltagy do you have any update on this ?

Thanks

@dalgaard
Copy link

Hi,

I am facing the same issues as reported by @jacklxc, @ibeltagy do you have any update on this ?

Thanks

Hi again,

I got it working just adding the parameter from_pt=True to the method call fixes my issue:

from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("allenai/scibert_scivocab_uncased", from_pt=True)
model = AutoModel.from_pretrained("allenai/scibert_scivocab_uncased", from_pt=True)

@jacklxc
Copy link
Author

jacklxc commented May 17, 2021

@dalgaard @vasudev13 It seems your discussion is drifting to the PyTorch version of SciBERT. @dalgaard Have you tried for TFBertModel?

@dalgaard
Copy link

@jacklxc yes you are right, sorry. I actually only had the problem for the TF version, PyTorch seemed to always work for me. So the code in my last post should have used TFAutoModel or TFBertModel, both classes work for me with the parameter from_pt=True.

@vasudev13
Copy link

Yes, same for me.

Thanks.

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

4 participants