mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
Adding doctest for text-classification
pipeline. (#20262)
* Adding doctest for `text-classification` pipeline. * Remove nested_simplify.
This commit is contained in:
parent
c282e93a74
commit
d9efb36cf6
@ -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).
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user