Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/transformers/pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
get_default_model_and_revision,
load_model,
)
from .deprecated import SummarizationPipeline, Text2TextGenerationPipeline, TranslationPipeline
from .depth_estimation import DepthEstimationPipeline
from .document_question_answering import DocumentQuestionAnsweringPipeline
from .feature_extraction import FeatureExtractionPipeline
Expand All @@ -74,7 +75,6 @@
from .object_detection import ObjectDetectionPipeline
from .question_answering import QuestionAnsweringArgumentHandler, QuestionAnsweringPipeline
from .table_question_answering import TableQuestionAnsweringArgumentHandler, TableQuestionAnsweringPipeline
from .text2text_generation import SummarizationPipeline, Text2TextGenerationPipeline, TranslationPipeline
from .text_classification import TextClassificationPipeline
from .text_generation import TextGenerationPipeline
from .text_to_audio import TextToAudioPipeline
Expand Down
16 changes: 16 additions & 0 deletions src/transformers/pipelines/deprecated/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# coding=utf-8
# Copyright 2025 The HuggingFace Inc. team.
#
# 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.

from .text2text_generation import SummarizationPipeline, Text2TextGenerationPipeline, TranslationPipeline
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import warnings
from typing import Any

from ..generation import GenerationConfig
from ..tokenization_utils import TruncationStrategy
from ..utils import add_end_docstrings, is_torch_available, logging
from .base import Pipeline, build_pipeline_init_args
from ...generation import GenerationConfig
from ...tokenization_utils import TruncationStrategy
from ...utils import add_end_docstrings, is_torch_available, logging
from ..base import Pipeline, build_pipeline_init_args


if is_torch_available():
from ..models.auto.modeling_auto import MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES
from ...models.auto.modeling_auto import MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES

logger = logging.get_logger(__name__)

Expand Down Expand Up @@ -77,6 +77,12 @@ class Text2TextGenerationPipeline(Pipeline):
return_name = "generated"

def __init__(self, *args, **kwargs):
if self.return_name == "generated": # Check this isn't summarization/translation instead
logger.warning_once(
"The `Text2TextGenerationPipeline` is deprecated and no longer maintained. For most "
"purposes, we recommend using newer models with causal pipelines like "
"`TextGenerationPipeline` or `ImageTextToTextPipeline`."
)
super().__init__(*args, **kwargs)

self.check_model_type(MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES)
Expand Down Expand Up @@ -254,6 +260,14 @@ class SummarizationPipeline(Text2TextGenerationPipeline):
# Used in the return key of the pipeline.
return_name = "summary"

def __init__(self, *args, **kwargs):
logger.warning_once(
"The `SummarizationPipeline` is deprecated and no longer maintained. For most "
"summarization tasks, we recommend appropriately prompting modern general-purpose LLMs "
"via pipelines like `TextGenerationPipeline` or `ImageTextToTextPipeline`."
)
super().__init__(*args, **kwargs)

def __call__(self, *args, **kwargs):
r"""
Summarize the text(s) given as inputs.
Expand Down Expand Up @@ -323,6 +337,14 @@ class TranslationPipeline(Text2TextGenerationPipeline):
# Used in the return key of the pipeline.
return_name = "translation"

def __init__(self, *args, **kwargs):
logger.warning_once(
"The `TranslationPipeline` is deprecated and no longer maintained. For most "
"translation tasks, we recommend appropriately prompting modern general-purpose LLMs "
"via pipelines like `TextGenerationPipeline` or `ImageTextToTextPipeline`."
)
super().__init__(*args, **kwargs)

def check_inputs(self, input_length: int, min_length: int, max_new_tokens: int):
"""
Removed input length check - unnecessary with max_new_tokens (previously relevant for max_length)
Expand Down