Using Trainer to save a Bartforsequenceclassification model

trainer.train()
trainer.save_model()

It gives me the error:

modeling_utils.py", line 2546, in save_pretrained
raise RuntimeError(
RuntimeError: The weights trying to be saved contained shared tensors [{‘model.shared.weight’, ‘model.encoder.embed_tokens.weight’, ‘model.decoder.embed_tokens.weight’}] that are mismatching the transformers base configuration. Try saving using safe_serialization=False or remove this tensor sharing.

Could anyone please tell me why is it happening? and how to solve it without using that safe_serialization=False?

1 Like