Thanks, that looks like what I want, but I've been having no fun trying to implement it.
I managed to save my "aggregated" model using the code you gave. But when I tried to import it I got:
KeyError: "[E002] Can't find factory for 'textcat2'. This usually happens when spaCy calls `nlp.create_pipe` with a component name that's not built in - for example, when constructing the pipeline from a model's meta.json. If you're using a custom component, you can write to `Language.factories['textcat2']` or remove it from the model meta and add it via `nlp.add_pipe` instead."
I Googled that and found this thread saying I needed to package with spacy package
for it to work: adding custom attribute to doc, having NER use attribute
I tried that, but packaging didn't work:
shutil.Error: [('am-test/textcat', 'am-test-packaged/en_vectors_web_lg-2.1.0/en_vectors_web_lg/en_vectors_web_lg-2.1.0/textcat', "[Errno 13] Permission denied: 'am-test-packaged/en_vectors_web_lg-2.1.0/en_vectors_web_lg/en_vectors_web_lg-2.1.0/textcat'"), ('am-test/textcat3', 'am-test-packaged/en_vectors_web_lg-2.1.0/en_vectors_web_lg/en_vectors_web_lg-2.1.0/textcat3', "[Errno 13] Permission denied: 'am-test-packaged/en_vectors_web_lg-2.1.0/en_vectors_web_lg/en_vectors_web_lg-2.1.0/textcat3'"), ('am-test/vocab', 'am-test-packaged/en_vectors_web_lg-2.1.0/en_vectors_web_lg/en_vectors_web_lg-2.1.0/vocab', "[Errno 13] Permission denied: 'am-test-packaged/en_vectors_web_lg-2.1.0/en_vectors_web_lg/en_vectors_web_lg-2.1.0/vocab'"), ('am-test', 'am-test-packaged/en_vectors_web_lg-2.1.0/en_vectors_web_lg/en_vectors_web_lg-2.1.0', "[Errno 13] Permission denied: 'am-test-packaged/en_vectors_web_lg-2.1.0/en_vectors_web_lg/en_vectors_web_lg-2.1.0'")]
If I breakpoint at that line, do the copy manually, and then run the rest of the function, it seems to build - but then the resulting .tar.gz
is only 4kb, and besides a mention in the meta.json
, doesn't include my model.