Repository: huggingface/transformers
Pull request: Remove remaining vestiges of the TranslationPipeline

There were some leftover references to the TranslationPipeline, so this PR removes them. Includes the cleanup from #43826 as well as some other changes!

Changed files:
filename: src/transformers/modelcard.py
patch: @@ -84,13 +84,10 @@
     "multiple-choice": "Multiple Choice",
     "object-detection": "Object Detection",
     "question-answering": "Question Answering",
-    "summarization": "Summarization",
     "table-question-answering": "Table Question Answering",
     "text-classification": "Text Classification",
     "text-generation": "Causal Language Modeling",
-    "text2text-generation": "Sequence-to-sequence Language Modeling",
     "token-classification": "Token Classification",
-    "translation": "Translation",
     "zero-shot-classification": "Zero Shot Classification",
     "automatic-speech-recognition": "Automatic Speech Recognition",
     "audio-classification": "Audio Classification",

filename: src/transformers/pipelines/base.py
patch: @@ -281,8 +281,7 @@ def get_default_model_and_revision(targeted_task: dict, task_options: Any | None
            Dictionary representing the given task, that should contain default models
 
         task_options (`Any`, None)
-           Any further value required by the task to get fully specified, for instance (SRC, TGT) languages for
-           translation task.
+           Any further value required by the task to get fully specified.
 
     Returns
 
@@ -298,9 +297,7 @@ def get_default_model_and_revision(targeted_task: dict, task_options: Any | None
     elif "model" in defaults:
         default_models = targeted_task["default"]["model"]
     else:
-        # XXX This error message needs to be updated to be more generic if more tasks are going to become
-        # parametrized
-        raise ValueError('The task defaults can\'t be correctly selected. You probably meant "translation_xx_to_yy"')
+        raise ValueError("The task defaults can't be correctly selected.")
 
     return default_models
 
@@ -1341,17 +1338,7 @@ def check_task(self, task: str) -> tuple[str, dict, Any]:
             targeted_task = self.supported_tasks[task]
             return task, targeted_task, None
 
-        if task.startswith("translation"):
-            tokens = task.split("_")
-            if len(tokens) == 4 and tokens[0] == "translation" and tokens[2] == "to":
-                targeted_task = self.supported_tasks["translation"]
-                task = "translation"
-                return task, targeted_task, (tokens[1], tokens[3])
-            raise KeyError(f"Invalid translation task {task}, use 'translation_XX_to_YY' format")
-
-        raise KeyError(
-            f"Unknown task {task}, available tasks are {self.get_supported_tasks() + ['translation_XX_to_YY']}"
-        )
+        raise KeyError(f"Unknown task {task}, available tasks are {self.get_supported_tasks()}")
 
     def register_pipeline(
         self,

filename: tests/models/m2m_100/test_modeling_m2m_100.py
patch: @@ -236,24 +236,6 @@ class M2M100ModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMix
     is_encoder_decoder = True
     test_missing_keys = False
 
-    # TODO: Fix the failed tests
-    def is_pipeline_test_to_skip(
-        self,
-        pipeline_test_case_name,
-        config_class,
-        model_architecture,
-        tokenizer_name,
-        image_processor_name,
-        feature_extractor_name,
-        processor_name,
-    ):
-        if pipeline_test_case_name == "TranslationPipelineTests":
-            # Get `ValueError: Translation requires a `src_lang` and a `tgt_lang` for this model`.
-            # `M2M100Config` was never used in pipeline tests: cannot create a simple tokenizer.
-            return True
-
-        return False
-
     def setUp(self):
         self.model_tester = M2M100ModelTester(self)
         self.config_tester = ConfigTester(self, config_class=M2M100Config)

filename: tests/models/plbart/test_modeling_plbart.py
patch: @@ -225,24 +225,6 @@ class PLBartModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMix
 
     test_missing_keys = False
 
-    # TODO: Fix the failed tests
-    def is_pipeline_test_to_skip(
-        self,
-        pipeline_test_case_name,
-        config_class,
-        model_architecture,
-        tokenizer_name,
-        image_processor_name,
-        feature_extractor_name,
-        processor_name,
-    ):
-        if pipeline_test_case_name == "TranslationPipelineTests":
-            # Get `ValueError: Translation requires a `src_lang` and a `tgt_lang` for this model`.
-            # `PLBartConfig` was never used in pipeline tests: cannot create a simple tokenizer.
-            return True
-
-        return False
-
     def setUp(self):
         self.model_tester = PLBartModelTester(self)
         self.config_tester = ConfigTester(self, config_class=PLBartConfig)

filename: tests/pipelines/test_pipelines_common.py
patch: @@ -30,7 +30,6 @@
     AutoTokenizer,
     DistilBertForSequenceClassification,
     MaskGenerationPipeline,
-    T5ForConditionalGeneration,
     TextClassificationPipeline,
     TextGenerationPipeline,
     pipeline,
@@ -214,31 +213,6 @@ def test_auto_model_pipeline_registration_from_local_dir(self):
 
             self.assertIsInstance(pipe, TextGenerationPipeline)  # Assert successful load
 
-    @require_torch
-    def test_pipeline_with_task_parameters_no_side_effects(self):
-        """
-        Regression test: certain pipeline flags, like `task`, modified the model configuration, causing unexpected
-        side-effects
-        """
-        # This checkpoint has task-specific parameters that will modify the behavior of the pipeline
-        model = T5ForConditionalGeneration.from_pretrained("t5-small")
-        self.assertTrue(model.config.num_beams == 1)
-
-        # The task-specific parameters used to cause side-effects on `model.config` -- not anymore
-        pipe = pipeline(model=model, tokenizer=AutoTokenizer.from_pretrained("t5-small"), task="translation_en_to_de")
-        self.assertTrue(model.config.num_beams == 1)
-        self.assertTrue(model.generation_config.num_beams == 1)
-
-        # Under the hood: we now store a generation config in the pipeline. This generation config stores the
-        # task-specific parameters.
-        self.assertTrue(pipe.generation_config.num_beams == 4)
-
-        # We can confirm that the task-specific parameters have an effect. (In this case, the default is `num_beams=1`,
-        # which would crash when `num_return_sequences=4` is passed.)
-        pipe("Hugging Face doesn't sell hugs.", num_return_sequences=4)
-        with self.assertRaises(ValueError):
-            pipe("Hugging Face doesn't sell hugs.", num_return_sequences=4, num_beams=1)
-
 
 @is_pipeline_test
 @require_torch
@@ -640,24 +614,11 @@ def check_default_pipeline(self, task, set_seed_fn, check_models_equal_fn):
         auto_model_cls = relevant_auto_classes[0]
 
         # retrieve correct model ids
-        if task == "translation":
-            # special case for translation pipeline which has multiple languages
-            model_ids = []
-            revisions = []
-            tasks = []
-            for translation_pair in task_dict["default"]:
-                model_id, revision = task_dict["default"][translation_pair]["model"]
-
-                model_ids.append(model_id)
-                revisions.append(revision)
-                tasks.append(task + f"_{'_to_'.join(translation_pair)}")
-        else:
-            # normal case - non-translation pipeline
-            model_id, revision = task_dict["default"]["model"]
-
-            model_ids = [model_id]
-            revisions = [revision]
-            tasks = [task]
+        model_id, revision = task_dict["default"]["model"]
+
+        model_ids = [model_id]
+        revisions = [revision]
+        tasks = [task]
 
         # check for equality
         for model_id, revision, task in zip(model_ids, revisions, tasks):