Ejemplo n.º 1
0
 def test_tf_sentiment_analysis(self):
     mandatory_keys = {"label", "score"}
     for model_name in TEXT_CLASSIF_FINETUNED_MODELS:
         nlp = pipeline(task="sentiment-analysis",
                        model=model_name,
                        tokenizer=model_name)
         self._test_mono_column_pipeline(nlp, VALID_INPUTS, mandatory_keys)
Ejemplo n.º 2
0
 def test_tf_fill_mask_results(self):
     mandatory_keys = {"sequence", "score", "token"}
     valid_inputs = [
         "My name is <mask>",
         "The largest city in France is <mask>",
     ]
     invalid_inputs = [
         "This is <mask> <mask>"  # More than 1 mask_token in the input is not supported
         "This is"  # No mask_token is not supported
     ]
     for model_name in FILL_MASK_FINETUNED_MODELS:
         nlp = pipeline(task="fill-mask",
                        model=model_name,
                        tokenizer=model_name)
         self._test_mono_column_pipeline(
             nlp,
             valid_inputs,
             mandatory_keys,
             invalid_inputs,
             expected_multi_result=expected_fill_mask_result,
             expected_check_keys=["sequence"],
         )
Ejemplo n.º 3
0
 def test_tf_defaults(self):
     # Test that pipelines can be correctly loaded without any argument
     for task in self.pipelines:
         with self.subTest(
                 msg="Testing TF defaults with TF and {}".format(task)):
             pipeline(task)
Ejemplo n.º 4
0
 def test_tf_zero_shot_outputs(self):
     nlp = pipeline(task="zero-shot-classification",
                    model="roberta-large-mnli")
     self._test_zero_shot_pipeline_outputs(nlp)
Ejemplo n.º 5
0
 def test_tf_zero_shot_classification(self):
     for model_name in TEXT_CLASSIF_FINETUNED_MODELS:
         nlp = pipeline(task="zero-shot-classification",
                        model=model_name,
                        tokenizer=model_name)
         self._test_zero_shot_pipeline(nlp)
Ejemplo n.º 6
0
 def test_tf_feature_extraction(self):
     for model_name in FEATURE_EXTRACT_FINETUNED_MODELS:
         nlp = pipeline(task="feature-extraction",
                        model=model_name,
                        tokenizer=model_name)
         self._test_mono_column_pipeline(nlp, VALID_INPUTS, {})