Hi there,
I’ve been going through this tutorial : Getting Started with Sentiment Analysis using Python
data = [“I love you”, “I hate you”]
// trained the model
trainer.train()
trainer.evaluate()
// saved the model on local drive
model_dir = ‘E:/ken/huggingFaceModels/’
trainer.save_model(model_dir + ‘fine_tune_sentiment/model’)
// tried to reload the model
from transformers import DistilBertForTokenClassification, DistilBertConfig, AutoModelForTokenClassification
mdl = DistilBertForTokenClassification.from_pretrained(model_dir + ‘fine_tune_sentiment/model’, local_files_only=True)
// apply reloaded model to data
mdl(data)
I get the following error message. I’m thinking that it is a different function that is required to reload a sentiment model?
// Error message
Traceback (most recent call last):
Input In [50] in <cell line: 1>
mdl(data)
File ~\anaconda3\lib\site-packages\torch\nn\modules\module.py:1194 in _call_impl
return forward_call(*input, **kwargs)
File ~\anaconda3\lib\site-packages\transformers\models\distilbert\modeling_distilbert.py:990 in forward
outputs = self.distilbert(
File ~\anaconda3\lib\site-packages\torch\nn\modules\module.py:1194 in _call_impl
return forward_call(*input, **kwargs)
File ~\anaconda3\lib\site-packages\transformers\models\distilbert\modeling_distilbert.py:563 in forward
input_shape = input_ids.size()
AttributeError: ‘list’ object has no attribute ‘size’