Buckets:

rtrm's picture
|
download
raw
12 kB

Utilities for pipelines

This page lists all the utility functions the library provides for pipelines.

Most of those are only useful if you are studying the code of the models in the library.

Argument handling[[transformers.pipelines.ArgumentHandler]]

class transformers.pipelines.ArgumentHandlertransformers.pipelines.ArgumentHandlerhttps://github.com/huggingface/transformers/blob/vr_33892/src/transformers/pipelines/base.py#L392[]

Base interface for handling arguments for each Pipeline.

class transformers.pipelines.ZeroShotClassificationArgumentHandlertransformers.pipelines.ZeroShotClassificationArgumentHandlerhttps://github.com/huggingface/transformers/blob/vr_33892/src/transformers/pipelines/zero_shot_classification.py#L13[]

Handles arguments for zero-shot for text classification by turning each possible label into an NLI premise/hypothesis pair.

class transformers.pipelines.QuestionAnsweringArgumentHandlertransformers.pipelines.QuestionAnsweringArgumentHandlerhttps://github.com/huggingface/transformers/blob/vr_33892/src/transformers/pipelines/question_answering.py#L142[]

QuestionAnsweringPipeline requires the user to provide multiple arguments (i.e. question & context) to be mapped to internal SquadExample.

QuestionAnsweringArgumentHandler manages all the possible to create a SquadExample from the command-line supplied arguments.

Data format[[transformers.PipelineDataFormat]]

class transformers.PipelineDataFormattransformers.PipelineDataFormathttps://github.com/huggingface/transformers/blob/vr_33892/src/transformers/pipelines/base.py#L402[{"name": "output_path", "val": ": typing.Optional[str]"}, {"name": "input_path", "val": ": typing.Optional[str]"}, {"name": "column", "val": ": typing.Optional[str]"}, {"name": "overwrite", "val": ": bool = False"}]- output_path (str) -- Where to save the outgoing data.

  • input_path (str) -- Where to look for the input data.
  • column (str) -- The column to read.
  • overwrite (bool, optional, defaults to False) -- Whether or not to overwrite the output_path.0

Base class for all the pipeline supported data format both for reading and writing. Supported data formats currently includes:

  • JSON
  • CSV
  • stdin/stdout (pipe)

PipelineDataFormat also includes some utilities to work with multi-columns like mapping from datasets columns to pipelines keyword arguments through the dataset_kwarg_1=dataset_column_1 format.

from_strtransformers.PipelineDataFormat.from_strhttps://github.com/huggingface/transformers/blob/vr_33892/src/transformers/pipelines/base.py#L479[{"name": "format", "val": ": str"}, {"name": "output_path", "val": ": typing.Optional[str]"}, {"name": "input_path", "val": ": typing.Optional[str]"}, {"name": "column", "val": ": typing.Optional[str]"}, {"name": "overwrite", "val": " = False"}]- format (str) -- The format of the desired pipeline. Acceptable values are "json", "csv" or "pipe".

  • output_path (str, optional) -- Where to save the outgoing data.
  • input_path (str, optional) -- Where to look for the input data.
  • column (str, optional) -- The column to read.
  • overwrite (bool, optional, defaults to False) -- Whether or not to overwrite the output_path.0PipelineDataFormatThe proper data format.

Creates an instance of the right subclass of PipelineDataFormat depending on format.

savetransformers.PipelineDataFormat.savehttps://github.com/huggingface/transformers/blob/vr_33892/src/transformers/pipelines/base.py#L451[{"name": "data", "val": ": typing.Union[dict, list[dict]]"}]- data (dict or list of dict) -- The data to store.0

Save the provided data object with the representation for the current PipelineDataFormat.

save_binarytransformers.PipelineDataFormat.save_binaryhttps://github.com/huggingface/transformers/blob/vr_33892/src/transformers/pipelines/base.py#L461[{"name": "data", "val": ": typing.Union[dict, list[dict]]"}]- data (dict or list of dict) -- The data to store.0strPath where the data has been saved.

