scibert icon indicating copy to clipboard operation
scibert copied to clipboard

Huggingface support for Tensorflow?

Open jacklxc opened this issue 4 years ago • 8 comments

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!

jacklxc avatar Jul 07 '20 00:07 jacklxc

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

ibeltagy avatar Jul 07 '20 01:07 ibeltagy

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.

jacklxc avatar Jul 07 '20 01:07 jacklxc

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.

vasudev13 avatar Aug 17 '20 21:08 vasudev13

Hi,

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

Thanks

dalgaard avatar May 14 '21 08:05 dalgaard

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)

dalgaard avatar May 17 '21 17:05 dalgaard

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

jacklxc avatar May 17 '21 17:05 jacklxc

@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.

dalgaard avatar May 17 '21 19:05 dalgaard

Yes, same for me.

Thanks.

vasudev13 avatar May 19 '21 00:05 vasudev13