How to train a model with a textcat or textcat_multilabel but with conditions ? #11197
-
Hello,
and the output should resemble or be split with True or False values (ignore the float):
The purpose is to ensure that there are several output labels while respecting the condition of not having an output label and its opposing (e.g. Lable_1: True and Label_2: True) I inquired and discovered that we can handle many outputs and various losses with Keras, however I am not sure if Spacy does as well. I can also use spacy's textcat multilabel because labels are non-mutually exclusive, but I will most likely end up with a label and its opposite. The last option I have is to train a model for each pair of labels and then train them, however this will take a long time. Thank you in advance for your help. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
There's no way to add constraints like that to a textcat model. There are a couple of different ways you can model it instead. To be clear, are these opposed labels strictly binary, in that a document is always one or the other? Or can a document be neither of them? Assuming that they are strictly binary, you could train a non-exclusive multilabel model with only the positive variants, and then the probability of the negative label would be You could also train a textcat_multilabel model with all the labels, and instead of using a simple threshold, take the higher value from the opposed pairs as positive and the other as negative. That could be implemented as a simple component. I would also recommend you try the approach of training a textcat for each pair of labels, as it might end up being an easier task that way. |
Beta Was this translation helpful? Give feedback.
There's no way to add constraints like that to a textcat model. There are a couple of different ways you can model it instead.
To be clear, are these opposed labels strictly binary, in that a document is always one or the other? Or can a document be neither of them?
Assuming that they are strictly binary, you could train a non-exclusive multilabel model with only the positive variants, and then the probability of the negative label would be
1 - positive prob
.You could also train a textcat_multilabel model with all the labels, and instead of using a simple threshold, take the higher value from the opposed pairs as positive and the other as negative. That could be implemented as a simple c…