"examples/pytorch/image-pretraining/run_mim.py" did not exist on "ab31b3e41b0f6023debbba1a7dccf3840aaf84f9"
pipelines.rst 6.73 KB
Newer Older
Sylvain Gugger's avatar
Sylvain Gugger committed
1
2
3
4
5
6
7
8
9
10
11
12
.. 
    Copyright 2020 The HuggingFace Team. All rights reserved.

    Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
    the License. You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
    an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
    specific language governing permissions and limitations under the License.

Lysandre Debut's avatar
Lysandre Debut committed
13
Pipelines
Sylvain Gugger's avatar
Sylvain Gugger committed
14
-----------------------------------------------------------------------------------------------------------------------
Lysandre Debut's avatar
Lysandre Debut committed
15

Sylvain Gugger's avatar
Sylvain Gugger committed
16
17
The pipelines are a great and easy way to use models for inference. These pipelines are objects that abstract most of
the complex code from the library, offering a simple API dedicated to several tasks, including Named Entity
Sylvain Gugger's avatar
Sylvain Gugger committed
18
19
Recognition, Masked Language Modeling, Sentiment Analysis, Feature Extraction and Question Answering. See the
:doc:`task summary <../task_summary>` for examples of use.
Lysandre Debut's avatar
Lysandre Debut committed
20
21
22

There are two categories of pipeline abstractions to be aware about:

Sylvain Gugger's avatar
Sylvain Gugger committed
23
24
25
- The :func:`~transformers.pipeline` which is the most powerful object encapsulating all other pipelines.
- The other task-specific pipelines:

26
    - :class:`~transformers.AudioClassificationPipeline`
27
    - :class:`~transformers.AutomaticSpeechRecognitionPipeline`
Sylvain Gugger's avatar
Sylvain Gugger committed
28
29
30
    - :class:`~transformers.ConversationalPipeline`
    - :class:`~transformers.FeatureExtractionPipeline`
    - :class:`~transformers.FillMaskPipeline`
Sylvain Gugger's avatar
Sylvain Gugger committed
31
    - :class:`~transformers.ImageClassificationPipeline`
Sylvain Gugger's avatar
Sylvain Gugger committed
32
33
    - :class:`~transformers.QuestionAnsweringPipeline`
    - :class:`~transformers.SummarizationPipeline`
34
    - :class:`~transformers.TableQuestionAnsweringPipeline`
Sylvain Gugger's avatar
Sylvain Gugger committed
35
36
    - :class:`~transformers.TextClassificationPipeline`
    - :class:`~transformers.TextGenerationPipeline`
37
    - :class:`~transformers.Text2TextGenerationPipeline`
Sylvain Gugger's avatar
Sylvain Gugger committed
38
39
    - :class:`~transformers.TokenClassificationPipeline`
    - :class:`~transformers.TranslationPipeline`
40
    - :class:`~transformers.ZeroShotClassificationPipeline`
Lysandre Debut's avatar
Lysandre Debut committed
41
42

The pipeline abstraction
Sylvain Gugger's avatar
Sylvain Gugger committed
43
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lysandre Debut's avatar
Lysandre Debut committed
44

Sylvain Gugger's avatar
Sylvain Gugger committed
45
46
The `pipeline` abstraction is a wrapper around all the other available pipelines. It is instantiated as any other
pipeline but requires an additional argument which is the `task`.
Lysandre Debut's avatar
Lysandre Debut committed
47

Sylvain Gugger's avatar
Sylvain Gugger committed
48
.. autofunction:: transformers.pipeline
Lysandre Debut's avatar
Lysandre Debut committed
49
50
51


The task specific pipelines
Sylvain Gugger's avatar
Sylvain Gugger committed
52
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lysandre Debut's avatar
Lysandre Debut committed
53

54
55
56
57
58
59
60
AudioClassificationPipeline
=======================================================================================================================

.. autoclass:: transformers.AudioClassificationPipeline
    :special-members: __call__
    :members:

61
62
63
64
65
66
67
AutomaticSpeechRecognitionPipeline
=======================================================================================================================

.. autoclass:: transformers.AutomaticSpeechRecognitionPipeline
    :special-members: __call__
    :members:

