pipelines.rst 3.13 KB
Newer Older
Lysandre Debut's avatar
Lysandre Debut committed
1
2
3
4
5
Pipelines
----------------------------------------------------

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
6
7
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
8
9
10

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

Sylvain Gugger's avatar
Sylvain Gugger committed
11
12
13
14
15
16
17
18
19
20
21
22
- The :func:`~transformers.pipeline` which is the most powerful object encapsulating all other pipelines.
- The other task-specific pipelines:

    - :class:`~transformers.ConversationalPipeline`
    - :class:`~transformers.FeatureExtractionPipeline`
    - :class:`~transformers.FillMaskPipeline`
    - :class:`~transformers.QuestionAnsweringPipeline`
    - :class:`~transformers.SummarizationPipeline`
    - :class:`~transformers.TextClassificationPipeline`
    - :class:`~transformers.TextGenerationPipeline`
    - :class:`~transformers.TokenClassificationPipeline`
    - :class:`~transformers.TranslationPipeline`
Lysandre Debut's avatar
Lysandre Debut committed
23
24
25
26
27
28
29

The pipeline abstraction
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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`.

Sylvain Gugger's avatar
Sylvain Gugger committed
30
.. autofunction:: transformers.pipeline
Lysandre Debut's avatar
Lysandre Debut committed
31
32
33


The task specific pipelines
Sylvain Gugger's avatar
Sylvain Gugger committed
34
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lysandre Debut's avatar
Lysandre Debut committed
35

Sylvain Gugger's avatar
Sylvain Gugger committed
36
ConversationalPipeline
Lysandre Debut's avatar
Lysandre Debut committed
37
38
==========================================

Sylvain Gugger's avatar
Sylvain Gugger committed
39
.. autoclass:: transformers.Conversation
Lysandre Debut's avatar
Lysandre Debut committed
40

Sylvain Gugger's avatar
Sylvain Gugger committed
41
42
43
44
45
.. autoclass:: transformers.ConversationalPipeline
    :special-members: __call__
    :members:

FeatureExtractionPipeline
Lysandre Debut's avatar
Lysandre Debut committed
46
47
==========================================

Sylvain Gugger's avatar
Sylvain Gugger committed
48
49
50
.. autoclass:: transformers.FeatureExtractionPipeline
    :special-members: __call__
    :members:
Lysandre Debut's avatar
Lysandre Debut committed
51
52
53
54
55

FillMaskPipeline
==========================================

.. autoclass:: transformers.FillMaskPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
56
57
    :special-members: __call__
    :members:
Lysandre Debut's avatar
Lysandre Debut committed
58

Sylvain Gugger's avatar
Sylvain Gugger committed
59
NerPipeline
Lysandre Debut's avatar
Lysandre Debut committed
60
61
==========================================

Sylvain Gugger's avatar
Sylvain Gugger committed
62
63
This class is an alias of the :class:`~transformers.TokenClassificationPipeline` defined below. Please refer to that
pipeline for documentation and usage examples.
Lysandre Debut's avatar
Lysandre Debut committed
64
65
66
67
68

QuestionAnsweringPipeline
==========================================

.. autoclass:: transformers.QuestionAnsweringPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
69
70
    :special-members: __call__
    :members:
71
72
73
74
75

SummarizationPipeline
==========================================

.. autoclass:: transformers.SummarizationPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
76
77
    :special-members: __call__
    :members:
78

Sylvain Gugger's avatar
Sylvain Gugger committed
79
80
81
82
83
84
TextClassificationPipeline
==========================================

.. autoclass:: transformers.TextClassificationPipeline
    :special-members: __call__
    :members:
85
86
87
88
89

TextGenerationPipeline
==========================================

.. autoclass:: transformers.TextGenerationPipeline
Sylvain Gugger's avatar
Sylvain Gugger committed
90
91
    :special-members: __call__
    :members:
92

Sylvain Gugger's avatar
Sylvain Gugger committed
93
TokenClassificationPipeline
94
95
==========================================

Sylvain Gugger's avatar
Sylvain Gugger committed
96
97
98
99
.. autoclass:: transformers.TokenClassificationPipeline
    :special-members: __call__
    :members:

100

Sylvain Gugger's avatar
Sylvain Gugger committed
101
102
103
104
105
Parent class: :obj:`Pipeline`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: transformers.Pipeline
    :members: