# New pipeline for zero-shot text classification

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fnew-pipeline-for-zero-shot-text-classification%2F681%3E%5C
**Category:** 🤗Transformers\
**Created:** [August 11, 2020, 6:34pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fnew-pipeline-for-zero-shot-text-classification%2F681 "2020-08-11T18:34:22Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![joeddav](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/joeddav/32/53881_2.png) [@joeddav](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjoeddav)%5C
**Post date:** [August 24, 2020, 3:35pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fnew-pipeline-for-zero-shot-text-classification%2F681%2F15 "2020-08-24T15:35:29Z")

</div>

Thanks for the helpful answer, @rsk97. Let me just add a bit:

1. 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 loss as if you were doing NLI with the true label set to `entailment`. You should also pass an equal number of sequences with a _randomly selected false label_, such as `<cls> Who are you voting for in 2020 ? <sep> This text is about sports . <sep>`. For these fictitious example, the target label should be set to `contradiction`. This method will work a little bit if you have a small amount of labeled data, but it will really excel if you have a large amount of data for some of your labels and only a small amount of data (or no data) for other labels.

2. We also have a bunch of ready-trained sentiment classifiers in the model hub. Use one of those out of the box, or fine-tune it further on your particular dataset.

This brings up a good point that the zero shot classification pipeline should _only_ be used in the absence of labeled data or when fine-tuning a model is not feasible. **If you have a good set of labeled data and you are able to fine-tune a model, you should fine-tune a model.** You will get better performance and at a lower computational cost.

---

_[View the full topic](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fnew-pipeline-for-zero-shot-text-classification%2F681)._
