@SylwiaOliwia We are using Roberta for sentiment analysis, we have to build a model and saved it in pkl file, but after loading, it is giving error “AttributeError: ‘TransformersVocab’ object has no attribute ‘tokenizer’”.
Can you help me with this?
I am using this thread:
1 Like
I had the same problem on Win10 laptop (no GPU). After hopeless googling I found this: https://www.kaggle.com/maroberti/fastai-with-transformers-bert-roberta
Basically TransformersVocab class needs the following methods:
def __getstate__(self):
return {'itos':self.itos, 'tokenizer':self.tokenizer}
def __setstate__(self, state:dict):
self.itos = state['itos']
self.tokenizer = state['tokenizer']
self.stoi = collections.defaultdict(int,{v:k for k,v in enumerate(self.itos)})
I don’t understand the solution, but after those additions I could fit in distilbert model following the same Medium post.
1 Like