|
2 | 2 | import warnings |
3 | 3 | from typing import Any |
4 | 4 |
|
5 | | -from ..generation import GenerationConfig |
6 | | -from ..tokenization_utils import TruncationStrategy |
7 | | -from ..utils import add_end_docstrings, is_torch_available, logging |
8 | | -from .base import Pipeline, build_pipeline_init_args |
| 5 | +from ...generation import GenerationConfig |
| 6 | +from ...tokenization_utils import TruncationStrategy |
| 7 | +from ...utils import add_end_docstrings, is_torch_available, logging |
| 8 | +from ..base import Pipeline, build_pipeline_init_args |
9 | 9 |
|
10 | 10 |
|
11 | 11 | if is_torch_available(): |
12 | | - from ..models.auto.modeling_auto import MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES |
| 12 | + from ...models.auto.modeling_auto import MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES |
13 | 13 |
|
14 | 14 | logger = logging.get_logger(__name__) |
15 | 15 |
|
@@ -77,6 +77,12 @@ class Text2TextGenerationPipeline(Pipeline): |
77 | 77 | return_name = "generated" |
78 | 78 |
|
79 | 79 | def __init__(self, *args, **kwargs): |
| 80 | + if self.return_name == "generated": # Check this isn't summarization/translation instead |
| 81 | + logger.warning_once( |
| 82 | + "The `Text2TextGenerationPipeline` is deprecated and no longer maintained. For most " |
| 83 | + "purposes, we recommend using newer models with causal pipelines like " |
| 84 | + "`TextGenerationPipeline` or `ImageTextToTextPipeline`." |
| 85 | + ) |
80 | 86 | super().__init__(*args, **kwargs) |
81 | 87 |
|
82 | 88 | self.check_model_type(MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES) |
@@ -254,6 +260,14 @@ class SummarizationPipeline(Text2TextGenerationPipeline): |
254 | 260 | # Used in the return key of the pipeline. |
255 | 261 | return_name = "summary" |
256 | 262 |
|
| 263 | + def __init__(self, *args, **kwargs): |
| 264 | + logger.warning_once( |
| 265 | + "The `SummarizationPipeline` is deprecated and no longer maintained. For most " |
| 266 | + "summarization tasks, we recommend appropriately prompting modern general-purpose LLMs " |
| 267 | + "via pipelines like `TextGenerationPipeline` or `ImageTextToTextPipeline`." |
| 268 | + ) |
| 269 | + super().__init__(*args, **kwargs) |
| 270 | + |
257 | 271 | def __call__(self, *args, **kwargs): |
258 | 272 | r""" |
259 | 273 | Summarize the text(s) given as inputs. |
@@ -323,6 +337,14 @@ class TranslationPipeline(Text2TextGenerationPipeline): |
323 | 337 | # Used in the return key of the pipeline. |
324 | 338 | return_name = "translation" |
325 | 339 |
|
| 340 | + def __init__(self, *args, **kwargs): |
| 341 | + logger.warning_once( |
| 342 | + "The `TranslationPipeline` is deprecated and no longer maintained. For most " |
| 343 | + "translation tasks, we recommend appropriately prompting modern general-purpose LLMs " |
| 344 | + "via pipelines like `TextGenerationPipeline` or `ImageTextToTextPipeline`." |
| 345 | + ) |
| 346 | + super().__init__(*args, **kwargs) |
| 347 | + |
326 | 348 | def check_inputs(self, input_length: int, min_length: int, max_new_tokens: int): |
327 | 349 | """ |
328 | 350 | Removed input length check - unnecessary with max_new_tokens (previously relevant for max_length) |
|
0 commit comments