Save the provided data object as a pickle-formatted binary data on the disk.

class transformers.CsvPipelineDataFormattransformers.CsvPipelineDataFormathttps://github.com/huggingface/transformers/blob/vr_33892/src/transformers/pipelines/base.py#L515[{"name": "output_path", "val": ": typing.Optional[str]"}, {"name": "input_path", "val": ": typing.Optional[str]"}, {"name": "column", "val": ": typing.Optional[str]"}, {"name": "overwrite", "val": " = False"}]- output_path (str) -- Where to save the outgoing data.

  • input_path (str) -- Where to look for the input data.
  • column (str) -- The column to read.
  • overwrite (bool, optional, defaults to False) -- Whether or not to overwrite the output_path.0

Support for pipelines using CSV data format.

savetransformers.CsvPipelineDataFormat.savehttps://github.com/huggingface/transformers/blob/vr_33892/src/transformers/pipelines/base.py#L545[{"name": "data", "val": ": list"}]- data (list[dict]) -- The data to store.0

Save the provided data object with the representation for the current PipelineDataFormat.

class transformers.JsonPipelineDataFormattransformers.JsonPipelineDataFormathttps://github.com/huggingface/transformers/blob/vr_33892/src/transformers/pipelines/base.py#L559[{"name": "output_path", "val": ": typing.Optional[str]"}, {"name": "input_path", "val": ": typing.Optional[str]"}, {"name": "column", "val": ": typing.Optional[str]"}, {"name": "overwrite", "val": " = False"}]- output_path (str) -- Where to save the outgoing data.

  • input_path (str) -- Where to look for the input data.
  • column (str) -- The column to read.
  • overwrite (bool, optional, defaults to False) -- Whether or not to overwrite the output_path.0

Support for pipelines using JSON file format.

savetransformers.JsonPipelineDataFormat.savehttps://github.com/huggingface/transformers/blob/vr_33892/src/transformers/pipelines/base.py#L590[{"name": "data", "val": ": dict"}]- data (dict) -- The data to store.0

Save the provided data object in a json file.

class transformers.PipedPipelineDataFormattransformers.PipedPipelineDataFormathttps://github.com/huggingface/transformers/blob/vr_33892/src/transformers/pipelines/base.py#L601[{"name": "output_path", "val": ": typing.Optional[str]"}, {"name": "input_path", "val": ": typing.Optional[str]"}, {"name": "column", "val": ": typing.Optional[str]"}, {"name": "overwrite", "val": ": bool = False"}]- output_path (str) -- Where to save the outgoing data.

  • input_path (str) -- Where to look for the input data.
  • column (str) -- The column to read.
  • overwrite (bool, optional, defaults to False) -- Whether or not to overwrite the output_path.0

Read data from piped input to the python process. For multi columns data, columns should separated by

If columns are provided, then the output will be a dictionary with {column_x: value_x}

savetransformers.PipedPipelineDataFormat.savehttps://github.com/huggingface/transformers/blob/vr_33892/src/transformers/pipelines/base.py#L630[{"name": "data", "val": ": dict"}]- data (dict) -- The data to store.0

Print the data.

Utilities[[transformers.pipelines.PipelineException]]

class transformers.pipelines.PipelineExceptiontransformers.pipelines.PipelineExceptionhttps://github.com/huggingface/transformers/blob/vr_33892/src/transformers/pipelines/base.py#L375[{"name": "task", "val": ": str"}, {"name": "model", "val": ": str"}, {"name": "reason", "val": ": str"}]- task (str) -- The task of the pipeline.

  • model (str) -- The model used by the pipeline.
  • reason (str) -- The error message to display.0

Raised by a Pipeline when handling call.

Xet Storage Details

Size:
12 kB
·
Xet hash:
bb3b349d16895af33544ae837888f5243bbc826450cfac218be96fea9951f62f

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.