Migrated from spacy v2 to spacyv3 in project #13959
Unanswered
delhydee
asked this question in
Help: Other Questions
Replies: 1 comment
-
|
You cannot directly load a spaCy v2 model in spaCy v3 — the binary format changed. Here is the correct migration path: Step 1: Convert the modelspaCy provides a built-in converter: python -m spacy convert-v2-to-v3 /path/to/v2_model /output/dirThis generates a v3-compatible model directory. Step 2: Download from Azure Blob Storage firstfrom azure.storage.blob import BlobServiceClient
import os
client = BlobServiceClient.from_connection_string("your_conn_string")
blob = client.get_blob_client(container="your-container", blob="model.tar.gz")
with open("model.tar.gz", "wb") as f:
f.write(blob.download_blob().readall())
os.system("tar -xzf model.tar.gz")Step 3: Load and verifyimport spacy
nlp = spacy.load("./converted_model")
doc = nlp("Test sentence")
print([(ent.text, ent.label_) for ent in doc.ents])If the converter failsIf the model was heavily customised, retrain on v3 from scratch using your original training data — the training pipeline in v3 is more efficient and the accuracy is usually better. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have model trained from training data using spacy v2 and now I have upgraded spacy version in project from v2to v3. I want to import trained model from the repository in azure storage blob service. while downloading model it is giving error Blob could not be downloaded Error message: [E1005] Unable to set attribute 'POS' in tokenizer exception for ' '. Tokenizer exceptions are only allowed to specify ORTH and NORM. Fresh model en_core_web_md has been loaded successfully. I don't have training data that I can use to again train model using spacyv3, hence wanted to access existing trained model. I then used migration script using Github copilot to migrate trained model in v2 to spacy v3 but still getting Error message: Trying to read a Model that was created with an incompatible version of Thinc. Now GitHub copilot suggest it is not possible to migrate spacyv2 trained model and only option left is to retrain. Can you please let me know if it is possible and if so how it will be achieved in python code.
Beta Was this translation helpful? Give feedback.
All reactions