stanford-crfm / BioMedLM

590 stars 61 forks source link

Seqcls for multi-label task #19

Closed guathwa closed 1 year ago

guathwa commented 1 year ago

I would like to use the seqcls script for a multilabel task with 41 labels. Please advise what are the changes I need to make for this use case. Thanks.

J38 commented 1 year ago

One thing you could do is supply your training data in the same way, and for each example with multiple labels, create a distinct example with each label. Then when you train the model you will end up with a probability distribution over the 41 labels that predicts the most likely label. Hopefully the model would put weight on each label that is appropriate. You could then pick a probability threshold and pick every label above that, and tune that to get the results you are happy with. The code can be set up to output the probabilities for all labels.

You could also create 41 models with label-yes, label-no ... but that might be computationally expensive.

Another thing you could try is using the generative code instead. So you could just frame each example as prompt --> label1, label2, label3 <|endoftext|> (in this example label1, label2, and label3 are appropriate) and see if the model generates good lists of labels.

Could you provide more detail about your problem? For instance what is the input, and what are the output labels? How many labels tend to get applied?

guathwa commented 1 year ago

Thanks. I have managed to complete the training for my use case.