pipelines.rst 2.25 KB
Newer Older
Lysandre Debut's avatar
Lysandre Debut committed
1
2
3
4
5
6
7
8
9
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
Recognition, Masked Language Modeling, Sentiment Analysis, Feature Extraction and Question Answering.

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

10
- The :func:`~transformers.pipeline` which is the most powerful object encapsulating all other pipelines
11
- The other task-specific pipelines, such as :class:`~transformers.TokenClassificationPipeline`
Lysandre Debut's avatar
Lysandre Debut committed
12
13
14
15
16
17
18
19
  or :class:`~transformers.QuestionAnsweringPipeline`

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
20
.. autofunction:: transformers.pipeline
Lysandre Debut's avatar
Lysandre Debut committed
21
22
23
24
25
26
27
28
29
30
31


The task specific pipelines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Parent class: Pipeline
=========================================

.. autoclass:: transformers.Pipeline
    :members: predict, transform, save_pretrained

32
TokenClassificationPipeline
Lysandre Debut's avatar
Lysandre Debut committed
33
34
==========================================

35
.. autoclass:: transformers.TokenClassificationPipeline
Lysandre Debut's avatar
Lysandre Debut committed
36

37
NerPipeline
Lysandre Debut's avatar
Lysandre Debut committed
38
39
==========================================

40
This class is an alias of the :class:`~transformers.TokenClassificationPipeline` defined above. Please refer to that pipeline for
Lysandre Debut's avatar
Lysandre Debut committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
documentation and usage examples.

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

.. autoclass:: transformers.FillMaskPipeline

FeatureExtractionPipeline
==========================================

.. autoclass:: transformers.FeatureExtractionPipeline

TextClassificationPipeline
==========================================

.. autoclass:: transformers.TextClassificationPipeline

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

.. autoclass:: transformers.QuestionAnsweringPipeline

63
64
65
66
67

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

.. autoclass:: transformers.SummarizationPipeline
68
69
70
71
72
73


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

.. autoclass:: transformers.TextGenerationPipeline