fix zero shot pipeline docs (#6245)
This commit is contained in:
@@ -20,6 +20,7 @@ There are two categories of pipeline abstractions to be aware about:
|
|||||||
- :class:`~transformers.TextGenerationPipeline`
|
- :class:`~transformers.TextGenerationPipeline`
|
||||||
- :class:`~transformers.TokenClassificationPipeline`
|
- :class:`~transformers.TokenClassificationPipeline`
|
||||||
- :class:`~transformers.TranslationPipeline`
|
- :class:`~transformers.TranslationPipeline`
|
||||||
|
- :class:`~transformers.ZeroShotClassificationPipeline`
|
||||||
|
|
||||||
The pipeline abstraction
|
The pipeline abstraction
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@@ -97,6 +98,13 @@ TokenClassificationPipeline
|
|||||||
:special-members: __call__
|
:special-members: __call__
|
||||||
:members:
|
:members:
|
||||||
|
|
||||||
|
ZeroShotClassificationPipeline
|
||||||
|
==========================================
|
||||||
|
|
||||||
|
.. autoclass:: transformers.ZeroShotClassificationPipeline
|
||||||
|
:special-members: __call__
|
||||||
|
:members:
|
||||||
|
|
||||||
|
|
||||||
Parent class: :obj:`Pipeline`
|
Parent class: :obj:`Pipeline`
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ from .pipelines import (
|
|||||||
TextGenerationPipeline,
|
TextGenerationPipeline,
|
||||||
TokenClassificationPipeline,
|
TokenClassificationPipeline,
|
||||||
TranslationPipeline,
|
TranslationPipeline,
|
||||||
|
ZeroShotClassificationPipeline,
|
||||||
pipeline,
|
pipeline,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1033,23 +1033,24 @@ class ZeroShotClassificationPipeline(Pipeline):
|
|||||||
Classify the sequence(s) given as inputs.
|
Classify the sequence(s) given as inputs.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
sequences (:obj:`str` or obj:`List[str]`):
|
sequences (:obj:`str` or :obj:`List[str]`):
|
||||||
The sequence(s) to classify, will be truncated if the model input is too large.
|
The sequence(s) to classify, will be truncated if the model input is too large.
|
||||||
candidate_labels (:obj:`str` or obj:`List[str]`):
|
candidate_labels (:obj:`str` or :obj:`List[str]`):
|
||||||
The set of possible class labels to classify each sequence into. Can be a single label, a string of
|
The set of possible class labels to classify each sequence into. Can be a single label, a string of
|
||||||
comma-separated labels, or a list of labels.
|
comma-separated labels, or a list of labels.
|
||||||
hypothesis_template (obj:`str`, `optional`, defaults to :obj:`"This example is {}."`):
|
hypothesis_template (:obj:`str`, `optional`, defaults to :obj:`"This example is {}."`):
|
||||||
The template used to turn each label into an NLI-style hypothesis. This template must include a {}
|
The template used to turn each label into an NLI-style hypothesis. This template must include a {}
|
||||||
or similar syntax for the candidate label to be inserted into the template. For example, the default
|
or similar syntax for the candidate label to be inserted into the template. For example, the default
|
||||||
template is :obj:`"This example is {}."` With the candidate label :obj:`"sports"`, this would be fed
|
template is :obj:`"This example is {}."` With the candidate label :obj:`"sports"`, this would be fed
|
||||||
into the model like :obj:`"<cls> sequence to classify <sep> This example is sports . <sep>"`. The
|
into the model like :obj:`"<cls> sequence to classify <sep> This example is sports . <sep>"`. The
|
||||||
default template works well in many cases, but it may be worthwhile to experiment with different
|
default template works well in many cases, but it may be worthwhile to experiment with different
|
||||||
templates depending on the task setting.
|
templates depending on the task setting.
|
||||||
multi_class (obj:`bool`, `optional`, defaults to :obj:`False`):
|
multi_class (:obj:`bool`, `optional`, defaults to :obj:`False`):
|
||||||
Whether or not multiple candidate labels can be true. If :obj:`False`, the scores are normalized
|
Whether or not multiple candidate labels can be true. If :obj:`False`, the scores are normalized
|
||||||
such that the sum of the label likelihoods for each sequence is 1. If :obj:`True`, the labels are
|
such that the sum of the label likelihoods for each sequence is 1. If :obj:`True`, the labels are
|
||||||
considered independent and probabilities are normalized for each candidate by doing a softmax of
|
considered independent and probabilities are normalized for each candidate by doing a softmax of
|
||||||
the entailment score vs. the contradiction score.
|
the entailment score vs. the contradiction score.
|
||||||
|
|
||||||
Return:
|
Return:
|
||||||
A :obj:`dict` or a list of :obj:`dict`: Each result comes as a dictionary with the
|
A :obj:`dict` or a list of :obj:`dict`: Each result comes as a dictionary with the
|
||||||
following keys:
|
following keys:
|
||||||
|
|||||||
Reference in New Issue
Block a user