# Saving and reloading sentiment model on local drive?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsaving-and-reloading-sentiment-model-on-local-drive%2F32849%3E%5C
**Category:** Beginners\
**Created:** [March 1, 2023, 11:29pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsaving-and-reloading-sentiment-model-on-local-drive%2F32849 "2023-03-01T23:29:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![uncannyken](https://avatars.discourse-cdn.com/v4/letter/u/ba9def/32.png) [@uncannyken](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Funcannyken)%5C
**Post date:** [March 1, 2023, 11:29pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsaving-and-reloading-sentiment-model-on-local-drive%2F32849%2F1 "2023-03-01T23:29:16Z")

</div>

Hi there,  
I’ve been going through this tutorial : [Getting Started with Sentiment Analysis using Python](https://huggingface.co/blog/sentiment-analysis-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’
