Adding doctest for text-classification pipeline. (#20262)

* Adding doctest for `text-classification` pipeline.

* Remove nested_simplify.
This commit is contained in:
Nicolas Patry 2022-11-16 17:15:34 +01:00 committed by GitHub
parent c282e93a74
commit d9efb36cf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,6 +50,21 @@ class TextClassificationPipeline(Pipeline):
Text classification pipeline using any `ModelForSequenceClassification`. See the [sequence classification
examples](../task_summary#sequence-classification) for more information.
Example:
```python
>>> from transformers import pipeline
>>> classifier = pipeline(model="distilbert-base-uncased-finetuned-sst-2-english")
>>> classifier("This movie is disgustingly good !")
[{'label': 'POSITIVE', 'score': 1.0}]
>>> classifier("Director tried too much.")
[{'label': 'NEGATIVE', 'score': 0.996}]
```
[Learn more about the basics of using a pipeline in the [pipeline tutorial]](../pipeline_tutorial)
This text classification pipeline can currently be loaded from [`pipeline`] using the following task identifier:
`"sentiment-analysis"` (for classifying sequences according to positive or negative sentiments).