Pipeline for text classification
Author: AlecS12
Pull request: no
Labels: name: wontfix

name: Core: Pipeline

name: Usage

# 🚀 Feature request
Could  you please add a text classification pipeline?
<!-- A clear and concise description of the feature proposal.
     Please provide a link to the paper and code in case they exist. -->

## Motivation

<!-- Please outline the motivation for the proposal. Is your feature request
     related to a problem? e.g., I'm always frustrated when [...]. If this is related
     to another GitHub issue, please link here too. -->

## Your contribution

<!-- Is there any way that you could help, e.g. by submitting a PR?
     Make sure to read the CONTRIBUTING.MD readme:
     https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md -->


Comments:
Did you check the README?

grep `text-classification: Initialize a TextClassificationPipeline directly, or see sentiment-analysis for an example.
`

Sorry, missed this somehow.  Thanks for adding it!

On Fri, Feb 7, 2020 at 12:38 PM Julien Chaumond <notifications@github.com>
wrote:

> Did you check the README?
>
> grep text-classification: Initialize a TextClassificationPipeline
> directly, or see sentiment-analysis for an example.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/transformers/issues/2776?email_source=notifications&email_token=AALSLVVTFNJWUYUPOVQ7PVLRBWMBJA5CNFSM4KRR6SN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELD46DA#issuecomment-583520012>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AALSLVWTPQIT7XNKXLWZSYLRBWMBJANCNFSM4KRR6SNQ>
> .
>


@julien-c trying that throws: 

```
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-7-b612b71d2864> in <module>
      1 sentiment_analysis = pipeline('sentiment-analysis')
----> 2 text_classification = pipeline('text-classification')

~/SpacedOut/engage-sentiment/.venv/lib/python3.7/site-packages/transformers/pipelines.py in pipeline(task, model, config, tokenizer, modelcard, framework, **kwargs)
   1024     # Retrieve the task
   1025     if task not in SUPPORTED_TASKS:
-> 1026         raise KeyError("Unknown task {}, available tasks are {}".format(task, list(SUPPORTED_TASKS.keys())))
   1027 
   1028     framework = framework or get_framework(model)

KeyError: "Unknown task text-classification, available tasks are ['feature-extraction', 'sentiment-analysis', 'ner', 'question-answering', 'fill-mask']"
```

you should import and use `TextClassificationPipeline` directly (i.e. there isn't a shortcut to use in `pipeline()`)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.


I'm going to ask the stupid question, and say there are no tutorial or code examples for `TextClassificationPipeline`. I mean I can dig up the source code, but documentation without examples is never my thing. Would be helpful if I know the data format for `run_tf_text_classification.py` as well. I guess what I'm asking is to finetune a text classification model, but the example at https://huggingface.co/transformers/custom_datasets.html is way too long. Quoting a meme, "ain't nobody got time for that".