# Can't import spacy model from prodigy train recipe output

**URL:** <https://support.prodi.gy/t/cant-import-spacy-model-from-prodigy-train-recipe-output/2536>\
**Category:** Getting Started\
**Tags:** usage, spacy, solved\
**Created:** [February 11, 2020, 3:57pm UTC](https://support.prodi.gy/t/cant-import-spacy-model-from-prodigy-train-recipe-output/2536 "2020-02-11T15:57:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![joann](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@joann](https://support.prodi.gy/u/joann)\
**Post date:** [February 11, 2020, 3:57pm UTC](https://support.prodi.gy/t/cant-import-spacy-model-from-prodigy-train-recipe-output/2536/1 "2020-02-11T15:57:44Z")

</div>

Hello,

I'm trying to import a model I trained using the following command:  
prodigy train textcat clinical\_order\_types en\_core\_web\_lg --textcat-exclusive

Then when I try loading the model:  
mod = spacy.load(model\_location)  
I'm getting: KeyError: 'PUNCTSIDE\_FIN'

In the past, I've been able to run this type of construct in other prodigy projects in an earlier version of prodigy (1.8?).  
The prodigy training command appears to be working, and this is the contents of the output directory:  
os.listdir(model\_location)  
['textcat', 'ner', 'tagger', 'tokenizer', 'meta.json', 'vocab', 'parser']  
Given that this is a text classification model, I don't know why there is a directory called "ner".

I read this regarding a similar error with spacy.load(): [nlp=spacy.load('en\_core\_web\_sm') KeyError: 'PUNCTSIDE\_FIN' · Issue #4945 · explosion/spaCy · GitHub](https://github.com/explosion/spaCy/issues/4945), but it doesn't seem to apply.

I'm using linux and have  
prodigy 1.9.5  
spacy 2.2.3  
python 3.8

Thanks a lot,

JoAnn

Here's the contents of the meta.json produced from the prodigy train:

{"lang":"en","name":"core\_web\_lg","license":"MIT","author":"Explosion","url":"[https://explosion.ai","email":"contact@explosion.ai](https://explosion.ai%22,%22email%22:%22contact@explosion.ai)","description":"English multi-task CNN trained on OntoNotes, with GloVe vectors trained on Common Crawl. Assigns word vectors, context-specific token vectors, POS tags, dependency parse and named entities.","sources":[{"name":"OntoNotes 5","url":"[https://catalog.ldc.upenn.edu/LDC2013T19","license":"commercial](https://catalog.ldc.upenn.edu/LDC2013T19%22,%22license%22:%22commercial) (licensed by Explosion)"},{"name":"Common Crawl"}],"pipeline":["tagger","parser","ner","textcat"],"version":"2.2.5","spacy\_version":"\>=2.2.2","parent\_package":"spacy","accuracy":{"las":90.1734441725,"uas":92.0132337105,"token\_acc":99.7579930934,"tags\_acc":97.2200800054,"ents\_f":86.5464321721,"ents\_p":86.7358967163,"ents\_r":86.3577935506},"speed":{"cpu":6257.754029418,"gpu":null,"nwords":291314},"labels":{"tagger":["$","''",",","-LRB-","-RRB-",".",":","ADD","AFX","CC","CD","DT","EX","FW","HYPH","IN","JJ","JJR","JJS","LS","MD","NFP","NN","NNP","NNPS","NNS","PDT","POS","PRP","PRP$","RB","RBR","RBS","RP","SYM","TO","UH","VB","VBD","VBG","VBN","VBP","VBZ","WDT","WP","WP$","WRB","XX","\_SP","``"],"parser":["ROOT","acl","acomp","advcl","advmod","agent","amod","appos","attr","aux","auxpass","case","cc","ccomp","compound","conj","csubj","csubjpass","dative","dep","det","dobj","expl","intj","mark","meta","neg","nmod","npadvmod","nsubj","nsubjpass","nummod","oprd","parataxis","pcomp","pobj","poss","preconj","predet","prep","prt","punct","quantmod","relcl","xcomp"],"ner":["CARDINAL","DATE","EVENT","FAC","GPE","LANGUAGE","LAW","LOC","MONEY","NORP","ORDINAL","ORG","PERCENT","PERSON","PRODUCT","QUANTITY","TIME","WORK\_OF\_ART"],"textcat":["vent\_stop","iabp","vent","transfuse\_blood\_products","noninvasive\_vent","other","chest\_tube\_suction"]},"vectors":{"width":300,"vectors":684831,"keys":684830,"name":"en\_core\_web\_lg.vectors"},"factories":{"tagger":"tagger","parser":"parser","ner":"ner","textcat":"textcat"}}

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [February 11, 2020, 4:58pm UTC](https://support.prodi.gy/t/cant-import-spacy-model-from-prodigy-train-recipe-output/2536/2 "2020-02-11T16:58:42Z")

</div>

Hi! This looks like the spaCy version used by Prodigy and the spaCy version you're loading your model with might be incompatible – you can run `pip list` in both environments to find out. If one environment is running v2.1.x and the other one is running v2.2.x, this would explain what's going on.

---

<div class="post-metadata">

**Author:** ![joann](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@joann](https://support.prodi.gy/u/joann)\
**Post date:** [February 11, 2020, 5:23pm UTC](https://support.prodi.gy/t/cant-import-spacy-model-from-prodigy-train-recipe-output/2536/3 "2020-02-11T17:23:13Z")

</div>

Awesome. I didn't realize I was loading my spacy model in a different environment. Thanks so much.

---

<div class="post-metadata">

**Author:** ![jeremy](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/jeremy/32/2164_2.png) [@jeremy](https://support.prodi.gy/u/jeremy)\
**Post date:** [June 3, 2021, 9:39am UTC](https://support.prodi.gy/t/cant-import-spacy-model-from-prodigy-train-recipe-output/2536/4 "2021-06-03T09:39:06Z")

</div>

I'm getting a similar error but I don't think it's for the same reason.

I annotated data using my own custom labels

> prodigy ner.manual ner\_news\_headlines blank:en non\_annotated\_news\_headlines.jsonl --label MY\_PERSON,MY\_ORG,MY\_LOCATION

Then I trained a custom model

> prodigy train ner ner\_news\_headlines blank:en --output "C:\Users\my\_username\desktop"

I believe the above step stored the trained model as a file called "my\_test\_model" (originally "tokenizer" but I renamed it)  
I wanted to use the new trained model (stored in the file "my\_test\_model") to annotate more data so I used the command

> prodigy ner.correct ner\_news\_headlines my\_test\_model non\_annotated\_news\_headlines.jsonl

However, I got the following error.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/6/60e098b4f7273b7a1fb0f598ca259649cb98af8a.png)

Any idea why I'm getting this error? Am I using the recipes incorrectly?

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [June 3, 2021, 12:30pm UTC](https://support.prodi.gy/t/cant-import-spacy-model-from-prodigy-train-recipe-output/2536/5 "2021-06-03T12:30:48Z")

</div>

> [@jeremy](#):
>
> Then I trained a custom model
> 
> > prodigy train ner ner\_news\_headlines blank:en --output "C:\Users\my\_username\desktop"

> [@jeremy](#):
>
> I believe the above step stored the trained model as a file called "my\_test\_model" (originally "tokenizer" but I renamed it)

The directory specified as `--output` is expected to be the directory to save the model data to – for example, a directory `my_test_model`. When you specified `C:\Users\my_username\desktop`, all the model data was written to your desktop – including multiple directories for the components, the `meta.json` etc.

One of the directories is `tokenizer`, so it sounds like you renamed that and accidentally ended up only using the tokenizer directory instead of the whole model data? That's also why spaCy is confused, because it can't find any of the files it expects.

There should be multiple directories and files created on your desktop, but it's probably a bit messy now – so I'd recommend to just re-run the training and specify an empty directory as the output. This is where all the files will be saved (and you'll also be able to see all the files and directories that are created).

---

<div class="post-metadata">

**Author:** ![jeremy](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/jeremy/32/2164_2.png) [@jeremy](https://support.prodi.gy/u/jeremy)\
**Post date:** [June 24, 2021, 5:35am UTC](https://support.prodi.gy/t/cant-import-spacy-model-from-prodigy-train-recipe-output/2536/6 "2021-06-24T05:35:55Z")

</div>

Thanks, now I got it!
