Problem in loading an old sentence classification roberta model generated using transformer version 3.0.2 with new library


I created a roberta sentence classifier model last year using the transformer version 3.0.2. Currently, I am trying to upgrade the library in new virtual environment and load the model to perform prediction, but I keep getting an error as shown below. Please help me with possible solutions to this issue.

RuntimeError                              Traceback (most recent call last)
Cell In [9], line 47
     44 model = ROBERTAClassifier()
     45 model =
---> 47 load_checkpoint(model_path + '/model.pkl', model, device)
     49 df = evaluate(model, test_dataloader, filepath, category)
     51 t2 = time.perf_counter()

File ~/bert/training/training_roberta_08-10-2021/, in load_checkpoint(path, model, device)
    155 def load_checkpoint(path, model, device):    
    156     state_dict = torch.load(path, map_location=device)
--> 157     model.load_state_dict(state_dict['model_state_dict'])
    159     return state_dict['valid_loss']

File ~/python_envs/nlp_pipeline_2/lib/python3.9/site-packages/torch/nn/modules/, in Module.load_state_dict(self, state_dict, strict)
   1046         error_msgs.insert(
   1047             0, 'Missing key(s) in state_dict: {}. '.format(
   1048                 ', '.join('"{}"'.format(k) for k in missing_keys)))
   1050 if len(error_msgs) > 0:
-> 1051     raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
   1052                        self.__class__.__name__, "\n\t".join(error_msgs)))
   1053 return _IncompatibleKeys(missing_keys, unexpected_keys)

RuntimeError: Error(s) in loading state_dict for ROBERTAClassifier:
	Missing key(s) in state_dict: "roberta.embeddings.position_ids".