Closed devendrasoni18 closed 1 year ago
Models trained in the same major version (like v3) should be able to be loaded in later versions, but because there can be minor inconsistencies, we recommend thorough testing and, if possible, retraining.
You appear to be having a separate issue related to pickle serialization. While pickling should work with models, we recommend the native saving/loading features in most circumstances. So normally you should do this:
# where you create the model
nlp.to_disk("my_model")
# where you load the model
nlp = spacy.load("my_model")
I'm not sure if the pickle problem is due to changed versions in spaCy or what - I haven't seen that error before, and in fact Googling it turns up this issue, so it seem rather uncommon.
Is it possible for you to load the model in the original training environment and save it using the above method instead of pickle? If so I'd recommend that approach.
On review, we can't guarantee that objects pickled with one version of spaCy will always work with another - pickle is just too low-level. For that reason we recommend you use our provided serialization API.
Since this isn't a bug, I'll move it to Discussions, but if you'd like more help just let us know.
I am getting the following error while loading spacy NER model from the pickle file.
self.model = pickle.load(open(model_path, 'rb'))
How to reproduce the behaviour
I have trained the NER model using the spacy version
3.1.2
and I recently upgraded the spacy to the latest3.4
. The error might be because of some version incompatibilities. If that is the case can someone confirm if is it possible to load spacy NER model trained on spacy version '3.1.2' can be loaded on the upgraded spacy '3.4'Your Environment