Fine tune Zero-shot classification on multi-label dataset
Hi all,I started a small project where I am trying to fine-tune a zero-shot classification model on a proprietary dataset. I was thinking to use the NLI approach, building contradiction and entailment statements for each of my sentences/labels pairs.I have a dataset with sentences and for each of them multiple true labels.However, I am not sure on what is the best way to approach this, given that in literature I have only seen the case where there is only one label per sentence.Making one example:Sentence 1. Classes = [‘A’,‘B’,‘C’]Should I build my dataset generating three different samplesSentence 1. This is about ‘A’ + Entailment labelSentence 1. This is about ‘B’ + Entailment labelSentence 1. This is about ‘C’ + Entailment labelor generating only one as follows:Sentence 1. This is about A, B, C. + Entailment labelI am happy to hear any other ideas on this.Thanks a lot!
2023-11-28T09:53:51Z
Here is one approach depending on the number of labels you havegithub.comNielsRogge/Transformers-Tutorials/blob/master/BERT/Fine_tuning_BERT_(and_friends)_for_multi_label_text_classification.ipynb{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Fine-tuning BERT (and friends) for multi-label text classification.ipynb",
      "provenance": [],
      "collapsed_sections": [],
      "authorship_tag": "ABX9TyMiblo1Ci0GTlAbbA5wB3mn",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    },
    "accelerator": "GPU",
    "widgets": {This file has been truncated.show original
2023-11-28T12:10:57Z
Hi,thanks for pointing to this resource, but this is useful only for a classic multi-label classification problem.I am looking into fine-tuning of a zero-shot classification model using the entailment-contradiction approach.
2023-11-28T12:44:46Z
Am  curious  why you wouldn’t treat it as a multi classification problem? Is there a reason it needs to be NLI. Will help me learn! Thanks
2023-11-30T14:32:13Z
According to this hereNew pipeline for zero-shot text classification🤗TransformersThanks for the helpful answer,@rsk97. Let me just add a bit: 


I discuss this briefly in my blog post under Classification as Natural Language Inference -> When Some Annotated Data is Available. In short, if you have a limited amount of labeled data, you can further fine-tune the pre-trained NLI model. Pass the true label for a given sequence in the same way as you would during inference, e.g. <cls> Who are you voting for in 2020 ? <sep> This text is about politics . <sep>, and calculate the l…The recommend approach is what you are suggesting in option 1. Basically present each of your multiple labels as entailments separately, but the author also suggests presenting an equal number of contradictions.