BPYap / BERT-WSD

[EMNLP-Findings 2020] Adapting BERT for Word Sense Disambiguation with Gloss Selection Objective and Example Sentences
https://arxiv.org/abs/2009.11795
62 stars 12 forks source link

How to use models from huggingface? #4

Open JamesArthurHolland opened 3 years ago

JamesArthurHolland commented 3 years ago

How do I use models that aren't in the specified list?

I would like to use this model:

https://huggingface.co/dccuchile/bert-base-spanish-wwm-uncased

How do I go about doing this?

Regards,

Jamie

BPYap commented 3 years ago

Hi Jamie,

One way to do it is to first download the weights, vocab and config file to a local folder then set the --model_name_or_path flag to the path of that local folder.

JamesArthurHolland commented 3 years ago

I'm very unfamiliar with these formats. I downloaded the tensorflow package for the spanish uncased, it only has the following files:

model.ckpt-2000000.index model.ckpt-2000000.data-00000-of-00001 model.ckpt-2000000.meta

The pytorch version only has:

pytorch_model.bin

But the BERT-WSD library appears to look for a config file, which you also mentioned. Is this a tensorflow version specific thing?

BPYap commented 3 years ago

You will only need the pytorch_model.bin along with vocab.txt and config.json under the same directory. It seems that the links for the vocab and config files are broken in the Hugging Face model repository. Upon closer look I found the working links in the colaboratory notebook provided by the authors: https://colab.research.google.com/drive/1uRwg4UmPgYIqGYY4gW_Nsw9782GFJbPt.

You can obtain the two files from the following links: https://users.dcc.uchile.cl/~jperez/beto/cased_2M/vocab.txt https://users.dcc.uchile.cl/~jperez/beto/cased_2M/config.json

Hope it helps. Cheers.