2020-12-07 23:36:34 +00:00
|
|
|
..
|
|
|
|
|
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.
|
|
|
|
|
|
2020-03-02 19:07:10 +00:00
|
|
|
Pipelines
|
2020-09-23 17:20:45 +00:00
|
|
|
-----------------------------------------------------------------------------------------------------------------------
|
2020-03-02 19:07:10 +00:00
|
|
|
|
2020-10-26 22:26:02 +00:00
|
|
|
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
|
2020-08-03 15:44:46 +00:00
|
|
|
Recognition, Masked Language Modeling, Sentiment Analysis, Feature Extraction and Question Answering. See the
|
|
|
|
|
:doc:`task summary <../task_summary>` for examples of use.
|
2020-03-02 19:07:10 +00:00
|
|
|
|
|
|
|
|
There are two categories of pipeline abstractions to be aware about:
|
|
|
|
|
|
2020-08-03 15:44:46 +00:00
|
|
|
- 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`
|
2020-08-04 20:37:49 +00:00
|
|
|
- :class:`~transformers.ZeroShotClassificationPipeline`
|
2020-09-02 11:34:35 +00:00
|
|
|
- :class:`~transformers.Text2TextGenerationPipeline`
|
2020-03-02 19:07:10 +00:00
|
|
|
|
|
|
|
|
The pipeline abstraction
|
2020-09-23 17:20:45 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2020-03-02 19:07:10 +00:00
|
|
|
|
2020-10-26 22:26:02 +00:00
|
|
|
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`.
|
2020-03-02 19:07:10 +00:00
|
|
|
|
2020-06-22 20:08:09 +00:00
|
|
|
.. autofunction:: transformers.pipeline
|
2020-03-02 19:07:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
The task specific pipelines
|
2020-09-23 17:20:45 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2020-03-02 19:07:10 +00:00
|
|
|
|
2020-08-03 15:44:46 +00:00
|
|
|
ConversationalPipeline
|
2020-09-23 17:20:45 +00:00
|
|
|
=======================================================================================================================
|
2020-03-02 19:07:10 +00:00
|
|
|
|
2020-08-03 15:44:46 +00:00
|
|
|
.. autoclass:: transformers.Conversation
|
2020-03-02 19:07:10 +00:00
|
|
|
|
2020-08-03 15:44:46 +00:00
|
|
|
.. autoclass:: transformers.ConversationalPipeline
|
|
|
|
|
:special-members: __call__
|
|
|
|
|
:members:
|
|
|
|
|
|
|
|
|
|
FeatureExtractionPipeline
|
2020-09-23 17:20:45 +00:00
|
|
|
=======================================================================================================================
|
2020-03-02 19:07:10 +00:00
|
|
|
|
2020-08-03 15:44:46 +00:00
|
|
|
.. autoclass:: transformers.FeatureExtractionPipeline
|
|
|
|
|
:special-members: __call__
|
|
|
|
|
:members:
|
2020-03-02 19:07:10 +00:00
|
|
|
|
|
|
|
|
FillMaskPipeline
|
2020-09-23 17:20:45 +00:00
|
|
|
=======================================================================================================================
|
2020-03-02 19:07:10 +00:00
|
|
|
|
|
|
|
|
.. autoclass:: transformers.FillMaskPipeline
|
2020-08-03 15:44:46 +00:00
|
|
|
:special-members: __call__
|
|
|
|
|
:members:
|
2020-03-02 19:07:10 +00:00
|
|
|
|
2020-08-03 15:44:46 +00:00
|
|
|
NerPipeline
|
2020-09-23 17:20:45 +00:00
|
|
|
=======================================================================================================================
|
2020-03-02 19:07:10 +00:00
|
|
|
|
2020-08-03 15:44:46 +00:00
|
|
|
This class is an alias of the :class:`~transformers.TokenClassificationPipeline` defined below. Please refer to that
|
|
|
|
|
pipeline for documentation and usage examples.
|
2020-03-02 19:07:10 +00:00
|
|
|
|
|
|
|
|
QuestionAnsweringPipeline
|
2020-09-23 17:20:45 +00:00
|
|
|
=======================================================================================================================
|
2020-03-02 19:07:10 +00:00
|
|
|
|
|
|
|
|
.. autoclass:: transformers.QuestionAnsweringPipeline
|
2020-08-03 15:44:46 +00:00
|
|
|
:special-members: __call__
|
|
|
|
|
:members:
|
2020-03-17 22:04:21 +00:00
|
|
|
|
|
|
|
|
SummarizationPipeline
|
2020-09-23 17:20:45 +00:00
|
|
|
=======================================================================================================================
|
2020-03-17 22:04:21 +00:00
|
|
|
|
|
|
|
|
.. autoclass:: transformers.SummarizationPipeline
|
2020-08-03 15:44:46 +00:00
|
|
|
:special-members: __call__
|
|
|
|
|
:members:
|
2020-04-22 13:37:03 +00:00
|
|
|
|
2020-08-03 15:44:46 +00:00
|
|
|
TextClassificationPipeline
|
2020-09-23 17:20:45 +00:00
|
|
|
=======================================================================================================================
|
2020-08-03 15:44:46 +00:00
|
|
|
|
|
|
|
|
.. autoclass:: transformers.TextClassificationPipeline
|
|
|
|
|
:special-members: __call__
|
|
|
|
|
:members:
|
2020-04-22 13:37:03 +00:00
|
|
|
|
|
|
|
|
TextGenerationPipeline
|
2020-09-23 17:20:45 +00:00
|
|
|
=======================================================================================================================
|
2020-04-22 13:37:03 +00:00
|
|
|
|
|
|
|
|
.. autoclass:: transformers.TextGenerationPipeline
|
2020-08-03 15:44:46 +00:00
|
|
|
:special-members: __call__
|
|
|
|
|
:members:
|
2020-07-30 18:11:39 +00:00
|
|
|
|
2020-09-02 11:34:35 +00:00
|
|
|
Text2TextGenerationPipeline
|
2020-09-23 17:20:45 +00:00
|
|
|
=======================================================================================================================
|
2020-09-02 11:34:35 +00:00
|
|
|
|
|
|
|
|
.. autoclass:: transformers.Text2TextGenerationPipeline
|
|
|
|
|
:special-members: __call__
|
|
|
|
|
:members:
|
|
|
|
|
|
2020-08-03 15:44:46 +00:00
|
|
|
TokenClassificationPipeline
|
2020-09-23 17:20:45 +00:00
|
|
|
=======================================================================================================================
|
2020-07-30 18:11:39 +00:00
|
|
|
|
2020-08-03 15:44:46 +00:00
|
|
|
.. autoclass:: transformers.TokenClassificationPipeline
|
|
|
|
|
:special-members: __call__
|
|
|
|
|
:members:
|
|
|
|
|
|
2020-08-04 20:37:49 +00:00
|
|
|
ZeroShotClassificationPipeline
|
2020-09-23 17:20:45 +00:00
|
|
|
=======================================================================================================================
|
2020-08-04 20:37:49 +00:00
|
|
|
|
|
|
|
|
.. autoclass:: transformers.ZeroShotClassificationPipeline
|
|
|
|
|
:special-members: __call__
|
|
|
|
|
:members:
|
|
|
|
|
|
2020-08-03 15:44:46 +00:00
|
|
|
Parent class: :obj:`Pipeline`
|
2020-09-23 17:20:45 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2020-08-03 15:44:46 +00:00
|
|
|
|
|
|
|
|
.. autoclass:: transformers.Pipeline
|
|
|
|
|
:members:
|