from_disk method throws ValueError: Cannot deserialize model: mismatched structure #12887
-
The following code is taken from https://spacy.io/usage/processing-pipelines#pipelines: lang = "en"
pipeline = ["tok2vec", "tagger", "parser", "ner", "attribute_ruler", "lemmatizer"]
data_path = "path/to/en_core_web_sm/en_core_web_sm-3.0.0" ### I only changed this path
cls = spacy.util.get_lang_class(lang) # 1. Get Language class, e.g. English
nlp = cls() # 2. Initialize it
for name in pipeline:
nlp.add_pipe(name) # 3. Add the component to the pipeline
nlp.from_disk(data_path) # 4. Load in the binary data And I receive the above error. My spacy version is Can anyone please tell me where I'm going wrong? Thank you in advance! Please note that |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If you're just trying to load from a directory, please use If you're trying to understand how |
Beta Was this translation helpful? Give feedback.
If you're just trying to load from a directory, please use
spacy.load("/path/to/dir")
instead.If you're trying to understand how
spacy.load
works, please look atspacy.util.load_model_from_path
for the exact details. (This code in the docs is intended more as a sketch/pseudocode than a 100% runnable example, but I agree that this isn't clear from the docs.)