Error while loading spacy model from the pickle file #12080
-
I am getting the following error while loading spacy NER model from the pickle file.
How to reproduce the behaviourI have trained the NER model using the spacy version Your Environment
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
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:
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. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
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:
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 i…