Hi,
I was using this snippet of code to load my finetuned GPT2 and it was working absolutely fine:
tokenizer = GPT2Tokenizer.from_pretrained(‘gpt2-medium’)
model = GPT2LMHeadModel.from_pretrained(‘gpt2-medium’)
model_path = ‘/content/drive/My Drive/PREDICTION/POETRY/EDset3_trained_models/gpt2_medium_SET3_ED.pt’
model.load_state_dict(torch.load(model_path))
model = model.to(device)
As of this morning, having made no changes, I get the following error:
RuntimeError: Error(s) in loading state_dict for GPT2LMHeadModel:
Missing key(s) in state_dict: “transformer.h.0.attn.masked_bias”, “transformer.h.1.attn.masked_bias”