Fasttext: FastText for multi-labels

Created on 17 Nov 2017  路  5Comments  路  Source: facebookresearch/fastText

Can FastText be used for a multi-label scenario?

Are you planning on implementing the functionality that would basically use all the labels of each document? For now the workaround would be to manually repeat each document on a separate line with each of the classes it belongs to.

Thanks

Most helpful comment

Hi @saroufimc1 , @rostandk , @jes-moore , @matanster , @juggernauts ,
You can do multi-label classification by using the softmax, but the threshold you have to provide at test time can be misleading (because the sum of the probabilities must sum to 1).

We added a more straightforward way to handle this. You can now use an independent sigmoid for each label, by using -loss ova or -loss one-vs-all.

You can have more information about this in the updated tutorial

Thank you very much for your feedback.

Best regards,
Onur

All 5 comments

see #185

I don't think this is super clear anywhere.
I worked around this by the following method and got decent results compared to BLSTM-1DMaxPool:

__label__toxic__label__racist__label__insult Text of the comment here
__label__toxic Text of the comment here
__label__clean Text of the comment here
__label__racist__label__insult Text of the comment here

I think I'm not getting it, as in the code, it seems to read any labels provided at the head of an input line, not just a single one. Am I grossly mistaken?

@jmoore24 I checked the default example on https://fasttext.cc/docs/en/supervised-tutorial.html and they seem to use a multi-label input to build a text classifier for the cooking section of StackExchange.

If you download that dataset, it seems that labels are separated by space as shown below:
__label__cake __label__pan __label__measurements Is it possible to know how much the cake weighs using a specific size of cake pan before baking?

In your case, I see that you do not have any space between the labels, where did you find your example? Just want to be sure how the input should be for the multi-label model.

However, it seems that running fasttext by providing multiple labels for each document separated by a space or to split labels for many lines, then each line with a label does not make a significant difference in the accuracy. I guess the main issue is that the output is not multi-label because of softmax.

Hi @saroufimc1 , @rostandk , @jes-moore , @matanster , @juggernauts ,
You can do multi-label classification by using the softmax, but the threshold you have to provide at test time can be misleading (because the sum of the probabilities must sum to 1).

We added a more straightforward way to handle this. You can now use an independent sigmoid for each label, by using -loss ova or -loss one-vs-all.

You can have more information about this in the updated tutorial

Thank you very much for your feedback.

Best regards,
Onur

Was this page helpful?
0 / 5 - 0 ratings

Related issues

premrajnarkhede picture premrajnarkhede  路  3Comments

PGryllos picture PGryllos  路  4Comments

poppingtonic picture poppingtonic  路  3Comments

leonardgithub picture leonardgithub  路  4Comments

ragvri picture ragvri  路  3Comments