Skip to content

Latest commit

 

History

History
93 lines (52 loc) · 5.81 KB

File metadata and controls

93 lines (52 loc) · 5.81 KB
graph LR
    Pipeline["Pipeline"]
    PreTrainedModel_TFPreTrainedModel["PreTrainedModel / TFPreTrainedModel"]
    PreTrainedTokenizer["PreTrainedTokenizer"]
    PreTrainedFeatureExtractor_BaseImageProcessor["PreTrainedFeatureExtractor / BaseImageProcessor"]
    ProcessorMixin["ProcessorMixin"]
    ModelOutput["ModelOutput"]
    GenerationConfig["GenerationConfig"]
    Pipeline -- "uses" --> PreTrainedModel_TFPreTrainedModel
    Pipeline -- "delegates preprocessing to" --> PreTrainedTokenizer
    Pipeline -- "delegates preprocessing to" --> PreTrainedFeatureExtractor_BaseImageProcessor
    Pipeline -- "consumes" --> ModelOutput
    Pipeline -- "uses" --> GenerationConfig
    PreTrainedModel_TFPreTrainedModel -- "produces" --> ModelOutput
    PreTrainedTokenizer -- "uses" --> ProcessorMixin
    PreTrainedFeatureExtractor_BaseImageProcessor -- "uses" --> ProcessorMixin
Loading

CodeBoardingDemoContact

Details

The transformers library's inference subsystem is orchestrated by the Pipeline component, which provides a high-level API for various machine learning tasks. The Pipeline delegates input preprocessing to specialized components: PreTrainedTokenizer for text-based inputs and PreTrainedFeatureExtractor / BaseImageProcessor for non-textual data. Both preprocessing components leverage the ProcessorMixin for common functionalities. After preprocessing, the Pipeline utilizes PreTrainedModel / TFPreTrainedModel to perform the actual inference, which in turn produces ModelOutput objects containing the raw results. For generative tasks, the Pipeline configures the model's behavior using GenerationConfig. This modular design ensures clear separation of concerns, enabling flexible and efficient execution of diverse ML inference workflows.

Pipeline

The central orchestrator of the inference workflow. It provides a unified, high-level API for various ML tasks, managing the sequence of operations from raw input to final output.

Related Classes/Methods:

PreTrainedModel / TFPreTrainedModel

Represents the core deep learning model responsible for performing the actual inference. These classes encapsulate the model architecture and loaded weights, providing the forward pass functionality.

Related Classes/Methods:

PreTrainedTokenizer

Handles the preprocessing of text inputs. It converts raw text into numerical representations (e.g., token IDs, attention masks) suitable for text-based models.

Related Classes/Methods:

PreTrainedFeatureExtractor / BaseImageProcessor

Manages the preprocessing of non-textual inputs (e.g., images, audio). It transforms raw data into features or tensors compatible with vision or audio models.

Related Classes/Methods:

ProcessorMixin

A mixin class providing common functionalities and utilities for various data processors (tokenizers, feature extractors). It promotes code reuse across different preprocessing components.

Related Classes/Methods:

ModelOutput

A standardized data structure used to encapsulate the raw outputs generated by PreTrainedModels after inference. It provides a consistent way for the Pipeline to receive and further process model results.

Related Classes/Methods:

GenerationConfig

Defines the parameters and strategies for text generation tasks (e.g., beam search, sampling, max length). The Pipeline uses this configuration when performing generative inference with a model.

Related Classes/Methods: