NER and Textcat with shared tok2vec with only one pipeline updating vectors #12382
-
Using spacy 3.4 to train several domain specific models, each containing an ner and textcat pipeline. After much help from this board, decided to have separate configs for the two pipelines with only ner using tok2vec given greater assumed impact. I want to explore next steps of combining the two pipelines. The discrete text chunks passed to each is often is related, yet still different. The text most often used for ner is often broken down into sections that are classified further. Given this, I've been advised that a shared tok2vec might lose some accuracy given the different text. Is it possible for textcat to use the tok2veclistener updated during ner training without making updates? Can I bias the tok2vec to support ner, yet still use it to improve textcat even if textcat will not update vectors? Is this as simple as making tok2vec a frozen component during textcat training? (I train ner and textcat separately so lots of freezing going on). Thank you. `[paths] [system] [nlp] [components] [components.ner] [components.ner.model] [components.ner.model.tok2vec] [components.textcat] [components.textcat.model] [components.textcat.model.linear_model] [components.textcat.model.tok2vec] [components.tok2vec] [components.tok2vec.model] [components.tok2vec.model.embed] [components.tok2vec.model.encode] [corpora] [corpora.dev] [corpora.train] [training] [training.batcher] [training.batcher.size] [training.logger] [training.optimizer] [training.score_weights] [pretraining] [initialize] [initialize.before_init] [initialize.components] [initialize.tokenizer]` Textcat Config: [system] [nlp] [components] [components.textcat] [components.textcat.model] [components.textcat.model.linear_model] [components.textcat.model.tok2vec] [components.textcat.model.tok2vec.embed] [components.textcat.model.tok2vec.encode] [corpora] [corpora.dev] [corpora.train] [training] [training.batcher] [training.batcher.size] [training.logger] [training.optimizer] [training.score_weights] [pretraining] [initialize] [initialize.before_init] [initialize.components] [initialize.components.textcat] [initialize.tokenizer] |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey, thanks for your question! You're correct; by freezing the
You can read more about freezing components here and about sourcing components from trained pipelines here. Hope that helps! |
Beta Was this translation helpful? Give feedback.
Hey, thanks for your question!
Please make sure to correctly format your posts, as it makes it easier for us to read them.
You're correct; by freezing the
tok2vec
component while training thetextcat
, thetok2vec
will not get updated.To implement it the way you described it, you need to make two training runs.
tok2vec
together with thener
without thetextcat
tok2vec
andner
from the trained model, put them infrozen_components
and train thetextcat
on topYou can read more about freezing components here and about sourcing components from trained pipelines here.
Hope that helps!