mirror of
https://github.com/saymrwulf/transformers.git
synced 2026-05-14 20:58:08 +00:00
Update tiny models and a few fixes (#22928)
* run_check_tiny_models * update summary * update mixin * update pipeline_model_mapping * update pipeline_model_mapping * Update for gpt_bigcode --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
parent
2fbd6df81c
commit
975159bb61
9 changed files with 116 additions and 16 deletions
|
|
@ -407,7 +407,7 @@ class GPTBigCodeModelTester:
|
|||
|
||||
|
||||
@require_torch
|
||||
class GPTBigCodeMQAModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
class GPTBigCodeModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
# TODO: Update the tests to use valid pretrained models.
|
||||
all_model_classes = (
|
||||
(
|
||||
|
|
@ -420,11 +420,6 @@ class GPTBigCodeMQAModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTe
|
|||
else ()
|
||||
)
|
||||
all_generative_model_classes = (GPTBigCodeForCausalLM,) if is_torch_available() else ()
|
||||
fx_compatible = False
|
||||
test_missing_keys = False
|
||||
test_pruning = False
|
||||
test_torchscript = False
|
||||
multi_query = True
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"feature-extraction": GPTBigCodeModel,
|
||||
|
|
@ -436,6 +431,11 @@ class GPTBigCodeMQAModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTe
|
|||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
fx_compatible = False
|
||||
test_missing_keys = False
|
||||
test_pruning = False
|
||||
test_torchscript = False
|
||||
multi_query = True
|
||||
|
||||
# special case for DoubleHeads model
|
||||
def _prepare_for_class(self, inputs_dict, model_class, return_labels=False):
|
||||
|
|
@ -521,7 +521,7 @@ class GPTBigCodeMQAModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTe
|
|||
|
||||
|
||||
@require_torch
|
||||
class GPTBigCodeMHAModelTest(GPTBigCodeMQAModelTest):
|
||||
class GPTBigCodeMHAModelTest(GPTBigCodeModelTest):
|
||||
# `parameterized_class` breaks with mixins, so we use inheritance instead
|
||||
multi_query = False
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ from transformers.utils import is_torch_available, is_vision_available
|
|||
|
||||
from ...test_configuration_common import ConfigTester
|
||||
from ...test_modeling_common import ModelTesterMixin, floats_tensor
|
||||
from ...test_pipeline_mixin import PipelineTesterMixin
|
||||
|
||||
|
||||
if is_torch_available():
|
||||
|
|
@ -282,19 +283,28 @@ class SamModelTester:
|
|||
|
||||
|
||||
@require_torch
|
||||
class SamModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
class SamModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
"""
|
||||
Here we also overwrite some of the tests of test_modeling_common.py, as SAM's vision encoder does not use input_ids, inputs_embeds,
|
||||
attention_mask and seq_length.
|
||||
"""
|
||||
|
||||
all_model_classes = (SamModel,) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": SamModel, "mask-generation": SamModel} if is_torch_available() else {}
|
||||
)
|
||||
fx_compatible = False
|
||||
test_pruning = False
|
||||
test_resize_embeddings = False
|
||||
test_head_masking = False
|
||||
test_torchscript = False
|
||||
|
||||
# TODO: Fix me @Arthur: `run_batch_test` in `tests/test_pipeline_mixin.py` not working
|
||||
def is_pipeline_test_to_skip(
|
||||
self, pipeline_test_casse_name, config_class, model_architecture, tokenizer_name, processor_name
|
||||
):
|
||||
return True
|
||||
|
||||
def setUp(self):
|
||||
self.model_tester = SamModelTester(self)
|
||||
self.vision_config_tester = ConfigTester(self, config_class=SamVisionConfig, has_text_modality=False)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,12 @@ from transformers.testing_utils import (
|
|||
|
||||
if is_vision_available():
|
||||
from PIL import Image
|
||||
else:
|
||||
|
||||
class Image:
|
||||
@staticmethod
|
||||
def open(*args, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def hashimage(image: Image) -> str:
|
||||
|
|
@ -60,6 +66,10 @@ class MaskGenerationPipelineTests(unittest.TestCase):
|
|||
"./tests/fixtures/tests_samples/COCO/000000039769.png",
|
||||
]
|
||||
|
||||
# TODO: Fix me @Arthur
|
||||
def run_pipeline_test(self, mask_generator, examples):
|
||||
pass
|
||||
|
||||
@require_tf
|
||||
@unittest.skip("Image segmentation not implemented in TF")
|
||||
def test_small_model_tf(self):
|
||||
|
|
|
|||
|
|
@ -44,9 +44,11 @@ class QAPipelineTests(unittest.TestCase):
|
|||
tf_model_mapping = TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING
|
||||
|
||||
if model_mapping is not None:
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ not in _TO_SKIP}
|
||||
if tf_model_mapping is not None:
|
||||
tf_model_mapping = {config: model for config, model in tf_model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
tf_model_mapping = {
|
||||
config: model for config, model in tf_model_mapping.items() if config.__name__ not in _TO_SKIP
|
||||
}
|
||||
|
||||
def get_test_pipeline(self, model, tokenizer, processor):
|
||||
if isinstance(model.config, LxmertConfig):
|
||||
|
|
|
|||
|
|
@ -35,9 +35,11 @@ class TextClassificationPipelineTests(unittest.TestCase):
|
|||
tf_model_mapping = TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
|
||||
|
||||
if model_mapping is not None:
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ not in _TO_SKIP}
|
||||
if tf_model_mapping is not None:
|
||||
tf_model_mapping = {config: model for config, model in tf_model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
tf_model_mapping = {
|
||||
config: model for config, model in tf_model_mapping.items() if config.__name__ not in _TO_SKIP
|
||||
}
|
||||
|
||||
@require_torch
|
||||
def test_small_model_pt(self):
|
||||
|
|
|
|||
|
|
@ -49,9 +49,11 @@ class TokenClassificationPipelineTests(unittest.TestCase):
|
|||
tf_model_mapping = TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING
|
||||
|
||||
if model_mapping is not None:
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ not in _TO_SKIP}
|
||||
if tf_model_mapping is not None:
|
||||
tf_model_mapping = {config: model for config, model in tf_model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
tf_model_mapping = {
|
||||
config: model for config, model in tf_model_mapping.items() if config.__name__ not in _TO_SKIP
|
||||
}
|
||||
|
||||
def get_test_pipeline(self, model, tokenizer, processor):
|
||||
token_classifier = TokenClassificationPipeline(model=model, tokenizer=tokenizer)
|
||||
|
|
|
|||
|
|
@ -36,9 +36,11 @@ class ZeroShotClassificationPipelineTests(unittest.TestCase):
|
|||
tf_model_mapping = TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
|
||||
|
||||
if model_mapping is not None:
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ not in _TO_SKIP}
|
||||
if tf_model_mapping is not None:
|
||||
tf_model_mapping = {config: model for config, model in tf_model_mapping.items() if config.__name__ in _TO_SKIP}
|
||||
tf_model_mapping = {
|
||||
config: model for config, model in tf_model_mapping.items() if config.__name__ not in _TO_SKIP
|
||||
}
|
||||
|
||||
def get_test_pipeline(self, model, tokenizer, processor):
|
||||
classifier = ZeroShotClassificationPipeline(
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ from .pipelines.test_pipelines_fill_mask import FillMaskPipelineTests
|
|||
from .pipelines.test_pipelines_image_classification import ImageClassificationPipelineTests
|
||||
from .pipelines.test_pipelines_image_segmentation import ImageSegmentationPipelineTests
|
||||
from .pipelines.test_pipelines_image_to_text import ImageToTextPipelineTests
|
||||
from .pipelines.test_pipelines_mask_generation import MaskGenerationPipelineTests
|
||||
from .pipelines.test_pipelines_object_detection import ObjectDetectionPipelineTests
|
||||
from .pipelines.test_pipelines_question_answering import QAPipelineTests
|
||||
from .pipelines.test_pipelines_summarization import SummarizationPipelineTests
|
||||
|
|
@ -68,6 +69,7 @@ pipeline_test_mapping = {
|
|||
"image-classification": {"test": ImageClassificationPipelineTests},
|
||||
"image-segmentation": {"test": ImageSegmentationPipelineTests},
|
||||
"image-to-text": {"test": ImageToTextPipelineTests},
|
||||
"mask-generation": {"test": MaskGenerationPipelineTests},
|
||||
"object-detection": {"test": ObjectDetectionPipelineTests},
|
||||
"question-answering": {"test": QAPipelineTests},
|
||||
"summarization": {"test": SummarizationPipelineTests},
|
||||
|
|
@ -355,6 +357,12 @@ class PipelineTesterMixin:
|
|||
def test_pipeline_image_to_text(self):
|
||||
self.run_task_tests(task="image-to-text")
|
||||
|
||||
@is_pipeline_test
|
||||
@require_vision
|
||||
@require_torch
|
||||
def test_pipeline_mask_generation(self):
|
||||
self.run_task_tests(task="mask-generation")
|
||||
|
||||
@is_pipeline_test
|
||||
@require_vision
|
||||
@require_timm
|
||||
|
|
|
|||
|
|
@ -2294,6 +2294,50 @@
|
|||
],
|
||||
"sha": "d6694b0d8fe17978761c9305dc151780506b192e"
|
||||
},
|
||||
"GPTBigCodeForCausalLM": {
|
||||
"tokenizer_classes": [
|
||||
"GPT2Tokenizer",
|
||||
"GPT2TokenizerFast"
|
||||
],
|
||||
"processor_classes": [],
|
||||
"model_classes": [
|
||||
"GPTBigCodeForCausalLM"
|
||||
],
|
||||
"sha": "99f7aaadf9c29669c63ef6c16f6bc5c07dbb9126"
|
||||
},
|
||||
"GPTBigCodeForSequenceClassification": {
|
||||
"tokenizer_classes": [
|
||||
"GPT2Tokenizer",
|
||||
"GPT2TokenizerFast"
|
||||
],
|
||||
"processor_classes": [],
|
||||
"model_classes": [
|
||||
"GPTBigCodeForSequenceClassification"
|
||||
],
|
||||
"sha": "64a7398d5763161037b818314c60dd83d93d03e9"
|
||||
},
|
||||
"GPTBigCodeForTokenClassification": {
|
||||
"tokenizer_classes": [
|
||||
"GPT2Tokenizer",
|
||||
"GPT2TokenizerFast"
|
||||
],
|
||||
"processor_classes": [],
|
||||
"model_classes": [
|
||||
"GPTBigCodeForTokenClassification"
|
||||
],
|
||||
"sha": "310537ecd22d45f71bf594b17922cf2abc338eaf"
|
||||
},
|
||||
"GPTBigCodeModel": {
|
||||
"tokenizer_classes": [
|
||||
"GPT2Tokenizer",
|
||||
"GPT2TokenizerFast"
|
||||
],
|
||||
"processor_classes": [],
|
||||
"model_classes": [
|
||||
"GPTBigCodeModel"
|
||||
],
|
||||
"sha": "3069419084a9dc36802d47de9df3d314ccfc2f28"
|
||||
},
|
||||
"GPTJForCausalLM": {
|
||||
"tokenizer_classes": [
|
||||
"GPT2Tokenizer",
|
||||
|
|
@ -2385,6 +2429,16 @@
|
|||
],
|
||||
"sha": "0229cfaaa843c6b492ac2abffabb00f1ff1936f8"
|
||||
},
|
||||
"GPTNeoXForSequenceClassification": {
|
||||
"tokenizer_classes": [
|
||||
"GPTNeoXTokenizerFast"
|
||||
],
|
||||
"processor_classes": [],
|
||||
"model_classes": [
|
||||
"GPTNeoXForSequenceClassification"
|
||||
],
|
||||
"sha": "17c4b845ee2e0bb780ca2dea2d59a3d9d5d3c651"
|
||||
},
|
||||
"GPTNeoXJapaneseForCausalLM": {
|
||||
"tokenizer_classes": [
|
||||
"GPTNeoXJapaneseTokenizer"
|
||||
|
|
@ -4940,6 +4994,16 @@
|
|||
],
|
||||
"sha": "0a0fbb844eeefa0dce62bd05db30a2bb91e5dc88"
|
||||
},
|
||||
"SamModel": {
|
||||
"tokenizer_classes": [],
|
||||
"processor_classes": [
|
||||
"SamImageProcessor"
|
||||
],
|
||||
"model_classes": [
|
||||
"SamModel"
|
||||
],
|
||||
"sha": "eca8651bc84e5ac3b1b62e784b744a6bd1b82575"
|
||||
},
|
||||
"SegformerForImageClassification": {
|
||||
"tokenizer_classes": [],
|
||||
"processor_classes": [
|
||||
|
|
|
|||
Loading…
Reference in a new issue