Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/transformers/pipelines/text_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ 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")
>>> scores = classifier("This movie is disgustingly good !")
>>> from transformers.testing_utils import nested_simplify

>>> nested_simplify(scores) # The scores might vary very slightly based on PyTorch version or Tensorflow.
[{'label': 'POSITIVE', 'score': 1.0}]

>>> nested_simplify(classifier("Director tried too much."))
[{'label': 'NEGATIVE', 'score': 0.996}]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still no nested_simplify

```

[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).

Expand Down