amazon-science / wqa_tanda

This repo provides code and data used in our TANDA paper.
Other
108 stars 26 forks source link

Load pre-trained BERT model with HuggingFace #10

Closed ZahraAbbasiantaeb closed 2 years ago

ZahraAbbasiantaeb commented 3 years ago

Hi, I am trying to load the 'tanda_bert_base_asnq' model with the following code:

config = BertConfig.from_json_file('./TANDA/BERT/tanda_bert_base_asnq/config.json')

bert = BertForPreTraining.from_pretrained('./TANDA/BERT/tanda_bert_base_asnq/model.ckpt.index', from_tf=True, config=config)

and I get the following error:

AttributeError: 'BertForPreTraining' object has no attribute 'bias'

I have used other functions like TFBertModel, TFAutoModel, and BertModel but it didn't work.

could you please help me to solve this error?

cosmoshsv commented 3 years ago

Please try using BertForSequenceClassification.from_pretrained. Also refer to #3 when converting the TF model to pytorch model.

sid7954 commented 2 years ago

Thanks for the answer cosmoshsv