alexriggio / BERT-LoRA-TensorRT

This repository contains a custom implementation of the BERT model, fine-tuned for specific tasks, along with an implementation of Low Rank Approximation (LoRA). The models are optimized for high performance using NVIDIA's TensorRT.
Apache License 2.0
46 stars 6 forks source link

Mismatched keys in custom implemetation #1

Closed JAYANTH-MOHAN closed 8 months ago

JAYANTH-MOHAN commented 8 months ago

In this code cell : tokenizer_base = BertTokenizer.from_pretrained('bert-base-uncased') bert_base = MyBertForSequenceClassification.from_pretrained( model_type='bert-base-uncased', config_args={"vocab_size": 30522, "n_classes": 2} # these are default configs but just added for explicity )

i am getting this error : AssertionError: mismatched keys: 201 != 202

alexriggio commented 8 months ago

Thanks for raising this issue.

From the error message, it appears that the state dictionary from the Hugging Face model may have one key less than the custom model's state dictionary.

  1. Could you confirm the version of the transformers library you're using? If not already, I recommend trying with transformers==4.28.1.

  2. For reference, the specific package versions used can be found at notebooks/requirements/requirements_fine_tuning.txt.

JAYANTH-MOHAN commented 8 months ago

Thanks, it works now!