# Use SpaCy textcat weights in a Prodigy TextClassifier

**URL:** <https://support.prodi.gy/t/use-spacy-textcat-weights-in-a-prodigy-textclassifier/2021>\
**Category:** Uncategorized\
**Tags:** textcat, solved\
**Created:** [September 17, 2019, 11:54pm UTC](https://support.prodi.gy/t/use-spacy-textcat-weights-in-a-prodigy-textclassifier/2021 "2019-09-17T23:54:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![timothyjlaurent](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/timothyjlaurent/32/590_2.png) [@timothyjlaurent](https://support.prodi.gy/u/timothyjlaurent)\
**Post date:** [September 17, 2019, 11:54pm UTC](https://support.prodi.gy/t/use-spacy-textcat-weights-in-a-prodigy-textclassifier/2021/1 "2019-09-17T23:54:38Z")

</div>

Hi,

I'm saving a SpaCy model from a batch\_train run and now I'd like to use that as the weights in a textcat.teach workflow.

If I initialize the TextClassifier with the SpaCy model with the textcat pipe will it use the previously trained weights or is there some way to make this happen?

---

<div class="post-metadata">

**Author:** ![timothyjlaurent](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/timothyjlaurent/32/590_2.png) [@timothyjlaurent](https://support.prodi.gy/u/timothyjlaurent)\
**Post date:** [September 18, 2019, 10:28pm UTC](https://support.prodi.gy/t/use-spacy-textcat-weights-in-a-prodigy-textclassifier/2021/2 "2019-09-18T22:28:30Z")

</div>

OK, I think I might have the answer to my question (but would appreciate confirmation 🙂 ).

So as far as I can tell, when initializing the TextClassifier prodigy model, it will add sentencizer and textcat pipes to the spacy model if they don't exist.

If they do exist though, it looks like it just uses the ones that are present.

```python
    textcat = nlp.get_pipe('textcat')
    textcat.foo = 'bar'

    model = TextClassifier(
        nlp,
        labels,
        long_text=long_text,
        low_data=len(examples) < 1000,
        init_tok2vec=init_tok2vec,
        exclusive_classes=exclusive,
    )

    assert model.nlp.get_pipe('textcat').foo == 'bar'

```

Is this right?

---

<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:** [September 19, 2019, 10:08am UTC](https://support.prodi.gy/t/use-spacy-textcat-weights-in-a-prodigy-textclassifier/2021/3 "2019-09-19T10:08:23Z")

</div>

> [@timothyjlaurent](#):
>
> So as far as I can tell, when initializing the TextClassifier prodigy model, it will add sentencizer and textcat pipes to the spacy model if they don't exist.
> 
> If they do exist though, it looks like it just uses the ones that are present.

Thanks for updating and yes, that's correct. What Prodigy calls the `TextClassifier` class (and what could have probably been named better) is the "annotation model" that takes the `nlp` object, makes sure that everything is set up correctly and handles updating the model in the loop.

One small thing to note about pre-defined text classifiers is that spaCy currently doesn't support resizing an existing pre-trained text classifier, so you can't add more labels to it if the model's already pre-trained. So if you're using an existing text classifier, the labels in the data all need to be in the model already.

---

<div class="post-metadata">

**Author:** ![timothyjlaurent](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/timothyjlaurent/32/590_2.png) [@timothyjlaurent](https://support.prodi.gy/u/timothyjlaurent)\
**Post date:** [September 19, 2019, 8:07pm UTC](https://support.prodi.gy/t/use-spacy-textcat-weights-in-a-prodigy-textclassifier/2021/4 "2019-09-19T20:07:16Z")

</div>

Thank for adding clarity and the bit about adding new labels.