Sylvain Gugger's avatar
Sylvain Gugger committed
68
ConversationalPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
69
=======================================================================================================================
Lysandre Debut's avatar
Lysandre Debut committed
70

Sylvain Gugger's avatar
Sylvain Gugger committed
71
.. autoclass:: transformers.Conversation
Lysandre Debut's avatar
Lysandre Debut committed
72

Sylvain Gugger's avatar
Sylvain Gugger committed
73
74
75
76
77
.. autoclass:: transformers.ConversationalPipeline
    :special-members: __call__
    :members:

FeatureExtractionPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
78
=======================================================================================================================
Lysandre Debut's avatar
Lysandre Debut committed
79

Sylvain Gugger's avatar
Sylvain Gugger committed
80
81
82
.. autoclass:: transformers.FeatureExtractionPipeline
    :special-members: __call__
    :members:
Lysandre Debut's avatar
Lysandre Debut committed
83
84

FillMaskPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
85
=======================================================================================================================
Lysandre Debut's avatar
Lysandre Debut committed
86
87

.. autoclass:: transformers.FillMaskPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
88
89
    :special-members: __call__
    :members:
Lysandre Debut's avatar
Lysandre Debut committed
90

91
92
93
94
95
96
97
ImageClassificationPipeline
=======================================================================================================================

.. autoclass:: transformers.ImageClassificationPipeline
    :special-members: __call__
    :members:

Sylvain Gugger's avatar
Sylvain Gugger committed
98
NerPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
99
=======================================================================================================================
Lysandre Debut's avatar
Lysandre Debut committed
100

101
102
103
.. autoclass:: transformers.NerPipeline

See :class:`~transformers.TokenClassificationPipeline` for all details.
Lysandre Debut's avatar
Lysandre Debut committed
104
105

QuestionAnsweringPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
106
=======================================================================================================================
Lysandre Debut's avatar
Lysandre Debut committed
107
108

.. autoclass:: transformers.QuestionAnsweringPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
109
110
    :special-members: __call__
    :members:
111
112

SummarizationPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
113
=======================================================================================================================
114
115

.. autoclass:: transformers.SummarizationPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
116
117
    :special-members: __call__
    :members:
118

119
120
121
122
123
124
125
TableQuestionAnsweringPipeline
=======================================================================================================================

.. autoclass:: transformers.TableQuestionAnsweringPipeline
    :special-members: __call__


Sylvain Gugger's avatar
Sylvain Gugger committed
126
TextClassificationPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
127
=======================================================================================================================
Sylvain Gugger's avatar
Sylvain Gugger committed
128
129
130
131

.. autoclass:: transformers.TextClassificationPipeline
    :special-members: __call__
    :members:
132
133

TextGenerationPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
134
=======================================================================================================================
135
136

.. autoclass:: transformers.TextGenerationPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
137
138
    :special-members: __call__
    :members:
139

140
Text2TextGenerationPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
141
=======================================================================================================================
142
143
144
145
146

.. autoclass:: transformers.Text2TextGenerationPipeline
    :special-members: __call__
    :members:

Sylvain Gugger's avatar
Sylvain Gugger committed
147
TokenClassificationPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
148
=======================================================================================================================
149

Sylvain Gugger's avatar
Sylvain Gugger committed
150
151
152
153
.. autoclass:: transformers.TokenClassificationPipeline
    :special-members: __call__
    :members:

154
155
156
157
158
159
160
TranslationPipeline
=======================================================================================================================

.. autoclass:: transformers.TranslationPipeline
    :special-members: __call__
    :members:

161
ZeroShotClassificationPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
162
=======================================================================================================================
163
164
165
166
167

.. autoclass:: transformers.ZeroShotClassificationPipeline
    :special-members: __call__
    :members:

Sylvain Gugger's avatar
Sylvain Gugger committed
168
Parent class: :obj:`Pipeline`
Sylvain Gugger's avatar
Sylvain Gugger committed
169
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sylvain Gugger's avatar
Sylvain Gugger committed
170
171
172

.. autoclass:: transformers.Pipeline
    :members: