Multiple, separate text classifications in a single model

You didn't save them to the same model directory, did you? You'd need to save them to different directories.

The simplest way to get the two models into a pipeline together is to do something like:

nlp = spacy.load("path/to/model1")
textcat2 = nlp.create_pipe("textcat")
textcat2.from_disk("path/to/model2/textcat")
nlp.add_pipe(textcat2, name="textcat2")
nlp.to_disk("some/output_directory")

The output directory should have your two TextCategorizer models. They'll both set values into the doc.cats variable, so if the second one predicts some of the same classes as the first one, its scores will overwrite the previous one. But if they're predicting different labels, you'll get all of the predictions in the dict at the end.

1 Like