diff --git a/examples/classification/gpt_imdb_finetune.ipynb b/examples/classification/gpt_imdb_finetune.ipynb index a73b5f6a8..28d29ac4f 100644 --- a/examples/classification/gpt_imdb_finetune.ipynb +++ b/examples/classification/gpt_imdb_finetune.ipynb @@ -86,7 +86,7 @@ "source": [ "from mindnlp.transformers import GPTTokenizer\n", "# tokenizer\n", - "gpt_tokenizer = GPTTokenizer.from_pretrained('openai-gpt', from_pt=True)\n", + "gpt_tokenizer = GPTTokenizer.from_pretrained('openai-gpt')\n", "\n", "# add sepcial token: \n", "special_tokens_dict = {\n", @@ -137,7 +137,7 @@ "from mindspore.experimental.optim import Adam\n", "\n", "# set bert config and define parameters for training\n", - "model = GPTForSequenceClassification.from_pretrained('openai-gpt', from_pt=True, num_labels=2)\n", + "model = GPTForSequenceClassification.from_pretrained('openai-gpt', num_labels=2)\n", "model.config.pad_token_id = gpt_tokenizer.pad_token_id\n", "model.resize_token_embeddings(model.config.vocab_size + 3)\n", "\n", diff --git a/llm/finetune/graphormer/graphormer_finetune.py b/llm/finetune/graphormer/graphormer_finetune.py index c0b649d1d..6b8ce1b5f 100644 --- a/llm/finetune/graphormer/graphormer_finetune.py +++ b/llm/finetune/graphormer/graphormer_finetune.py @@ -69,7 +69,7 @@ def main(args): auto_load=True) # Load model - model = GraphormerForGraphClassification.from_pretrained("clefourrier/graphormer-base-pcqm4mv2", from_pt=True) + model = GraphormerForGraphClassification.from_pretrained("clefourrier/graphormer-base-pcqm4mv2") # Initiate the optimizer optimizer = nn.AdamWeightDecay(model.trainable_params(), diff --git a/llm/inference/chatglm2/cli_demo.py b/llm/inference/chatglm2/cli_demo.py index fc895929a..b6eb1b840 100644 --- a/llm/inference/chatglm2/cli_demo.py +++ b/llm/inference/chatglm2/cli_demo.py @@ -2,8 +2,8 @@ import platform from mindnlp.transformers import ChatGLM2Tokenizer, ChatGLM2ForConditionalGeneration -tokenizer = ChatGLM2Tokenizer.from_pretrained("THUDM/chatglm2-6b", from_pt=True) -model = ChatGLM2ForConditionalGeneration.from_pretrained("THUDM/chatglm2-6b", from_pt=True) +tokenizer = ChatGLM2Tokenizer.from_pretrained("THUDM/chatglm2-6b") +model = ChatGLM2ForConditionalGeneration.from_pretrained("THUDM/chatglm2-6b") model = model.set_train(False) os_name = platform.system() diff --git a/llm/inference/chatglm3/cli_demo.py b/llm/inference/chatglm3/cli_demo.py index f2bcdfe94..06e18fa22 100644 --- a/llm/inference/chatglm3/cli_demo.py +++ b/llm/inference/chatglm3/cli_demo.py @@ -2,8 +2,8 @@ import platform from mindnlp.transformers import ChatGLM3Tokenizer, ChatGLM3ForConditionalGeneration -tokenizer = ChatGLM3Tokenizer.from_pretrained("THUDM/chatglm3-6b", from_pt=True) -model = ChatGLM3ForConditionalGeneration.from_pretrained("THUDM/chatglm3-6b", from_pt=True) +tokenizer = ChatGLM3Tokenizer.from_pretrained("THUDM/chatglm3-6b") +model = ChatGLM3ForConditionalGeneration.from_pretrained("THUDM/chatglm3-6b") model = model.set_train(False) os_name = platform.system() diff --git a/llm/inference/pangu/pangu_generate.py b/llm/inference/pangu/pangu_generate.py index 82a205724..7e3fa6751 100644 --- a/llm/inference/pangu/pangu_generate.py +++ b/llm/inference/pangu/pangu_generate.py @@ -1,7 +1,7 @@ from mindnlp.transformers import AutoTokenizer, AutoModelForCausalLM -tokenizer = AutoTokenizer.from_pretrained("sunzeyeah/pangu-350M-sft", from_pt=True) -model = AutoModelForCausalLM.from_pretrained("sunzeyeah/pangu-350M-sft", from_pt=True) +tokenizer = AutoTokenizer.from_pretrained("sunzeyeah/pangu-350M-sft") +model = AutoModelForCausalLM.from_pretrained("sunzeyeah/pangu-350M-sft") prompt = "我不能确定对方是不是喜欢我,我却想分分秒秒跟他在一起,有谁能告诉我如何能想他少一点回答:" inputs = tokenizer(prompt, add_special_tokens=False, return_token_type_ids=False, return_tensors="ms") diff --git a/llm/inference/phi_2/streamlit_app.py b/llm/inference/phi_2/streamlit_app.py index 938efe975..e5e61ac35 100644 --- a/llm/inference/phi_2/streamlit_app.py +++ b/llm/inference/phi_2/streamlit_app.py @@ -4,12 +4,10 @@ # Load the Phi 2 model and tokenizer tokenizer = AutoTokenizer.from_pretrained( "microsoft/phi-2", - from_pt=True ) model = AutoModelForCausalLM.from_pretrained( "microsoft/phi-2", - from_pt=True ) # Streamlit UI diff --git a/mindnlp/transformers/modeling_utils.py b/mindnlp/transformers/modeling_utils.py index c518ffdc0..4311200c0 100644 --- a/mindnlp/transformers/modeling_utils.py +++ b/mindnlp/transformers/modeling_utils.py @@ -800,7 +800,7 @@ def from_pretrained( # pylint: disable=too-many-locals """from_pretrained""" state_dict = kwargs.pop("state_dict", None) cache_dir = kwargs.pop("cache_dir", None) - from_pt = kwargs.pop("from_pt", True) + _ = kwargs.pop("from_pt", True) force_download = kwargs.pop("force_download", False) resume_download = kwargs.pop("resume_download", False) proxies = kwargs.pop("proxies", None) @@ -839,7 +839,7 @@ def from_pretrained( # pylint: disable=too-many-locals pretrained_model_name_or_path = str(pretrained_model_name_or_path) is_local = os.path.isdir(pretrained_model_name_or_path) if is_local: - if from_pt and os.path.isfile( + if os.path.isfile( os.path.join(pretrained_model_name_or_path, subfolder, PT_WEIGHTS_NAME) ): # Load from a PyTorch checkpoint @@ -858,7 +858,7 @@ def from_pretrained( # pylint: disable=too-many-locals archive_file = os.path.join( pretrained_model_name_or_path, subfolder, _add_variant(SAFE_WEIGHTS_NAME, variant) ) - elif from_pt and os.path.isfile( + elif os.path.isfile( os.path.join(pretrained_model_name_or_path, subfolder, _add_variant(PT_WEIGHTS_INDEX_NAME, variant)) ): # Load from a sharded PyTorch checkpoint @@ -901,11 +901,12 @@ def from_pretrained( # pylint: disable=too-many-locals elif is_remote_url(pretrained_model_name_or_path): filename = pretrained_model_name_or_path resolved_archive_file = download_url(pretrained_model_name_or_path) - elif from_pt: + else: if use_safetensors is not False: filename = _add_variant(SAFE_WEIGHTS_NAME, variant) else: - filename = _add_variant(PT_WEIGHTS_NAME, variant) + filename = _add_variant(WEIGHTS_NAME, variant) + try: # Load from URL or cache if already cached cached_file_kwargs = { @@ -935,68 +936,30 @@ def from_pretrained( # pylint: disable=too-many-locals if resolved_archive_file is not None: is_sharded = True use_safetensors = True - else: - # This repo has no safetensors file of any kind, we switch to PyTorch. - filename = _add_variant(PT_WEIGHTS_NAME, variant) - resolved_archive_file = cached_file( - pretrained_model_name_or_path, filename, **cached_file_kwargs - ) if resolved_archive_file is None: - filename = _add_variant(PT_WEIGHTS_NAME, variant) + filename = _add_variant(WEIGHTS_NAME, variant) resolved_archive_file = cached_file(pretrained_model_name_or_path, filename, **cached_file_kwargs) - if resolved_archive_file is None and filename == _add_variant(PT_WEIGHTS_NAME, variant): + if resolved_archive_file is None and filename == _add_variant(WEIGHTS_NAME, variant): # Maybe the checkpoint is sharded, we try to grab the index name in this case. resolved_archive_file = cached_file( pretrained_model_name_or_path, - _add_variant(PT_WEIGHTS_INDEX_NAME, variant), + _add_variant(WEIGHTS_INDEX_NAME, variant), **cached_file_kwargs, ) if resolved_archive_file is not None: is_sharded = True if resolved_archive_file is None: - raise EnvironmentError( - f"{pretrained_model_name_or_path} does not appear to have a file named" - f" {_add_variant(SAFE_WEIGHTS_NAME, variant)}, {_add_variant(PT_WEIGHTS_NAME, variant)}" - ) - except EnvironmentError: - # Raise any environment error raise by `cached_file`. It will have a helpful error message adapted - # to the original exception. - raise - except Exception as exc: - # For any other exception, we throw a generic error. - raise EnvironmentError( - f"Can't load the model for '{pretrained_model_name_or_path}'. If you were trying to load it" - ", make sure you don't have a local directory with the" - f" same name. Otherwise, make sure '{pretrained_model_name_or_path}' is the correct path to a" - f" directory containing a file named {_add_variant(SAFE_WEIGHTS_NAME, variant)}," - f" {_add_variant(PT_WEIGHTS_NAME, variant)}." - ) from exc - else: - # set correct filename - filename = _add_variant(WEIGHTS_NAME, variant) - try: - # Load from URL or cache if already cached - cached_file_kwargs = { - "cache_dir": cache_dir, - "force_download": force_download, - "proxies": proxies, - "resume_download": resume_download, - "local_files_only": local_files_only, - "subfolder": subfolder, - "_raise_exceptions_for_missing_entries": False, - 'token': token - } - - resolved_archive_file = cached_file(pretrained_model_name_or_path, filename, **cached_file_kwargs) + filename = _add_variant(PT_WEIGHTS_NAME, variant) + resolved_archive_file = cached_file(pretrained_model_name_or_path, filename, **cached_file_kwargs) - if resolved_archive_file is None and filename == _add_variant(WEIGHTS_NAME, variant): + if resolved_archive_file is None and filename == _add_variant(PT_WEIGHTS_NAME, variant): # Maybe the checkpoint is sharded, we try to grab the index name in this case. resolved_archive_file = cached_file( pretrained_model_name_or_path, - _add_variant(WEIGHTS_INDEX_NAME, variant), + _add_variant(PT_WEIGHTS_INDEX_NAME, variant), **cached_file_kwargs, ) if resolved_archive_file is not None: @@ -1005,7 +968,7 @@ def from_pretrained( # pylint: disable=too-many-locals if resolved_archive_file is None: raise EnvironmentError( f"{pretrained_model_name_or_path} does not appear to have a file named" - f" {_add_variant(WEIGHTS_NAME, variant)}." + f" {_add_variant(SAFE_WEIGHTS_NAME, variant)}, {_add_variant(PT_WEIGHTS_NAME, variant)}" ) except EnvironmentError: # Raise any environment error raise by `cached_file`. It will have a helpful error message adapted @@ -1017,7 +980,8 @@ def from_pretrained( # pylint: disable=too-many-locals f"Can't load the model for '{pretrained_model_name_or_path}'. If you were trying to load it" ", make sure you don't have a local directory with the" f" same name. Otherwise, make sure '{pretrained_model_name_or_path}' is the correct path to a" - f" directory containing a file named {_add_variant(WEIGHTS_NAME, variant)}." + f" directory containing a file named {_add_variant(WEIGHTS_NAME, variant)}, {_add_variant(SAFE_WEIGHTS_NAME, variant)}," + f" {_add_variant(PT_WEIGHTS_NAME, variant)}." ) from exc if is_local: @@ -1091,8 +1055,8 @@ def empty_initializer(init, shape=None, dtype=mindspore.float32): # These are all the pointers of shared tensors. tied_params = [names for _, names in ptrs.items() if len(names) > 1] - def load_ckpt(resolved_archive_file, from_pt=False): - if from_pt and 'ckpt' not in resolved_archive_file: + def load_ckpt(resolved_archive_file): + if 'ckpt' not in resolved_archive_file: if use_safetensors: from safetensors.numpy import load_file origin_state_dict = load_file(resolved_archive_file) @@ -1214,14 +1178,14 @@ def load_param_into_net(model: nn.Cell, param_dict: dict, prefix: str): if is_sharded: all_keys_unexpected = [] for name in tqdm(converted_filenames, desc="Loading checkpoint shards"): - state_dict = load_ckpt(name, from_pt) + state_dict = load_ckpt(name) keys_unexpected, keys_missing = load_param_into_net(model, state_dict, cls.base_model_prefix) all_keys_unexpected.extend(keys_unexpected) del state_dict gc.collect() loaded_keys = sharded_metadata["all_checkpoint_keys"] else: - state_dict = load_ckpt(resolved_archive_file, from_pt) + state_dict = load_ckpt(resolved_archive_file) loaded_keys = list(state_dict.keys()) all_keys_unexpected, keys_missing = load_param_into_net(model, state_dict, cls.base_model_prefix) else: @@ -1266,7 +1230,6 @@ def load_param_into_net(model: nn.Cell, param_dict: dict, prefix: str): # Set model in evaluation mode to deactivate DropOut modules by default model.set_train(False) - kwargs['from_pt'] = from_pt # If it is a model with generation capabilities, attempt to load the generation config if model.can_generate() and pretrained_model_name_or_path is not None: try: diff --git a/mindnlp/transformers/models/auto/auto_factory.py b/mindnlp/transformers/models/auto/auto_factory.py index c0a4081ee..e1775d0f2 100644 --- a/mindnlp/transformers/models/auto/auto_factory.py +++ b/mindnlp/transformers/models/auto/auto_factory.py @@ -69,7 +69,7 @@ def from_config(cls, config, **kwargs): @classmethod def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs): config = kwargs.pop("config", None) - from_pt = kwargs.get('from_pt', True) + _ = kwargs.get('from_pt', True) token = kwargs.get('token', None) if not isinstance(config, PretrainedConfig): kwargs_orig = copy.deepcopy(kwargs) @@ -92,7 +92,6 @@ def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs): if kwargs_orig.get("quantization_config", None) is not None: kwargs["quantization_config"] = kwargs_orig["quantization_config"] - kwargs['from_pt'] = from_pt kwargs['token'] = token if type(config) in cls._model_mapping.keys(): model_class = _get_model_class(config, cls._model_mapping) diff --git a/mindnlp/transformers/models/auto/tokenization_auto.py b/mindnlp/transformers/models/auto/tokenization_auto.py index ae90c074c..20a9f99f1 100644 --- a/mindnlp/transformers/models/auto/tokenization_auto.py +++ b/mindnlp/transformers/models/auto/tokenization_auto.py @@ -27,7 +27,6 @@ from collections import OrderedDict from typing import Dict, Optional, Union -from mindnlp.configs import MS_URL_BASE, HF_URL_BASE from mindnlp.utils import cached_file, is_sentencepiece_available, is_tokenizers_available, logging from ...configuration_utils import PretrainedConfig, EncoderDecoderConfig from ...tokenization_utils import PreTrainedTokenizer # pylint: disable=cyclic-import @@ -553,8 +552,7 @@ def get_tokenizer_config( tokenizer_config = get_tokenizer_config("tokenizer-test") ```""" - from_pt = kwargs.get('from_pt', False) - endpoint = HF_URL_BASE if from_pt else MS_URL_BASE + _ = kwargs.get('from_pt', False) resolved_config_file = cached_file( pretrained_model_name_or_path, TOKENIZER_CONFIG_FILE, diff --git a/mindnlp/transformers/pipelines/base.py b/mindnlp/transformers/pipelines/base.py index 925277ec1..8673c20ef 100644 --- a/mindnlp/transformers/pipelines/base.py +++ b/mindnlp/transformers/pipelines/base.py @@ -230,8 +230,6 @@ def load_model( all_traceback = {} for model_class in class_tuple: kwargs = model_kwargs.copy() - if model.endswith(".bin") or model.endswith(".safetensors") or model.endswith(".pth"): - kwargs["from_pt"] = True try: model = model_class.from_pretrained(model, **kwargs) model = model.set_train(False) diff --git a/tests/ut/transformers/models/auto/test_configuration_auto.py b/tests/ut/transformers/models/auto/test_configuration_auto.py index 579e316ca..bb4201351 100644 --- a/tests/ut/transformers/models/auto/test_configuration_auto.py +++ b/tests/ut/transformers/models/auto/test_configuration_auto.py @@ -50,7 +50,7 @@ def test_config_model_type_from_local_file(self): self.assertIsInstance(config, RobertaConfig) def test_config_model_type_from_model_identifier(self): - config = AutoConfig.from_pretrained(DUMMY_UNKNOWN_IDENTIFIER, from_pt=True) + config = AutoConfig.from_pretrained(DUMMY_UNKNOWN_IDENTIFIER) self.assertIsInstance(config, RobertaConfig) def test_config_for_model_str(self): diff --git a/tests/ut/transformers/models/auto/test_modeling_auto.py b/tests/ut/transformers/models/auto/test_modeling_auto.py index 77267cbbb..9cde9787d 100644 --- a/tests/ut/transformers/models/auto/test_modeling_auto.py +++ b/tests/ut/transformers/models/auto/test_modeling_auto.py @@ -233,13 +233,13 @@ def test_token_classification_model_from_pretrained(self): def test_from_pretrained_identifier(self): - model = AutoModelWithLMHead.from_pretrained(SMALL_MODEL_IDENTIFIER, from_pt=True) + model = AutoModelWithLMHead.from_pretrained(SMALL_MODEL_IDENTIFIER) self.assertIsInstance(model, BertForMaskedLM) self.assertEqual(model.num_parameters(), 14410) self.assertEqual(model.num_parameters(only_trainable=True), 14410) def test_from_identifier_from_model_type(self): - model = AutoModelWithLMHead.from_pretrained(DUMMY_UNKNOWN_IDENTIFIER, from_pt=True) + model = AutoModelWithLMHead.from_pretrained(DUMMY_UNKNOWN_IDENTIFIER) self.assertIsInstance(model, RobertaForMaskedLM) self.assertEqual(model.num_parameters(), 14410) self.assertEqual(model.num_parameters(only_trainable=True), 14410) @@ -321,7 +321,7 @@ def test_model_file_not_found(self): with self.assertRaises( EnvironmentError, ): - _ = AutoModel.from_pretrained("hf-internal-testing/config-no-model", from_pt=True) + _ = AutoModel.from_pretrained("hf-internal-testing/config-no-model") # def test_cached_model_has_minimum_calls_to_head(self): # # Make sure we have cached the model. diff --git a/tests/ut/transformers/models/autoformer/test_modeling_autoformer.py b/tests/ut/transformers/models/autoformer/test_modeling_autoformer.py index aad4f8362..f7a78dbaf 100644 --- a/tests/ut/transformers/models/autoformer/test_modeling_autoformer.py +++ b/tests/ut/transformers/models/autoformer/test_modeling_autoformer.py @@ -420,7 +420,7 @@ class AutoformerModelIntegrationTests(unittest.TestCase): @unittest.skip('Mindspore cannot load torch .pt file.') def test_inference_no_head(self): model = AutoformerModel.from_pretrained( - "huggingface/autoformer-tourism-monthly",from_pt=True) + "huggingface/autoformer-tourism-monthly") batch = prepare_batch() output = model( @@ -446,7 +446,7 @@ def test_inference_no_head(self): @unittest.skip('Mindspore cannot load torch .pt file.') def test_inference_head(self): model = AutoformerForPrediction.from_pretrained( - "huggingface/autoformer-tourism-monthly", from_pt=True) + "huggingface/autoformer-tourism-monthly") batch = prepare_batch("val-batch.pt") output = model( past_values=batch["past_values"], @@ -466,7 +466,7 @@ def test_inference_head(self): @unittest.skip('Mindspore cannot load torch .pt file.') def test_seq_to_seq_generation(self): model = AutoformerForPrediction.from_pretrained( - "huggingface/autoformer-tourism-monthly", from_pt=True) + "huggingface/autoformer-tourism-monthly") batch = prepare_batch("val-batch.pt") outputs = model.generate( static_categorical_features=batch["static_categorical_features"], diff --git a/tests/ut/transformers/models/bart/test_modeling_bart.py b/tests/ut/transformers/models/bart/test_modeling_bart.py index 886afe759..6a2e2cedd 100644 --- a/tests/ut/transformers/models/bart/test_modeling_bart.py +++ b/tests/ut/transformers/models/bart/test_modeling_bart.py @@ -369,7 +369,7 @@ def test_shift_tokens_right(self): @slow def test_tokenization(self): - tokenizer = BartTokenizer.from_pretrained("facebook/bart-large", from_pt=True) + tokenizer = BartTokenizer.from_pretrained("facebook/bart-large") examples = [" Hello world", " DomDramg"] # need leading spaces for equality fairseq_results = [ mindspore.tensor([0, 20920, 232, 2]), @@ -537,11 +537,11 @@ class FastIntegrationTests(unittest.TestCase): @cached_property def tok(self): - return BartTokenizer.from_pretrained("facebook/bart-large", from_pt=True) + return BartTokenizer.from_pretrained("facebook/bart-large") @cached_property def xsum_1_1_model(self): - return BartForConditionalGeneration.from_pretrained("sshleifer/distilbart-xsum-1-1", from_pt=True) + return BartForConditionalGeneration.from_pretrained("sshleifer/distilbart-xsum-1-1") def test_xsum_1_1_generation(self): hf = self.xsum_1_1_model @@ -854,11 +854,11 @@ def test_encoder_equiv(self): class BartModelIntegrationTests(unittest.TestCase): @cached_property def default_tokenizer(self): - return BartTokenizer.from_pretrained("facebook/bart-large", from_pt=True) + return BartTokenizer.from_pretrained("facebook/bart-large") @slow def test_inference_no_head(self): - model = BartModel.from_pretrained("facebook/bart-large", from_pt=True) + model = BartModel.from_pretrained("facebook/bart-large") input_ids = _long_tensor([[0, 31414, 232, 328, 740, 1140, 12695, 69, 46078, 1588, 2]]) attention_mask = input_ids.ne(model.config.pad_token_id) output = model(input_ids=input_ids, attention_mask=attention_mask).last_hidden_state @@ -890,7 +890,7 @@ def test_mnli_inference(self): example_b = [0, 31414, 232, 328, 740, 1140, 69, 46078, 1588, 2, 1] input_ids = _long_tensor([[0, 31414, 232, 328, 740, 1140, 12695, 69, 46078, 1588, 2], example_b]) - model = AutoModelForSequenceClassification.from_pretrained("facebook/bart-large-mnli", from_pt=True) + model = AutoModelForSequenceClassification.from_pretrained("facebook/bart-large-mnli") # eval called in from_pre attention_mask = input_ids.ne(model.config.pad_token_id) # Test that model hasn't changed @@ -912,7 +912,7 @@ def test_mnli_inference(self): @slow def test_xsum_summarization_same_as_fairseq(self): - model = BartForConditionalGeneration.from_pretrained("facebook/bart-large-xsum", from_pt=True) + model = BartForConditionalGeneration.from_pretrained("facebook/bart-large-xsum") tok = self.default_tokenizer PGE_ARTICLE = """ PG&E stated it scheduled the blackouts in response to forecasts for high winds amid dry conditions. The aim is to reduce the risk of wildfires. Nearly 800 thousand customers were scheduled to be affected by the shutoffs which were expected to last through at least midday tomorrow.""" @@ -948,15 +948,15 @@ def test_xsum_summarization_same_as_fairseq(self): self.assertEqual(EXPECTED_SUMMARY, decoded[0]) def test_xsum_config_generation_params(self): - config = BartConfig.from_pretrained("facebook/bart-large-xsum", from_pt=True) + config = BartConfig.from_pretrained("facebook/bart-large-xsum") expected_params = {"num_beams": 6, "do_sample": False, "early_stopping": True, "length_penalty": 1.0} config_params = {k: getattr(config, k, "MISSING") for k, v in expected_params.items()} self.assertDictEqual(expected_params, config_params) @slow def test_cnn_summarization_same_as_fairseq(self): - hf = BartForConditionalGeneration.from_pretrained("facebook/bart-large-cnn", from_pt=True) - tok = BartTokenizer.from_pretrained("facebook/bart-large", from_pt=True) + hf = BartForConditionalGeneration.from_pretrained("facebook/bart-large-cnn") + tok = BartTokenizer.from_pretrained("facebook/bart-large") FRANCE_ARTICLE = ( # @noq " Marseille, France (CNN)The French prosecutor leading an investigation into the crash of Germanwings" @@ -1217,8 +1217,8 @@ def test_contrastive_search_bart(self): " native Pakistan after an investigation by the Joint Terrorism Task Force. If convicted, Barrientos faces" " up to four years in prison. Her next court appearance is scheduled for May 18." ) - bart_tokenizer = BartTokenizer.from_pretrained("facebook/bart-large-cnn", from_pt=True) - bart_model = BartForConditionalGeneration.from_pretrained("facebook/bart-large-cnn", from_pt=True) + bart_tokenizer = BartTokenizer.from_pretrained("facebook/bart-large-cnn") + bart_model = BartForConditionalGeneration.from_pretrained("facebook/bart-large-cnn") input_ids = bart_tokenizer( article, add_special_tokens=False, truncation=True, max_length=512, return_tensors="ms" ).input_ids @@ -1238,7 +1238,7 @@ def test_contrastive_search_bart(self): @slow def test_decoder_attention_mask(self): - model = BartForConditionalGeneration.from_pretrained("facebook/bart-large", forced_bos_token_id=0, from_pt=True) + model = BartForConditionalGeneration.from_pretrained("facebook/bart-large", forced_bos_token_id=0) tokenizer = self.default_tokenizer sentence = "UN Chief Says There Is No in Syria" input_ids = tokenizer(sentence, return_tensors="ms").input_ids diff --git a/tests/ut/transformers/models/bert/test_modeling_bert.py b/tests/ut/transformers/models/bert/test_modeling_bert.py index 5abafa779..11e087eaf 100644 --- a/tests/ut/transformers/models/bert/test_modeling_bert.py +++ b/tests/ut/transformers/models/bert/test_modeling_bert.py @@ -617,7 +617,7 @@ def test_inference_no_head_absolute_embedding(self): @slow def test_inference_no_head_relative_embedding_key(self): - model = BertModel.from_pretrained("zhiheng-huang/bert-base-uncased-embedding-relative-key", from_pt=True) + model = BertModel.from_pretrained("zhiheng-huang/bert-base-uncased-embedding-relative-key") input_ids = mindspore.tensor([[0, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 2]]) attention_mask = mindspore.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) output = model(input_ids, attention_mask=attention_mask)[0] @@ -631,7 +631,7 @@ def test_inference_no_head_relative_embedding_key(self): @slow def test_inference_no_head_relative_embedding_key_query(self): - model = BertModel.from_pretrained("zhiheng-huang/bert-base-uncased-embedding-relative-key-query", from_pt=True) + model = BertModel.from_pretrained("zhiheng-huang/bert-base-uncased-embedding-relative-key-query") input_ids = mindspore.tensor([[0, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 2]]) attention_mask = mindspore.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) output = model(input_ids, attention_mask=attention_mask)[0] diff --git a/tests/ut/transformers/models/bert/test_tokenization_bert.py b/tests/ut/transformers/models/bert/test_tokenization_bert.py index 7d6346245..5c78e0fbc 100644 --- a/tests/ut/transformers/models/bert/test_tokenization_bert.py +++ b/tests/ut/transformers/models/bert/test_tokenization_bert.py @@ -341,14 +341,3 @@ def test_change_tokenize_chinese_chars(self): ] self.assertListEqual(tokens_without_spe_char_p, expected_tokens) self.assertListEqual(tokens_without_spe_char_r, expected_tokens) - - def test_bert_tokenizer_with_ms_dataset(self): - """test BertTokenizer from pretrained.""" - texts = ['i make a small mistake when i\'m working! 床前明月光'] - test_dataset = GeneratorDataset(texts, 'text') - - bert_tokenizer = BertTokenizer.from_pretrained('bert-base-chinese') - test_dataset = test_dataset.map(operations=bert_tokenizer, input_columns='text', output_columns=['input_ids', 'token_type_ids', 'attention_mask']) - dataset_after = next(test_dataset.create_tuple_iterator())[0] - - assert len(dataset_after) == 21 diff --git a/tests/ut/transformers/models/bloom/test_modeling_bloom.py b/tests/ut/transformers/models/bloom/test_modeling_bloom.py index ed8a8029e..b8a18ac68 100644 --- a/tests/ut/transformers/models/bloom/test_modeling_bloom.py +++ b/tests/ut/transformers/models/bloom/test_modeling_bloom.py @@ -95,7 +95,7 @@ def __init__( self.pad_token_id = vocab_size - 1 def get_large_model_config(self): - return BloomConfig.from_pretrained("bigscience/bloom", from_pt=True) + return BloomConfig.from_pretrained("bigscience/bloom") def prepare_config_and_inputs(self, gradient_checkpointing=False): input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size) @@ -386,7 +386,7 @@ def test_past_key_values_format(self): @slow def test_model_from_pretrained(self): for model_name in BLOOM_PRETRAINED_MODEL_ARCHIVE_LIST[:1]: - model = BloomModel.from_pretrained(model_name, from_pt=True) + model = BloomModel.from_pretrained(model_name) self.assertIsNotNone(model) @slow @@ -411,9 +411,9 @@ def test_simple_generation(self): # >=1b1 + allow_fp16_reduced_precision_reduction = False + torch.bmm ==> PASS path_560m = "bigscience/bloom-560m" - model = BloomForCausalLM.from_pretrained(path_560m, use_cache=True, from_pt=True) + model = BloomForCausalLM.from_pretrained(path_560m, use_cache=True) model = model.set_train(False) - tokenizer = BloomTokenizerFast.from_pretrained(path_560m, from_pt=True) + tokenizer = BloomTokenizerFast.from_pretrained(path_560m) input_sentence = "I enjoy walking with my cute dog" # This output has been obtained using fp32 model on the huggingface DGX workstation - NVIDIA A100 GPU @@ -430,9 +430,9 @@ def test_simple_generation(self): @slow def test_batch_generation(self): path_560m = "bigscience/bloom-560m" - model = BloomForCausalLM.from_pretrained(path_560m, use_cache=True, from_pt=True) + model = BloomForCausalLM.from_pretrained(path_560m, use_cache=True) model = model.set_train(False) - tokenizer = BloomTokenizerFast.from_pretrained(path_560m, padding_side="left", from_pt=True) + tokenizer = BloomTokenizerFast.from_pretrained(path_560m, padding_side="left") input_sentence = ["I enjoy walking with my cute dog", "I enjoy walking with my cute dog"] @@ -449,9 +449,9 @@ def test_batch_generation(self): @slow def test_batch_generation_padd(self): path_560m = "bigscience/bloom-560m" - model = BloomForCausalLM.from_pretrained(path_560m, use_cache=True, from_pt=True) + model = BloomForCausalLM.from_pretrained(path_560m, use_cache=True) model = model.set_train(False) - tokenizer = BloomTokenizerFast.from_pretrained(path_560m, padding_side="left", from_pt=True) + tokenizer = BloomTokenizerFast.from_pretrained(path_560m, padding_side="left") input_sentence = ["I enjoy walking with my cute dog", "Hello my name is"] input_sentence_without_pad = "Hello my name is" @@ -478,9 +478,9 @@ def test_batch_generation_padd(self): def test_batch_generated_text(self): path_560m = "bigscience/bloom-560m" - model = BloomForCausalLM.from_pretrained(path_560m, use_cache=True, from_pt=True) + model = BloomForCausalLM.from_pretrained(path_560m, use_cache=True) model = model.set_train(False) - tokenizer = BloomTokenizerFast.from_pretrained(path_560m, padding_side="left", from_pt=True) + tokenizer = BloomTokenizerFast.from_pretrained(path_560m, padding_side="left") input_sentences = [ "Hello what is", @@ -531,7 +531,7 @@ def setUp(self): @require_mindspore def test_embeddings(self): # The config in this checkpoint has `bfloat16` as `torch_dtype` -> model in `bfloat16` - model = BloomForCausalLM.from_pretrained(self.path_bigscience_model, ms_dtype="auto", from_pt=True) + model = BloomForCausalLM.from_pretrained(self.path_bigscience_model, ms_dtype="auto") model.set_train(False) EMBEDDINGS_DS_BEFORE_LN_BF_16_MEAN = { @@ -758,7 +758,7 @@ def test_embeddings(self): @require_mindspore def test_hidden_states_transformers(self): - model = BloomModel.from_pretrained(self.path_bigscience_model, use_cache=False, ms_dtype="auto", from_pt=True) + model = BloomModel.from_pretrained(self.path_bigscience_model, use_cache=False, ms_dtype="auto") model.set_train(False) EXAMPLE_IDS = [3478, 368, 109586, 35433, 2, 77, 132619, 3478, 368, 109586, 35433, 2, 2175, 23714, 73173, 144252, 2, 77, 132619, 3478] # fmt: skip @@ -779,7 +779,7 @@ def test_hidden_states_transformers(self): @require_mindspore def test_logits(self): - model = BloomForCausalLM.from_pretrained(self.path_bigscience_model, use_cache=False, ms_dtype="auto", from_pt=True)# load in bf16 + model = BloomForCausalLM.from_pretrained(self.path_bigscience_model, use_cache=False, ms_dtype="auto")# load in bf16 model.set_train(False) EXAMPLE_IDS = [3478, 368, 109586, 35433, 2, 77, 132619, 3478, 368, 109586, 35433, 2, 2175, 23714, 73173, 144252, 2, 77, 132619, 3478] # fmt: skip diff --git a/tests/ut/transformers/models/chatglm/test_modeling_chatglm.py b/tests/ut/transformers/models/chatglm/test_modeling_chatglm.py index 7fb066f22..796528bb7 100644 --- a/tests/ut/transformers/models/chatglm/test_modeling_chatglm.py +++ b/tests/ut/transformers/models/chatglm/test_modeling_chatglm.py @@ -56,23 +56,6 @@ class ChatGLMGenerationTest(unittest.TestCase): def get_generation_kwargs(self): pass - @slow - def test_chat_random_init(self): - model, tokenizer = get_model_and_tokenizer_random_init() - prompts = ["你好", "介绍一下清华大学", "它创建于哪一年"] - history = [] - set_random_seed(42) - expected_responses = [ - '你好👋!我是人工智能助手 ChatGLM-6B,很高兴见到你,欢迎问我任何问题。', - '清华大学是中国著名的综合性研究型大学,位于中国北京市海淀区,创建于 1911 年,前身是清华学堂。作为我国顶尖高等教育机构之一,清华大学在科学研究、工程技术、信息技术、经济管理等领域处于领先地位,也是世界上最著名的工程学府之一。\n\n清华大学拥有世界一流的教学设施和科学研究平台,设有多个学院和研究中心,包括工程学院、自然科学学院、社会科学学院、人文学院、法学院、经济管理学院等。学校拥有众多知名教授和研究团队,其中包括多位院士、国家杰出青年科学基金获得者、长江学者等。\n\n清华大学的本科生招生范围为全国中学毕业生,本科生入学要求严格,考试成绩优秀。同时,清华大学也提供研究生和博士生招生,包括硕士研究生和博士研究生。', - '清华大学创建于 1911 年。' - ] - for (prompt, expected_response) in zip(prompts, expected_responses): - response, history = model.chat(tokenizer, prompt, history=history, max_length=20) - print(repr(response)) - break - self.assertEquals(expected_response, response) - @slow def test_chat(self): model, tokenizer = get_model_and_tokenizer() diff --git a/tests/ut/transformers/models/ernie/test_modeling_ernie.py b/tests/ut/transformers/models/ernie/test_modeling_ernie.py index bd0fe681e..0e2a16b79 100644 --- a/tests/ut/transformers/models/ernie/test_modeling_ernie.py +++ b/tests/ut/transformers/models/ernie/test_modeling_ernie.py @@ -568,5 +568,5 @@ def test_for_token_classification(self): @slow def test_model_from_pretrained(self): for model_name in ERNIE_PRETRAINED_MODEL_ARCHIVE_LIST[:1]: - model = ErnieModel.from_pretrained(model_name, from_pt=True) + model = ErnieModel.from_pretrained(model_name) self.assertIsNotNone(model) diff --git a/tests/ut/transformers/models/ernie_m/test_modeling_ernie_m.py b/tests/ut/transformers/models/ernie_m/test_modeling_ernie_m.py index 8edca4b4f..696976b36 100644 --- a/tests/ut/transformers/models/ernie_m/test_modeling_ernie_m.py +++ b/tests/ut/transformers/models/ernie_m/test_modeling_ernie_m.py @@ -305,7 +305,7 @@ def test_model_from_pretrained(self): class ErnieMModelIntegrationTest(unittest.TestCase): @slow def test_inference_model(self): - model = ErnieMModel.from_pretrained("susnato/ernie-m-base_pytorch", from_pt=True) + model = ErnieMModel.from_pretrained("susnato/ernie-m-base_pytorch") model.set_train(False) input_ids = mindspore.tensor([[0, 1, 2, 3, 4, 5]]) output = model(input_ids)[0] diff --git a/tests/ut/transformers/models/falcon/test_modeling_falcon.py b/tests/ut/transformers/models/falcon/test_modeling_falcon.py index 2a0213066..a4bd6c8e2 100644 --- a/tests/ut/transformers/models/falcon/test_modeling_falcon.py +++ b/tests/ut/transformers/models/falcon/test_modeling_falcon.py @@ -518,8 +518,8 @@ def test_model_rope_scaling(self, scaling_type): class FalconLanguageGenerationTest(unittest.TestCase): @slow def test_lm_generate_falcon(self): - tokenizer = AutoTokenizer.from_pretrained("Rocketknight1/falcon-rw-1b", from_pt=True) - model = FalconForCausalLM.from_pretrained("Rocketknight1/falcon-rw-1b", from_pt=True) + tokenizer = AutoTokenizer.from_pretrained("Rocketknight1/falcon-rw-1b") + model = FalconForCausalLM.from_pretrained("Rocketknight1/falcon-rw-1b") model.set_train(False) inputs = tokenizer("My favorite food is", return_tensors="ms") @@ -538,8 +538,8 @@ def test_lm_generation_big_models(self): "Rocketknight1/tiny-random-falcon-7b", "Rocketknight1/tiny-random-falcon-40b", ]: - tokenizer = AutoTokenizer.from_pretrained(repo, from_pt=True) - model = FalconForCausalLM.from_pretrained(repo, from_pt=True) + tokenizer = AutoTokenizer.from_pretrained(repo) + model = FalconForCausalLM.from_pretrained(repo) model.set_train(False) inputs = tokenizer("My favorite food is", return_tensors="ms") @@ -559,8 +559,8 @@ def test_lm_generation_use_cache(self): "Rocketknight1/tiny-random-falcon-7b", "Rocketknight1/tiny-random-falcon-40b", ]: - tokenizer = AutoTokenizer.from_pretrained(repo, from_pt=True) - model = FalconForCausalLM.from_pretrained(repo, from_pt=True) + tokenizer = AutoTokenizer.from_pretrained(repo) + model = FalconForCausalLM.from_pretrained(repo) model.set_train(False) inputs = tokenizer("My favorite food is", return_tensors="ms") @@ -576,12 +576,11 @@ def test_lm_generation_use_cache(self): @slow def test_batched_generation(self): tokenizer = AutoTokenizer.from_pretrained( - "tiiuae/falcon-7b", padding_side="left", from_pt=True + "tiiuae/falcon-7b", padding_side="left" ) tokenizer.pad_token = tokenizer.eos_token model = AutoModelForCausalLM.from_pretrained( "tiiuae/falcon-7b", - from_pt=True, ) test_text = "A sequence: 1, 2" # should generate the rest of the sequence diff --git a/tests/ut/transformers/models/graphormer/test_modeling_graphormer.py b/tests/ut/transformers/models/graphormer/test_modeling_graphormer.py index a034c63da..df59c54a8 100644 --- a/tests/ut/transformers/models/graphormer/test_modeling_graphormer.py +++ b/tests/ut/transformers/models/graphormer/test_modeling_graphormer.py @@ -459,15 +459,14 @@ def test_for_graph_classification(self): @slow def test_model_from_pretrained(self): for model_name in GRAPHORMER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]: - model = GraphormerForGraphClassification.from_pretrained(model_name, from_pt=True) + model = GraphormerForGraphClassification.from_pretrained(model_name) self.assertIsNotNone(model) @require_mindspore class GraphormerModelIntegrationTest(unittest.TestCase): @slow def test_inference_graph_classification(self): - model = GraphormerForGraphClassification.from_pretrained("clefourrier/graphormer-base-pcqm4mv2", - from_pt=True) + model = GraphormerForGraphClassification.from_pretrained("clefourrier/graphormer-base-pcqm4mv2") # Actual real graph data from the MUTAG dataset # fmt: off diff --git a/tests/ut/transformers/models/hubert/test_modeling_hubert.py b/tests/ut/transformers/models/hubert/test_modeling_hubert.py index d4a9193fc..39716611c 100644 --- a/tests/ut/transformers/models/hubert/test_modeling_hubert.py +++ b/tests/ut/transformers/models/hubert/test_modeling_hubert.py @@ -391,7 +391,7 @@ def test_feed_forward_chunking(self): @slow def test_model_from_pretrained(self): - model = HubertModel.from_pretrained("facebook/hubert-base-ls960", from_pt=True) + model = HubertModel.from_pretrained("facebook/hubert-base-ls960") self.assertIsNotNone(model) @@ -491,7 +491,7 @@ def test_feed_forward_chunking(self): @slow def test_model_from_pretrained(self): - model = HubertModel.from_pretrained("facebook/hubert-large-ls960-ft", from_pt=True) + model = HubertModel.from_pretrained("facebook/hubert-large-ls960-ft") self.assertIsNotNone(model) @@ -538,8 +538,8 @@ def _load_superb(self, task, num_samples): return ds[:num_samples] def test_inference_ctc_batched(self): - model = HubertForCTC.from_pretrained("facebook/hubert-large-ls960-ft", from_pt=True).half() - processor = Wav2Vec2Processor.from_pretrained("facebook/hubert-large-ls960-ft", from_pt=True, do_lower_case=True) + model = HubertForCTC.from_pretrained("facebook/hubert-large-ls960-ft").half() + processor = Wav2Vec2Processor.from_pretrained("facebook/hubert-large-ls960-ft", do_lower_case=True) input_speech = self._load_datasamples(2) inputs = processor(input_speech, return_tensors="ms", padding=True) @@ -560,8 +560,8 @@ def test_inference_ctc_batched(self): def test_inference_keyword_spotting(self): # NOTE: 原仓库代码用 float16 的精度也过不了测试 :( - model = HubertForSequenceClassification.from_pretrained("superb/hubert-base-superb-ks", from_pt=True)#.half() - processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-base-superb-ks", from_pt=True) + model = HubertForSequenceClassification.from_pretrained("superb/hubert-base-superb-ks")#.half() + processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-base-superb-ks") input_data = self._load_superb("ks", 4) inputs = processor(input_data["speech"], return_tensors="ms", padding=True) @@ -578,8 +578,8 @@ def test_inference_keyword_spotting(self): self.assertTrue(mnp.allclose(predicted_logits, expected_logits, atol=3e-2)) def test_inference_intent_classification(self): - model = HubertForSequenceClassification.from_pretrained("superb/hubert-base-superb-ic", from_pt=True).half() - processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-base-superb-ic", from_pt=True) + model = HubertForSequenceClassification.from_pretrained("superb/hubert-base-superb-ic").half() + processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-base-superb-ic") input_data = self._load_superb("ic", 4) inputs = processor(input_data["speech"], return_tensors="ms", padding=True) @@ -609,8 +609,8 @@ def test_inference_intent_classification(self): def test_inference_speaker_identification(self): # NOTE: 原仓库代码用 float16 的精度也过不了测试 :( - model = HubertForSequenceClassification.from_pretrained("superb/hubert-base-superb-sid", from_pt=True)#.half() - processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-base-superb-sid", from_pt=True) + model = HubertForSequenceClassification.from_pretrained("superb/hubert-base-superb-sid")#.half() + processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-base-superb-sid") input_data = self._load_superb("si", 4) output_logits = [] @@ -632,8 +632,8 @@ def test_inference_speaker_identification(self): self.assertTrue(mnp.allclose(predicted_logits, expected_logits, atol=10)) def test_inference_emotion_recognition(self): - model = HubertForSequenceClassification.from_pretrained("superb/hubert-base-superb-er", from_pt=True).half() - processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-base-superb-er", from_pt=True) + model = HubertForSequenceClassification.from_pretrained("superb/hubert-base-superb-er").half() + processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-base-superb-er") input_data = self._load_superb("er", 4) inputs = processor(input_data["speech"], return_tensors="ms", padding=True) @@ -651,8 +651,8 @@ def test_inference_emotion_recognition(self): self.assertTrue(mnp.allclose(predicted_logits, expected_logits, atol=1e-1)) def test_inference_distilhubert(self): - model = HubertModel.from_pretrained("ntu-spml/distilhubert", from_pt=True).half() - processor = Wav2Vec2FeatureExtractor.from_pretrained("ntu-spml/distilhubert", from_pt=True) + model = HubertModel.from_pretrained("ntu-spml/distilhubert").half() + processor = Wav2Vec2FeatureExtractor.from_pretrained("ntu-spml/distilhubert") # TODO: can't test on batched inputs due to incompatible padding https://github.com/pytorch/fairseq/pull/3572 input_speech = self._load_datasamples(1) diff --git a/tests/ut/transformers/models/llama/test_modeling_llama.py b/tests/ut/transformers/models/llama/test_modeling_llama.py index fa4ed9f04..fc6a79bf2 100644 --- a/tests/ut/transformers/models/llama/test_modeling_llama.py +++ b/tests/ut/transformers/models/llama/test_modeling_llama.py @@ -388,9 +388,9 @@ def test_generate_padding_right(self): """ Overwritting the common test as the test is flaky on tiny models """ - model = LlamaForCausalLM.from_pretrained("meta-llama/Llama-2-7b-hf", from_pt=True) + model = LlamaForCausalLM.from_pretrained("meta-llama/Llama-2-7b-hf") - tokenizer = LlamaTokenizer.from_pretrained("meta-llama/Llama-2-7b-hf", from_pt=True) + tokenizer = LlamaTokenizer.from_pretrained("meta-llama/Llama-2-7b-hf") texts = ["hi", "Hello this is a very long sentence"] @@ -529,8 +529,8 @@ def main(): @unittest.skip('do not have enough memory.') @slow def test_model_7b_logits(self): - model = LlamaForCausalLM.from_pretrained("codellama/CodeLlama-7b-hf", from_pt=True) - tokenizer = CodeLlamaTokenizer.from_pretrained("codellama/CodeLlama-7b-hf", from_pt=True) + model = LlamaForCausalLM.from_pretrained("codellama/CodeLlama-7b-hf") + tokenizer = CodeLlamaTokenizer.from_pretrained("codellama/CodeLlama-7b-hf") # Tokenize and prepare for the model a list of sequences or a list of pairs of sequences. # meaning by default this supports passing splitted list of inputs processed_text = tokenizer.batch_decode(tokenizer(self.PROMPTS)["input_ids"], add_special_tokens=False) diff --git a/tests/ut/transformers/models/longformer/test_modeling_longformer.py b/tests/ut/transformers/models/longformer/test_modeling_longformer.py index 382ddf74a..bc20752b0 100644 --- a/tests/ut/transformers/models/longformer/test_modeling_longformer.py +++ b/tests/ut/transformers/models/longformer/test_modeling_longformer.py @@ -530,7 +530,7 @@ def test_mask_invalid_locations(self): self.assertTrue(ops.isinf(hid_states_4).sum().item() == 12) def test_layer_local_attn(self): - model = LongformerModel.from_pretrained("patrickvonplaten/longformer-random-tiny", from_pt=True) + model = LongformerModel.from_pretrained("patrickvonplaten/longformer-random-tiny") model.set_train(False) layer = model.encoder.layer[0].attention.self hidden_states = self._get_hidden_states() @@ -563,7 +563,7 @@ def test_layer_local_attn(self): ) def test_layer_global_attn(self): - model = LongformerModel.from_pretrained("patrickvonplaten/longformer-random-tiny", from_pt=True) + model = LongformerModel.from_pretrained("patrickvonplaten/longformer-random-tiny") model.set_train(False) layer = model.encoder.layer[0].attention.self hidden_states = ops.cat([self._get_hidden_states(), self._get_hidden_states() - 0.5], axis=0) @@ -612,7 +612,7 @@ def test_layer_global_attn(self): ) def test_layer_attn_probs(self): - model = LongformerModel.from_pretrained("patrickvonplaten/longformer-random-tiny", from_pt=True) + model = LongformerModel.from_pretrained("patrickvonplaten/longformer-random-tiny") model.set_train(False) layer = model.encoder.layer[0].attention.self hidden_states = ops.cat([self._get_hidden_states(), self._get_hidden_states() - 0.5], axis=0) @@ -697,7 +697,7 @@ def test_layer_attn_probs(self): @slow def test_inference_no_head(self): - model = LongformerModel.from_pretrained("allenai/longformer-base-4096", from_pt=True) + model = LongformerModel.from_pretrained("allenai/longformer-base-4096") # 'Hello world!' @@ -713,7 +713,7 @@ def test_inference_no_head(self): @slow def test_inference_no_head_long(self): - model = LongformerModel.from_pretrained("allenai/longformer-base-4096", from_pt=True) + model = LongformerModel.from_pretrained("allenai/longformer-base-4096") # 'Hello world! ' repeated 1000 times @@ -734,7 +734,7 @@ def test_inference_no_head_long(self): @slow def test_inference_masked_lm_long(self): - model = LongformerForMaskedLM.from_pretrained("allenai/longformer-base-4096", from_pt=True) + model = LongformerForMaskedLM.from_pretrained("allenai/longformer-base-4096") # 'Hello world! ' repeated 1000 times diff --git a/tests/ut/transformers/models/mbart/test_modeling_mbart.py b/tests/ut/transformers/models/mbart/test_modeling_mbart.py index e3ad9230a..d5c2b4660 100644 --- a/tests/ut/transformers/models/mbart/test_modeling_mbart.py +++ b/tests/ut/transformers/models/mbart/test_modeling_mbart.py @@ -398,13 +398,13 @@ class AbstractSeq2SeqIntegrationTest(unittest.TestCase): @classmethod def setUpClass(cls): - cls.tokenizer = AutoTokenizer.from_pretrained(cls.checkpoint_name, use_fast=False, from_pt=True) + cls.tokenizer = AutoTokenizer.from_pretrained(cls.checkpoint_name, use_fast=False) return cls @cached_property def model(self): """Only load the model if needed.""" - model = MBartForConditionalGeneration.from_pretrained(self.checkpoint_name, from_pt=True) + model = MBartForConditionalGeneration.from_pretrained(self.checkpoint_name) model = model.half() return model @@ -445,7 +445,7 @@ def test_mbart_enro_config(self): mbart_models = ["facebook/mbart-large-en-ro"] expected = {"scale_embedding": True, "output_past": True} for name in mbart_models: - config = MBartConfig.from_pretrained(name, from_pt=True) + config = MBartConfig.from_pretrained(name) for k, v in expected.items(): try: self.assertEqual(v, getattr(config, k)) diff --git a/tests/ut/transformers/models/megatron_bert/test_modeling_megatron_bert.py b/tests/ut/transformers/models/megatron_bert/test_modeling_megatron_bert.py index c3dabd7f6..b39624d0d 100644 --- a/tests/ut/transformers/models/megatron_bert/test_modeling_megatron_bert.py +++ b/tests/ut/transformers/models/megatron_bert/test_modeling_megatron_bert.py @@ -370,7 +370,7 @@ def test_inference_no_head(self): directory = "nvidia/megatron-bert-uncased-345m" if "MYDIR" in os.environ: directory = os.path.join(os.environ["MYDIR"], directory) - model = MegatronBertModel.from_pretrained(directory, from_pt=True) + model = MegatronBertModel.from_pretrained(directory) model.half() input_ids = _long_tensor([[101, 7110, 1005, 1056, 2023, 11333, 17413, 1029, 102]]) diff --git a/tests/ut/transformers/models/mistral/test_modeling_mistral.py b/tests/ut/transformers/models/mistral/test_modeling_mistral.py index 9dc84215d..bd58e85ec 100644 --- a/tests/ut/transformers/models/mistral/test_modeling_mistral.py +++ b/tests/ut/transformers/models/mistral/test_modeling_mistral.py @@ -377,7 +377,7 @@ class MistralIntegrationTest(unittest.TestCase): @slow def test_model_7b_logits(self): input_ids = [1, 306, 4658, 278, 6593, 310, 2834, 338] - model = MistralForCausalLM.from_pretrained("mistralai/Mistral-7B-v0.1", from_pt=True) + model = MistralForCausalLM.from_pretrained("mistralai/Mistral-7B-v0.1") input_ids = mindspore.tensor([input_ids]) out = model(input_ids).logits # Expected mean on dim = -1 @@ -393,8 +393,8 @@ def test_model_7b_logits(self): def test_model_7b_generation(self): EXPECTED_TEXT_COMPLETION = """My favourite condiment is 100% ketchup. I love it on everything. I’m not a big""" prompt = "My favourite condiment is " - tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-v0.1", use_fast=False, from_pt=True) - model = MistralForCausalLM.from_pretrained("mistralai/Mistral-7B-v0.1", from_pt=True) + tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-v0.1", use_fast=False) + model = MistralForCausalLM.from_pretrained("mistralai/Mistral-7B-v0.1") input_ids = tokenizer.encode(prompt, return_tensors="ms") # greedy generation outputs diff --git a/tests/ut/transformers/models/mt5/test_modeling_mt5.py b/tests/ut/transformers/models/mt5/test_modeling_mt5.py index 962b5f39c..b4985289d 100644 --- a/tests/ut/transformers/models/mt5/test_modeling_mt5.py +++ b/tests/ut/transformers/models/mt5/test_modeling_mt5.py @@ -38,8 +38,8 @@ def test_small_integration_test(self): >>> score = t5_model.score(inputs=["Hello there"], targets=["Hi I am"], vocabulary=vocab) """ - model = AutoModelForSeq2SeqLM.from_pretrained("google/mt5-small", return_dict=True, from_pt=True) - tokenizer = AutoTokenizer.from_pretrained("google/mt5-small", from_pt=True) + model = AutoModelForSeq2SeqLM.from_pretrained("google/mt5-small", return_dict=True) + tokenizer = AutoTokenizer.from_pretrained("google/mt5-small") input_ids = tokenizer("Hello there", return_tensors="ms").input_ids labels = tokenizer("Hi I am", return_tensors="ms").input_ids diff --git a/tests/ut/transformers/models/opt/test_modeling_opt.py b/tests/ut/transformers/models/opt/test_modeling_opt.py index eb0709813..27b30982c 100644 --- a/tests/ut/transformers/models/opt/test_modeling_opt.py +++ b/tests/ut/transformers/models/opt/test_modeling_opt.py @@ -352,7 +352,7 @@ def _long_tensor(tok_lst): class OPTModelIntegrationTests(unittest.TestCase): @slow def test_inference_no_head(self): - model = OPTModel.from_pretrained("facebook/opt-350m", from_pt=True) + model = OPTModel.from_pretrained("facebook/opt-350m") input_ids = _long_tensor([[0, 31414, 232, 328, 740, 1140, 12695, 69, 46078, 1588, 2]]) output = model(input_ids=input_ids).last_hidden_state @@ -378,14 +378,14 @@ def setUp(self): def test_load_model(self): try: - _ = OPTForCausalLM.from_pretrained(self.path_model, from_pt=True) + _ = OPTForCausalLM.from_pretrained(self.path_model) except BaseException: self.fail("Failed loading model") def test_logits(self): - model = OPTForCausalLM.from_pretrained(self.path_model, from_pt=True) + model = OPTForCausalLM.from_pretrained(self.path_model) model = model.set_train(False) - tokenizer = GPT2Tokenizer.from_pretrained(self.path_model, from_pt=True) + tokenizer = GPT2Tokenizer.from_pretrained(self.path_model) prompts = [ "Today is a beautiful day and I want to", @@ -430,8 +430,8 @@ def test_generation_pre_attn_layer_norm(self): ] predicted_outputs = [] - tokenizer = GPT2Tokenizer.from_pretrained(model_id, from_pt=True) - model = OPTForCausalLM.from_pretrained(model_id, from_pt=True) + tokenizer = GPT2Tokenizer.from_pretrained(model_id) + model = OPTForCausalLM.from_pretrained(model_id) for prompt in self.prompts: input_ids = tokenizer(prompt, return_tensors="ms").input_ids @@ -446,8 +446,8 @@ def test_generation_pre_attn_layer_norm(self): def test_batch_generation(self): model_id = "facebook/opt-350m" - tokenizer = GPT2Tokenizer.from_pretrained(model_id, from_pt=True) - model = OPTForCausalLM.from_pretrained(model_id, from_pt=True) + tokenizer = GPT2Tokenizer.from_pretrained(model_id) + model = OPTForCausalLM.from_pretrained(model_id) model tokenizer.padding_side = "left" @@ -495,8 +495,8 @@ def test_generation_post_attn_layer_norm(self): ] predicted_outputs = [] - tokenizer = GPT2Tokenizer.from_pretrained(model_id, from_pt=True) - model = OPTForCausalLM.from_pretrained(model_id, from_pt=True) + tokenizer = GPT2Tokenizer.from_pretrained(model_id) + model = OPTForCausalLM.from_pretrained(model_id) for prompt in self.prompts: input_ids = tokenizer(prompt, return_tensors="ms").input_ids @@ -514,9 +514,9 @@ def test_batched_nan_fp16(self): # therefore not using a tiny model, but the smallest model the problem was seen with which is opt-1.3b. # please refer to this github thread: https://github.com/huggingface/transformers/pull/17437 for more details model_name = "facebook/opt-1.3b" - tokenizer = GPT2Tokenizer.from_pretrained(model_name, use_fast=False, padding_side="left", from_pt=True) + tokenizer = GPT2Tokenizer.from_pretrained(model_name, use_fast=False, padding_side="left") - model = OPTForCausalLM.from_pretrained(model_name, ms_dtype=mindspore.float16, use_cache=True, from_pt=True) + model = OPTForCausalLM.from_pretrained(model_name, ms_dtype=mindspore.float16, use_cache=True) model = model.set_train(False) batch = tokenizer(["Who are you?", "Joe Biden is the president of"], padding=True, return_tensors="ms") @@ -537,8 +537,8 @@ def test_contrastive_search_opt(self): "there?" ) - opt_tokenizer = GPT2Tokenizer.from_pretrained("facebook/opt-1.3b", from_pt=True) - opt_model = OPTForCausalLM.from_pretrained("facebook/opt-1.3b", from_pt=True) + opt_tokenizer = GPT2Tokenizer.from_pretrained("facebook/opt-1.3b") + opt_model = OPTForCausalLM.from_pretrained("facebook/opt-1.3b") input_ids = opt_tokenizer(article, return_tensors="ms").input_ids outputs = opt_model.generate(input_ids, penalty_alpha=0.6, top_k=5, max_length=256) diff --git a/tests/ut/transformers/models/phi/test_modeling_phi.py b/tests/ut/transformers/models/phi/test_modeling_phi.py index 9c90bb3b8..cc3cb0f3d 100644 --- a/tests/ut/transformers/models/phi/test_modeling_phi.py +++ b/tests/ut/transformers/models/phi/test_modeling_phi.py @@ -363,10 +363,10 @@ def test_flash_attn_2_generate_padding_right(self): Overwritting the common test as the test is flaky on tiny models """ model = PhiForCausalLM.from_pretrained( - "microsoft/phi-1", from_pt=True + "microsoft/phi-1" ) - tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-1", from_pt=True) + tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-1") texts = ["hi", "Hello this is a very long sentence"] @@ -389,7 +389,7 @@ def test_model_phi_1_logits(self): ) } - model = PhiForCausalLM.from_pretrained("microsoft/phi-1", from_pt=True) + model = PhiForCausalLM.from_pretrained("microsoft/phi-1") model.set_train(False) output = model(**input_ids).logits @@ -405,7 +405,7 @@ def test_model_phi_1_5_logits(self): ) } - model = PhiForCausalLM.from_pretrained("microsoft/phi-1_5", from_pt=True) + model = PhiForCausalLM.from_pretrained("microsoft/phi-1_5") model.set_train(False) output = model(**input_ids).logits @@ -421,7 +421,7 @@ def test_model_phi_2_logits(self): ) } - model = PhiForCausalLM.from_pretrained("microsoft/phi-2", from_pt=True) + model = PhiForCausalLM.from_pretrained("microsoft/phi-2") model.set_train(False) output = model(**input_ids).logits @@ -432,8 +432,8 @@ def test_model_phi_2_logits(self): self.assertTrue(np.allclose(EXPECTED_OUTPUT.asnumpy(), output[0, :2, :30].asnumpy(), atol=1e-2, rtol=1e-2)) def test_phi_2_generation(self): - model = PhiForCausalLM.from_pretrained("microsoft/phi-2", from_pt=True) - tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-2", from_pt=True) + model = PhiForCausalLM.from_pretrained("microsoft/phi-2") + tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-2") inputs = tokenizer( "Can you help me write a formal email to a potential business partner proposing a joint venture?", diff --git a/tests/ut/transformers/models/pop2piano/test_modeling_pop2piano.py b/tests/ut/transformers/models/pop2piano/test_modeling_pop2piano.py index 114963fca..2876f68a5 100644 --- a/tests/ut/transformers/models/pop2piano/test_modeling_pop2piano.py +++ b/tests/ut/transformers/models/pop2piano/test_modeling_pop2piano.py @@ -607,7 +607,7 @@ def test_v1_1_resize_embeddings(self): @slow def test_model_from_pretrained(self): for model_name in POP2PIANO_PRETRAINED_MODEL_ARCHIVE_LIST[:1]: - model = Pop2PianoForConditionalGeneration.from_pretrained(model_name, from_pt=True) + model = Pop2PianoForConditionalGeneration.from_pretrained(model_name) self.assertIsNotNone(model) def test_pass_with_input_features(self): @@ -618,7 +618,7 @@ def test_pass_with_input_features(self): "extrapolated_beatstep": ops.randint(size=(1, 900), low=0, high=100).type(mindspore.float32), } ) - model = Pop2PianoForConditionalGeneration.from_pretrained("sweetcocoa/pop2piano", from_pt=True) + model = Pop2PianoForConditionalGeneration.from_pretrained("sweetcocoa/pop2piano") model_opts = model.generate(input_features=input_features["input_features"], return_dict_in_generate=True) self.assertEqual(model_opts.sequences.ndim, 2) @@ -644,7 +644,7 @@ def test_pass_with_batched_input_features(self): "attention_mask_extrapolated_beatstep": ops.ones((5, 900), dtype=mindspore.int32), } ) - model = Pop2PianoForConditionalGeneration.from_pretrained("sweetcocoa/pop2piano", from_pt=True) + model = Pop2PianoForConditionalGeneration.from_pretrained("sweetcocoa/pop2piano") model_opts = model.generate( input_features=input_features["input_features"], attention_mask=input_features["attention_mask"], @@ -659,7 +659,7 @@ class Pop2PianoModelIntegrationTests(unittest.TestCase): @slow def test_mel_conditioner_integration(self): composer = "composer1" - model = Pop2PianoForConditionalGeneration.from_pretrained("sweetcocoa/pop2piano", from_pt=True) + model = Pop2PianoForConditionalGeneration.from_pretrained("sweetcocoa/pop2piano") input_embeds = ops.ones((10, 100, 512)) composer_value = model.generation_config.composer_to_feature_token[composer] @@ -690,12 +690,12 @@ def test_full_model_integration(self): speech_input1 = np.zeros([1_000_000], dtype=np.float32) sampling_rate = 44_100 - processor = Pop2PianoProcessor.from_pretrained("sweetcocoa/pop2piano", from_pt=True) + processor = Pop2PianoProcessor.from_pretrained("sweetcocoa/pop2piano") input_features = processor.feature_extractor( speech_input1, sampling_rate=sampling_rate, return_tensors="ms" ) - model = Pop2PianoForConditionalGeneration.from_pretrained("sweetcocoa/pop2piano", from_pt=True) + model = Pop2PianoForConditionalGeneration.from_pretrained("sweetcocoa/pop2piano") outputs = model.generate( input_features=input_features["input_features"], return_dict_in_generate=True ).sequences @@ -715,10 +715,10 @@ def test_real_music(self): if is_librosa_available() and is_scipy_available() and is_essentia_available() and is_mindspore_available(): from mindnlp.transformers import Pop2PianoFeatureExtractor, Pop2PianoTokenizer - model = Pop2PianoForConditionalGeneration.from_pretrained("sweetcocoa/pop2piano", from_pt=True) + model = Pop2PianoForConditionalGeneration.from_pretrained("sweetcocoa/pop2piano") model.set_train(False) - feature_extractor = Pop2PianoFeatureExtractor.from_pretrained("sweetcocoa/pop2piano", from_pt=True) - tokenizer = Pop2PianoTokenizer.from_pretrained("sweetcocoa/pop2piano", from_pt=True) + feature_extractor = Pop2PianoFeatureExtractor.from_pretrained("sweetcocoa/pop2piano") + tokenizer = Pop2PianoTokenizer.from_pretrained("sweetcocoa/pop2piano") ds = load_dataset("sweetcocoa/pop2piano_ci", split="test") output_fe = feature_extractor( diff --git a/tests/ut/transformers/models/rwkv/test_modeling_rwkv.py b/tests/ut/transformers/models/rwkv/test_modeling_rwkv.py index 3e623fb47..2ace3fb65 100644 --- a/tests/ut/transformers/models/rwkv/test_modeling_rwkv.py +++ b/tests/ut/transformers/models/rwkv/test_modeling_rwkv.py @@ -89,7 +89,7 @@ def __init__( self.pad_token_id = vocab_size - 1 def get_large_model_config(self): - return RwkvConfig.from_pretrained("sgugger/rwkv-4-pile-7b", from_pt=True) + return RwkvConfig.from_pretrained("sgugger/rwkv-4-pile-7b") def prepare_config_and_inputs( self, gradient_checkpointing=False, scale_attn_by_inverse_layer_idx=False, reorder_and_upcast_attn=False @@ -413,7 +413,7 @@ def test_attention_outputs(self): @slow def test_model_from_pretrained(self): for model_name in RWKV_PRETRAINED_MODEL_ARCHIVE_LIST[:1]: - model = RwkvModel.from_pretrained(model_name, from_pt=True) + model = RwkvModel.from_pretrained(model_name) self.assertIsNotNone(model) @@ -421,11 +421,11 @@ def test_model_from_pretrained(self): class RWKVIntegrationTests(unittest.TestCase): def setUp(self): self.model_id = "RWKV/rwkv-4-169m-pile" - self.tokenizer = AutoTokenizer.from_pretrained(self.model_id, from_pt=True) + self.tokenizer = AutoTokenizer.from_pretrained(self.model_id) def test_simple_generate(self): expected_output = "Hello my name is Jasmine and I am a newbie to the" - model = RwkvForCausalLM.from_pretrained(self.model_id, from_pt=True) + model = RwkvForCausalLM.from_pretrained(self.model_id) input_ids = self.tokenizer("Hello my name is", return_tensors="ms").input_ids output = model.generate(input_ids, max_new_tokens=10) @@ -439,7 +439,7 @@ def test_simple_generate_fp16(self): expected_output = "Hello my name is Jasmine and I am a newbie to the" input_ids = self.tokenizer("Hello my name is", return_tensors="ms").input_ids - model = RwkvForCausalLM.from_pretrained(self.model_id, ms_dtype=mindspore.float16, from_pt=True) + model = RwkvForCausalLM.from_pretrained(self.model_id, ms_dtype=mindspore.float16) output = model.generate(input_ids, max_new_tokens=10) output_sentence = self.tokenizer.decode(output[0].tolist()) diff --git a/tests/ut/transformers/models/seamless_m4t/test_modeling_seamless_m4t.py b/tests/ut/transformers/models/seamless_m4t/test_modeling_seamless_m4t.py index 5a7f70743..58f68c905 100644 --- a/tests/ut/transformers/models/seamless_m4t/test_modeling_seamless_m4t.py +++ b/tests/ut/transformers/models/seamless_m4t/test_modeling_seamless_m4t.py @@ -381,7 +381,7 @@ def test_model(self): @slow def test_model_from_pretrained(self): for model_name in SEAMLESS_M4T_PRETRAINED_MODEL_ARCHIVE_LIST[:1]: - model = SeamlessM4TModel.from_pretrained(model_name, from_pt=True) + model = SeamlessM4TModel.from_pretrained(model_name) self.assertIsNotNone(model) def _get_input_ids_and_config(self, batch_size=2): @@ -661,7 +661,7 @@ def test_model(self): @slow def test_model_from_pretrained(self): for model_name in SEAMLESS_M4T_PRETRAINED_MODEL_ARCHIVE_LIST[:1]: - model = SeamlessM4TModel.from_pretrained(model_name, from_pt=True) + model = SeamlessM4TModel.from_pretrained(model_name) self.assertIsNotNone(model) def test_initialization(self): @@ -964,7 +964,7 @@ def assertListAlmostEqual(self, list1, list2, tol=1e-3): @cached_property def processor(self): - return SeamlessM4TProcessor.from_pretrained(self.repo_id, from_pt=True) + return SeamlessM4TProcessor.from_pretrained(self.repo_id) @cached_property def input_text(self): @@ -992,8 +992,8 @@ def input_audio(self): return self.processor(audios=[input_features.tolist()], sampling_rate=sampling_rate, return_tensors="ms") def factory_test_task(self, class1, class2, inputs, class1_kwargs, class2_kwargs): - model1 = class1.from_pretrained(self.repo_id, from_pt=True) - model2 = class2.from_pretrained(self.repo_id, from_pt=True) + model1 = class1.from_pretrained(self.repo_id) + model2 = class2.from_pretrained(self.repo_id) set_seed(0) output_1 = model1.generate(**inputs, **class1_kwargs) set_seed(0) @@ -1008,7 +1008,7 @@ def factory_test_task(self, class1, class2, inputs, class1_kwargs, class2_kwargs @slow def test_to_eng_text(self): - model = SeamlessM4TModel.from_pretrained(self.repo_id, from_pt=True) + model = SeamlessM4TModel.from_pretrained(self.repo_id) # test text - tgt lang: eng @@ -1036,7 +1036,7 @@ def test_to_eng_text(self): @slow def test_to_swh_text(self): - model = SeamlessM4TModel.from_pretrained(self.repo_id, from_pt=True) + model = SeamlessM4TModel.from_pretrained(self.repo_id) # test text - tgt lang: swh @@ -1063,7 +1063,7 @@ def test_to_swh_text(self): @slow def test_to_rus_speech(self): - model = SeamlessM4TModel.from_pretrained(self.repo_id, from_pt=True) + model = SeamlessM4TModel.from_pretrained(self.repo_id) # test audio - tgt lang: rus expected_text_tokens = [3, 256147, 1197, 73565, 3413, 537, 233331, 248075, 3] # fmt: skip diff --git a/tests/ut/transformers/models/seamless_m4t_v2/test_modeling_seamless_m4t_v2.py b/tests/ut/transformers/models/seamless_m4t_v2/test_modeling_seamless_m4t_v2.py index be19ad079..9aaa98656 100644 --- a/tests/ut/transformers/models/seamless_m4t_v2/test_modeling_seamless_m4t_v2.py +++ b/tests/ut/transformers/models/seamless_m4t_v2/test_modeling_seamless_m4t_v2.py @@ -399,7 +399,7 @@ def test_model(self): @slow def test_model_from_pretrained(self): for model_name in SEAMLESS_M4T_V2_PRETRAINED_MODEL_ARCHIVE_LIST: - model = SeamlessM4Tv2Model.from_pretrained(model_name, from_pt=True) + model = SeamlessM4Tv2Model.from_pretrained(model_name) self.assertIsNotNone(model) def _get_input_ids_and_config(self, batch_size=2): @@ -663,7 +663,7 @@ def test_model(self): @slow def test_model_from_pretrained(self): for model_name in SEAMLESS_M4T_V2_PRETRAINED_MODEL_ARCHIVE_LIST: - model = SeamlessM4Tv2Model.from_pretrained(model_name, from_pt=True) + model = SeamlessM4Tv2Model.from_pretrained(model_name) self.assertIsNotNone(model) def test_initialization(self): @@ -1008,7 +1008,7 @@ def assertListAlmostEqual(self, list1, list2, tol=1e-4): @cached_property def processor(self): - return SeamlessM4TProcessor.from_pretrained(self.repo_id, from_pt=True) + return SeamlessM4TProcessor.from_pretrained(self.repo_id) @cached_property def input_text(self): @@ -1036,8 +1036,8 @@ def input_audio(self): def factory_test_task(self, class1, class2, inputs, class1_kwargs, class2_kwargs): # half-precision loading to limit GPU usage - model1 = class1.from_pretrained(self.repo_id, ms_dtype=mindspore.float16, from_pt=True) - model2 = class2.from_pretrained(self.repo_id, ms_dtype=mindspore.float16, from_pt=True) + model1 = class1.from_pretrained(self.repo_id, ms_dtype=mindspore.float16) + model2 = class2.from_pretrained(self.repo_id, ms_dtype=mindspore.float16) set_seed(0) output_1 = model1.generate(**inputs, **class1_kwargs) @@ -1053,7 +1053,7 @@ def factory_test_task(self, class1, class2, inputs, class1_kwargs, class2_kwargs @slow def test_to_eng_text(self): - model = SeamlessM4Tv2Model.from_pretrained(self.repo_id, from_pt=True) + model = SeamlessM4Tv2Model.from_pretrained(self.repo_id) # test text - tgt lang: eng @@ -1087,7 +1087,7 @@ def test_to_eng_text(self): @slow @unittest.skip(reason="Equivalence is broken since a new update") def test_to_swh_text(self): - model = SeamlessM4Tv2Model.from_pretrained(self.repo_id, from_pt=True) + model = SeamlessM4Tv2Model.from_pretrained(self.repo_id) # test text - tgt lang: swh @@ -1121,7 +1121,7 @@ def test_to_swh_text(self): @slow def test_to_rus_speech(self): - model = SeamlessM4Tv2Model.from_pretrained(self.repo_id, from_pt=True) + model = SeamlessM4Tv2Model.from_pretrained(self.repo_id) # test audio - tgt lang: rus diff --git a/tests/ut/transformers/models/t5/test_modeling_t5.py b/tests/ut/transformers/models/t5/test_modeling_t5.py index ad53faac6..e6742ab33 100644 --- a/tests/ut/transformers/models/t5/test_modeling_t5.py +++ b/tests/ut/transformers/models/t5/test_modeling_t5.py @@ -1037,8 +1037,8 @@ def test_small_v1_1_integration_test(self): >>> score = t5_model.score(inputs=["Hello there"], targets=["Hi I am"], vocabulary=vocab) """ - model = T5ForConditionalGeneration.from_pretrained("google/t5-v1_1-small", from_pt=True) - tokenizer = T5Tokenizer.from_pretrained("google/t5-v1_1-small", from_pt=True) + model = T5ForConditionalGeneration.from_pretrained("google/t5-v1_1-small") + tokenizer = T5Tokenizer.from_pretrained("google/t5-v1_1-small") input_ids = tokenizer("Hello there", return_tensors="ms").input_ids labels = tokenizer("Hi I am", return_tensors="ms").input_ids @@ -1060,8 +1060,8 @@ def test_small_byt5_integration_test(self): >>> score = t5_model.score(inputs=["Hello there"], targets=["Hi I am"], vocabulary=vocab) """ - model = T5ForConditionalGeneration.from_pretrained("google/byt5-small", from_pt=True) - tokenizer = ByT5Tokenizer.from_pretrained("google/byt5-small", from_pt=True) + model = T5ForConditionalGeneration.from_pretrained("google/byt5-small") + tokenizer = ByT5Tokenizer.from_pretrained("google/byt5-small") input_ids = tokenizer("Hello there", return_tensors="ms").input_ids labels = tokenizer("Hi I am", return_tensors="ms").input_ids @@ -1400,8 +1400,8 @@ def test_contrastive_search_t5(self): " up to four years in prison. Her next court appearance is scheduled for May 18." ) article = "summarize: " + article.strip() - t5_tokenizer = AutoTokenizer.from_pretrained("flax-community/t5-base-cnn-dm", from_pt=True) - t5_model = T5ForConditionalGeneration.from_pretrained("flax-community/t5-base-cnn-dm", from_pt=True) + t5_tokenizer = AutoTokenizer.from_pretrained("flax-community/t5-base-cnn-dm") + t5_model = T5ForConditionalGeneration.from_pretrained("flax-community/t5-base-cnn-dm") input_ids = t5_tokenizer( article, add_special_tokens=False, truncation=True, max_length=512, return_tensors="ms" ).input_ids diff --git a/tests/ut/transformers/models/tinybert/test_tinybert.py b/tests/ut/transformers/models/tinybert/test_tinybert.py index 5d128be9d..326f0244d 100644 --- a/tests/ut/transformers/models/tinybert/test_tinybert.py +++ b/tests/ut/transformers/models/tinybert/test_tinybert.py @@ -378,8 +378,3 @@ def test_from_pretrained(self): def test_from_pretrained_path(self): """test from pretrained""" _ = TinyBertModel.from_pretrained('.mindnlp/models/tinybert_6L_zh') - - @pytest.mark.download - def test_from_pretrained_from_pt(self): - """test from pt""" - _ = TinyBertModel.from_pretrained('huawei-noah/tinybert_6L_zh', from_pt=True) diff --git a/tests/ut/transformers/models/wav2vec2/test_feature_extraction_wav2vec2.py b/tests/ut/transformers/models/wav2vec2/test_feature_extraction_wav2vec2.py index 2ae57e074..8a76cda00 100644 --- a/tests/ut/transformers/models/wav2vec2/test_feature_extraction_wav2vec2.py +++ b/tests/ut/transformers/models/wav2vec2/test_feature_extraction_wav2vec2.py @@ -226,8 +226,8 @@ def test_pretrained_checkpoints_are_set_correctly(self): # group norm don't have their feature extractor return the # attention_mask for model_id in WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST: - config = Wav2Vec2Config.from_pretrained(model_id, from_pt=True) - feat_extract = Wav2Vec2FeatureExtractor.from_pretrained(model_id, from_pt=True) + config = Wav2Vec2Config.from_pretrained(model_id) + feat_extract = Wav2Vec2FeatureExtractor.from_pretrained(model_id) # only "layer" feature extraction norm should make use of # attention_mask diff --git a/tests/ut/transformers/models/wav2vec2/test_modeling_wav2vec2.py b/tests/ut/transformers/models/wav2vec2/test_modeling_wav2vec2.py index a9cf40b2a..7e520855d 100644 --- a/tests/ut/transformers/models/wav2vec2/test_modeling_wav2vec2.py +++ b/tests/ut/transformers/models/wav2vec2/test_modeling_wav2vec2.py @@ -101,7 +101,7 @@ def _test_wav2vec2_with_lm_invalid_pool(in_queue, out_queue, timeout): ms.tensor(sample["audio"]["array"]).numpy(), orig_sr=48_000, target_sr=16_000 ) - model = Wav2Vec2ForCTC.from_pretrained("patrickvonplaten/wav2vec2-large-xlsr-53-spanish-with-lm", from_pt=True) + model = Wav2Vec2ForCTC.from_pretrained("patrickvonplaten/wav2vec2-large-xlsr-53-spanish-with-lm") processor = Wav2Vec2ProcessorWithLM.from_pretrained("patrickvonplaten/wav2vec2-large-xlsr-53-spanish-with-lm") input_values = processor(resampled_audio, return_tensors="ms").input_values @@ -576,11 +576,11 @@ def test_initialization(self): def test_mask_feature_prob_ctc(self): model = Wav2Vec2ForCTC.from_pretrained( - "hf-internal-testing/tiny-random-wav2vec2", from_pt=True, mask_feature_prob=0.2, mask_feature_length=2 + "hf-internal-testing/tiny-random-wav2vec2", mask_feature_prob=0.2, mask_feature_length=2 ) model.set_train(True) processor = Wav2Vec2Processor.from_pretrained( - "hf-internal-testing/tiny-random-wav2vec2", from_pt=True, return_attention_mask=True + "hf-internal-testing/tiny-random-wav2vec2", return_attention_mask=True ) batch_duration_in_seconds = [1, 3, 2, 6] @@ -599,11 +599,11 @@ def test_mask_feature_prob_ctc(self): def test_mask_time_prob_ctc(self): model = Wav2Vec2ForCTC.from_pretrained( - "hf-internal-testing/tiny-random-wav2vec2", from_pt=True, mask_time_prob=0.2, mask_time_length=2 + "hf-internal-testing/tiny-random-wav2vec2", mask_time_prob=0.2, mask_time_length=2 ) model.set_train(True) processor = Wav2Vec2Processor.from_pretrained( - "hf-internal-testing/tiny-random-wav2vec2", from_pt=True, return_attention_mask=True + "hf-internal-testing/tiny-random-wav2vec2", return_attention_mask=True ) batch_duration_in_seconds = [1, 3, 2, 6] @@ -626,7 +626,7 @@ def test_feed_forward_chunking(self): @slow def test_model_from_pretrained(self): - model = Wav2Vec2Model.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True) + model = Wav2Vec2Model.from_pretrained("facebook/wav2vec2-base-960h") self.assertIsNotNone(model) @@ -794,11 +794,11 @@ def test_model_for_pretraining(self): def test_mask_feature_prob_ctc(self): model = Wav2Vec2ForCTC.from_pretrained( - "hf-internal-testing/tiny-random-wav2vec2", from_pt=True, mask_feature_prob=0.2, mask_feature_length=2 + "hf-internal-testing/tiny-random-wav2vec2", mask_feature_prob=0.2, mask_feature_length=2 ) model.set_train(True) processor = Wav2Vec2Processor.from_pretrained( - "hf-internal-testing/tiny-random-wav2vec2", from_pt=True, return_attention_mask=True + "hf-internal-testing/tiny-random-wav2vec2", return_attention_mask=True ) batch_duration_in_seconds = [1, 3, 2, 6] @@ -817,11 +817,11 @@ def test_mask_feature_prob_ctc(self): def test_mask_time_prob_ctc(self): model = Wav2Vec2ForCTC.from_pretrained( - "hf-internal-testing/tiny-random-wav2vec2", from_pt=True, mask_time_prob=0.2, mask_time_length=2 + "hf-internal-testing/tiny-random-wav2vec2", mask_time_prob=0.2, mask_time_length=2 ) model.set_train(True) processor = Wav2Vec2Processor.from_pretrained( - "hf-internal-testing/tiny-random-wav2vec2", from_pt=True, return_attention_mask=True + "hf-internal-testing/tiny-random-wav2vec2", return_attention_mask=True ) batch_duration_in_seconds = [1, 3, 2, 6] @@ -841,7 +841,6 @@ def test_mask_time_prob_ctc(self): def test_mask_time_feature_prob_ctc_single_batch(self): model = Wav2Vec2ForCTC.from_pretrained( "hf-internal-testing/tiny-random-wav2vec2", - from_pt=True, mask_time_prob=0.2, mask_feature_prob=0.2, mask_time_length=2, @@ -849,7 +848,7 @@ def test_mask_time_feature_prob_ctc_single_batch(self): ) model.set_train(True) processor = Wav2Vec2Processor.from_pretrained( - "hf-internal-testing/tiny-random-wav2vec2", from_pt=True, return_attention_mask=True + "hf-internal-testing/tiny-random-wav2vec2", return_attention_mask=True ) batch_duration_in_seconds = [6] @@ -872,7 +871,7 @@ def test_feed_forward_chunking(self): @unittest.skip(reason="resource url unavailable") def test_load_and_set_attn_adapter(self): - processor = Wav2Vec2Processor.from_pretrained("hf-internal-testing/tiny-random-wav2vec2", from_pt=True, return_attention_mask=True) + processor = Wav2Vec2Processor.from_pretrained("hf-internal-testing/tiny-random-wav2vec2", return_attention_mask=True) def get_logits(model, input_features): batch = processor( @@ -889,11 +888,11 @@ def get_logits(model, input_features): input_features = [np.random.random(16_000 * s) for s in [1, 3, 2, 6]] - model = Wav2Vec2ForCTC.from_pretrained("hf-internal-testing/tiny-random-wav2vec2-adapter", from_pt=True, target_lang="it") + model = Wav2Vec2ForCTC.from_pretrained("hf-internal-testing/tiny-random-wav2vec2-adapter", target_lang="it") logits = get_logits(model, input_features) - model_2 = Wav2Vec2ForCTC.from_pretrained("hf-internal-testing/tiny-random-wav2vec2-adapter", from_pt=True) + model_2 = Wav2Vec2ForCTC.from_pretrained("hf-internal-testing/tiny-random-wav2vec2-adapter") model_2.load_adapter("it") logits_2 = get_logits(model_2, input_features) @@ -904,7 +903,7 @@ def get_logits(model, input_features): # test that loading adapter weights with mismatched vocab sizes can be loaded def test_load_target_lang_with_mismatched_size(self): processor = Wav2Vec2Processor.from_pretrained( - "hf-internal-testing/tiny-random-wav2vec2", from_pt=True, return_attention_mask=True + "hf-internal-testing/tiny-random-wav2vec2", return_attention_mask=True ) def get_logits(model, input_features): @@ -922,11 +921,11 @@ def get_logits(model, input_features): input_features = [np.random.random(16_000 * s) for s in [1, 3, 2, 6]] - model = Wav2Vec2ForCTC.from_pretrained("hf-internal-testing/tiny-random-wav2vec2-adapter", from_pt=True, target_lang="fr", ignore_mismatched_sizes=True) + model = Wav2Vec2ForCTC.from_pretrained("hf-internal-testing/tiny-random-wav2vec2-adapter", target_lang="fr", ignore_mismatched_sizes=True) logits = get_logits(model, input_features) - model_2 = Wav2Vec2ForCTC.from_pretrained("hf-internal-testing/tiny-random-wav2vec2-adapter", from_pt=True) + model_2 = Wav2Vec2ForCTC.from_pretrained("hf-internal-testing/tiny-random-wav2vec2-adapter") model_2.load_adapter("fr") logits_2 = get_logits(model_2, input_features) @@ -936,7 +935,7 @@ def get_logits(model, input_features): @unittest.skip(reason="no pytorch support") def test_load_attn_adapter(self): processor = Wav2Vec2Processor.from_pretrained( - "hf-internal-testing/tiny-random-wav2vec2", from_pt=True, return_attention_mask=True + "hf-internal-testing/tiny-random-wav2vec2", return_attention_mask=True ) def get_logits(model, input_features): @@ -954,7 +953,7 @@ def get_logits(model, input_features): input_features = [np.random.random(16_000 * s) for s in [1, 3, 2, 6]] - model = Wav2Vec2ForCTC.from_pretrained("hf-internal-testing/tiny-random-wav2vec2", from_pt=True, adapter_attn_dim=16) + model = Wav2Vec2ForCTC.from_pretrained("hf-internal-testing/tiny-random-wav2vec2", adapter_attn_dim=16) with tempfile.TemporaryDirectory() as tempdir: model.save_pretrained(tempdir) @@ -999,7 +998,7 @@ def get_logits(model, input_features): self.assertTrue(mnp.allclose(logits, logits_2, atol=1e-3)) - model = Wav2Vec2ForCTC.from_pretrained("hf-internal-testing/tiny-random-wav2vec2-adapter", from_pt=True) + model = Wav2Vec2ForCTC.from_pretrained("hf-internal-testing/tiny-random-wav2vec2-adapter") logits = get_logits(model, input_features) model.load_adapter("eng") @@ -1012,7 +1011,7 @@ def get_logits(model, input_features): @slow def test_model_from_pretrained(self): - model = Wav2Vec2Model.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True) + model = Wav2Vec2Model.from_pretrained("facebook/wav2vec2-base-960h") self.assertIsNotNone(model) @@ -1217,8 +1216,8 @@ def _load_superb(self, task, num_samples): return ds[:num_samples] def test_inference_ctc_normal(self): - model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True) - processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True, do_lower_case=True) + model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h") + processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h", do_lower_case=True) input_speech = self._load_datasamples(1) input_values = processor(input_speech, return_tensors="ms").input_values @@ -1231,8 +1230,8 @@ def test_inference_ctc_normal(self): self.assertListEqual(predicted_trans, EXPECTED_TRANSCRIPTIONS) def test_inference_ctc_normal_batched(self): - model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True) - processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True, do_lower_case=True) + model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h") + processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h", do_lower_case=True) input_speech = self._load_datasamples(2) inputs = processor(input_speech, return_tensors="ms", padding=True) @@ -1249,8 +1248,8 @@ def test_inference_ctc_normal_batched(self): self.assertListEqual(predicted_trans, EXPECTED_TRANSCRIPTIONS) def test_inference_ctc_robust_batched(self): - model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-large-960h-lv60-self", from_pt=True) - processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-large-960h-lv60-self", from_pt=True, do_lower_case=True) + model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-large-960h-lv60-self") + processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-large-960h-lv60-self", do_lower_case=True) input_speech = self._load_datasamples(4) inputs = processor(input_speech, return_tensors="ms", padding=True) @@ -1273,8 +1272,8 @@ def test_inference_ctc_robust_batched(self): @unittest.skipIf(ms.get_context('device_target') != "CPU", "cannot make deterministic on GPU") def test_inference_integration(self): - model = Wav2Vec2ForPreTraining.from_pretrained("facebook/wav2vec2-base", from_pt=True) - feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("facebook/wav2vec2-base", from_pt=True) + model = Wav2Vec2ForPreTraining.from_pretrained("facebook/wav2vec2-base") + feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("facebook/wav2vec2-base") input_speech = self._load_datasamples(2) inputs_dict = feature_extractor(input_speech, return_tensors="ms", padding=True) @@ -1318,9 +1317,9 @@ def test_inference_integration(self): self.assertTrue(mnp.allclose(cosine_sim_masked, expected_cosine_sim_masked, atol=1e-3)) def test_inference_pretrained(self): - model = Wav2Vec2ForPreTraining.from_pretrained("facebook/wav2vec2-base", from_pt=True) + model = Wav2Vec2ForPreTraining.from_pretrained("facebook/wav2vec2-base") feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained( - "facebook/wav2vec2-base", from_pt=True, return_attention_mask=True + "facebook/wav2vec2-base", return_attention_mask=True ) input_speech = self._load_datasamples(2) @@ -1352,7 +1351,7 @@ def test_inference_pretrained(self): # ... now compare to randomly initialized model - config = Wav2Vec2Config.from_pretrained("facebook/wav2vec2-base", from_pt=True) + config = Wav2Vec2Config.from_pretrained("facebook/wav2vec2-base") model_rand = Wav2Vec2ForPreTraining(config) outputs_rand = model_rand( inputs_dict.input_values, @@ -1376,7 +1375,6 @@ def test_inference_pretrained(self): def test_loss_pretraining(self): model = Wav2Vec2ForPreTraining.from_pretrained( "facebook/wav2vec2-base", - from_pt=True, attention_dropout=0.0, feat_proj_dropout=0.0, hidden_dropout=0.0, @@ -1385,7 +1383,7 @@ def test_loss_pretraining(self): model.set_train(True) feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained( - "facebook/wav2vec2-base", from_pt=True, return_attention_mask=True + "facebook/wav2vec2-base", return_attention_mask=True ) input_speech = self._load_datasamples(2) @@ -1430,8 +1428,8 @@ def test_loss_pretraining(self): #self.assertTrue(abs(outputs.loss.item() - expected_loss) < 1e-3) def test_inference_keyword_spotting(self): - model = Wav2Vec2ForSequenceClassification.from_pretrained("superb/wav2vec2-base-superb-ks", from_pt=True) - processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/wav2vec2-base-superb-ks", from_pt=True) + model = Wav2Vec2ForSequenceClassification.from_pretrained("superb/wav2vec2-base-superb-ks") + processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/wav2vec2-base-superb-ks") input_data = self._load_superb("ks", 4) inputs = processor(input_data["speech"], return_tensors="ms", padding=True) @@ -1448,8 +1446,8 @@ def test_inference_keyword_spotting(self): self.assertTrue(mnp.allclose(predicted_logits, expected_logits, atol=1e-2)) def test_inference_intent_classification(self): - model = Wav2Vec2ForSequenceClassification.from_pretrained("superb/wav2vec2-base-superb-ic", from_pt=True) - processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/wav2vec2-base-superb-ic", from_pt=True) + model = Wav2Vec2ForSequenceClassification.from_pretrained("superb/wav2vec2-base-superb-ic") + processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/wav2vec2-base-superb-ic") input_data = self._load_superb("ic", 4) inputs = processor(input_data["speech"], return_tensors="ms", padding=True) @@ -1477,8 +1475,8 @@ def test_inference_intent_classification(self): self.assertTrue(mnp.allclose(predicted_logits_location, expected_logits_location, atol=1e-2)) def test_inference_speaker_identification(self): - model = Wav2Vec2ForSequenceClassification.from_pretrained("superb/wav2vec2-base-superb-sid", from_pt=True) - processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/wav2vec2-base-superb-sid", from_pt=True) + model = Wav2Vec2ForSequenceClassification.from_pretrained("superb/wav2vec2-base-superb-sid") + processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/wav2vec2-base-superb-sid") input_data = self._load_superb("si", 4) output_logits = [] @@ -1497,8 +1495,8 @@ def test_inference_speaker_identification(self): self.assertTrue(mnp.allclose(predicted_logits, expected_logits, atol=1e-2)) def test_inference_emotion_recognition(self): - model = Wav2Vec2ForSequenceClassification.from_pretrained("superb/wav2vec2-base-superb-er", from_pt=True) - processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/wav2vec2-base-superb-er", from_pt=True) + model = Wav2Vec2ForSequenceClassification.from_pretrained("superb/wav2vec2-base-superb-er") + processor = Wav2Vec2FeatureExtractor.from_pretrained("superb/wav2vec2-base-superb-er") input_data = self._load_superb("er", 4) inputs = processor(input_data["speech"], return_tensors="ms", padding=True) @@ -1516,8 +1514,8 @@ def test_inference_emotion_recognition(self): @unittest.skip("espeak not available on Windows") def test_phoneme_recognition(self): - model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-lv-60-espeak-cv-ft", from_pt=True) - processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-lv-60-espeak-cv-ft", from_pt=True) + model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-lv-60-espeak-cv-ft") + processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-lv-60-espeak-cv-ft") input_speech = self._load_datasamples(4) inputs = processor(input_speech, return_tensors="ms", padding=True) @@ -1557,7 +1555,7 @@ def test_wav2vec2_with_lm(self): ms.tensor(sample["audio"]["array"]).numpy(), orig_sr=48_000, target_sr=16_000 ) - model = Wav2Vec2ForCTC.from_pretrained("patrickvonplaten/wav2vec2-large-xlsr-53-spanish-with-lm", from_pt=True) + model = Wav2Vec2ForCTC.from_pretrained("patrickvonplaten/wav2vec2-large-xlsr-53-spanish-with-lm") processor = Wav2Vec2ProcessorWithLM.from_pretrained("patrickvonplaten/wav2vec2-large-xlsr-53-spanish-with-lm") input_values = processor(resampled_audio, return_tensors="ms").input_values @@ -1577,7 +1575,7 @@ def test_wav2vec2_with_lm_pool(self): ms.tensor(sample["audio"]["array"]).numpy(), orig_sr=48_000, target_sr=16_000 ) - model = Wav2Vec2ForCTC.from_pretrained("patrickvonplaten/wav2vec2-large-xlsr-53-spanish-with-lm", from_pt=True) + model = Wav2Vec2ForCTC.from_pretrained("patrickvonplaten/wav2vec2-large-xlsr-53-spanish-with-lm") processor = Wav2Vec2ProcessorWithLM.from_pretrained("patrickvonplaten/wav2vec2-large-xlsr-53-spanish-with-lm") input_values = processor(resampled_audio, return_tensors="ms").input_values @@ -1606,8 +1604,8 @@ def test_wav2vec2_with_lm_invalid_pool(self): run_test_in_subprocess(test_case=self, target_func=_test_wav2vec2_with_lm_invalid_pool, inputs=None) def test_inference_diarization(self): - model = Wav2Vec2ForAudioFrameClassification.from_pretrained("anton-l/wav2vec2-base-superb-sd", from_pt=True) - processor = Wav2Vec2FeatureExtractor.from_pretrained("anton-l/wav2vec2-base-superb-sd", from_pt=True) + model = Wav2Vec2ForAudioFrameClassification.from_pretrained("anton-l/wav2vec2-base-superb-sd") + processor = Wav2Vec2FeatureExtractor.from_pretrained("anton-l/wav2vec2-base-superb-sd") input_data = self._load_superb("sd", 4) inputs = processor(input_data["speech"], return_tensors="ms", padding=True, sampling_rate=16_000) @@ -1631,8 +1629,8 @@ def test_inference_diarization(self): self.assertTrue(mnp.allclose(outputs.logits[:, :4], expected_logits, atol=1e-2)) def test_inference_speaker_verification(self): - model = Wav2Vec2ForXVector.from_pretrained("anton-l/wav2vec2-base-superb-sv", from_pt=True) - processor = Wav2Vec2FeatureExtractor.from_pretrained("anton-l/wav2vec2-base-superb-sv", from_pt=True) + model = Wav2Vec2ForXVector.from_pretrained("anton-l/wav2vec2-base-superb-sv") + processor = Wav2Vec2FeatureExtractor.from_pretrained("anton-l/wav2vec2-base-superb-sv") input_data = self._load_superb("si", 4) inputs = processor(input_data["speech"], return_tensors="ms", padding=True, sampling_rate=16_000) @@ -1656,8 +1654,8 @@ def test_inference_speaker_verification(self): @unittest.skip('no torch support') @require_librosa def test_inference_mms_1b_all(self): - model = Wav2Vec2ForCTC.from_pretrained("facebook/mms-1b-all", from_pt=True) - processor = Wav2Vec2Processor.from_pretrained("facebook/mms-1b-all", from_pt=True) + model = Wav2Vec2ForCTC.from_pretrained("facebook/mms-1b-all") + processor = Wav2Vec2Processor.from_pretrained("facebook/mms-1b-all") LANG_MAP = {"it": "ita", "es": "spa", "fr": "fra", "en": "eng"} diff --git a/tests/ut/transformers/models/wav2vec2/test_tokenization_wav2vec2.py b/tests/ut/transformers/models/wav2vec2/test_tokenization_wav2vec2.py index 73a2988ab..032603039 100644 --- a/tests/ut/transformers/models/wav2vec2/test_tokenization_wav2vec2.py +++ b/tests/ut/transformers/models/wav2vec2/test_tokenization_wav2vec2.py @@ -79,11 +79,11 @@ def setUp(self): def get_tokenizer(self, **kwargs): kwargs.update(self.special_tokens_map) - return Wav2Vec2Tokenizer.from_pretrained(self.tmpdirname, from_pt=True, **kwargs) + return Wav2Vec2Tokenizer.from_pretrained(self.tmpdirname, **kwargs) def test_tokenizer_decode(self): # TODO(PVP) - change to facebook - tokenizer = Wav2Vec2Tokenizer.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True) + tokenizer = Wav2Vec2Tokenizer.from_pretrained("facebook/wav2vec2-base-960h") sample_ids = [ [11, 5, 15, tokenizer.pad_token_id, 15, 8, 98], @@ -96,7 +96,7 @@ def test_tokenizer_decode(self): def test_tokenizer_decode_special(self): # TODO(PVP) - change to facebook - tokenizer = Wav2Vec2Tokenizer.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True) + tokenizer = Wav2Vec2Tokenizer.from_pretrained("facebook/wav2vec2-base-960h") sample_ids = [ [11, 5, 15, tokenizer.pad_token_id, 15, 8, 98], @@ -126,7 +126,7 @@ def test_tokenizer_decode_special(self): self.assertEqual(batch_tokens, ["HELLO", "BYE BYE"]) def test_tokenizer_decode_added_tokens(self): - tokenizer = Wav2Vec2Tokenizer.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True) + tokenizer = Wav2Vec2Tokenizer.from_pretrained("facebook/wav2vec2-base-960h") tokenizer.add_tokens(["!", "?"]) tokenizer.add_special_tokens({"cls_token": "$$$"}) @@ -242,7 +242,7 @@ def _input_values_are_equal(input_values_1, input_values_2): def test_save_pretrained(self): pretrained_name = list(self.tokenizer_class.pretrained_vocab_files_map["vocab_file"].keys())[0] - tokenizer = self.tokenizer_class.from_pretrained(pretrained_name, from_pt=True) + tokenizer = self.tokenizer_class.from_pretrained(pretrained_name) tmpdirname2 = tempfile.mkdtemp() tokenizer_files = tokenizer.save_pretrained(tmpdirname2) @@ -252,7 +252,7 @@ def test_save_pretrained(self): ) # Checks everything loads correctly in the same way - tokenizer_p = self.tokenizer_class.from_pretrained(tmpdirname2, from_pt=True) + tokenizer_p = self.tokenizer_class.from_pretrained(tmpdirname2) # Check special tokens are set accordingly on Rust and Python for key in tokenizer.special_tokens_map: @@ -283,7 +283,7 @@ def test_save_and_load_tokenizer(self): before_vocab = tokenizer.get_vocab() tokenizer.save_pretrained(tmpdirname) - after_tokenizer = tokenizer.__class__.from_pretrained(tmpdirname, from_pt=True) + after_tokenizer = tokenizer.__class__.from_pretrained(tmpdirname) after_tokens = after_tokenizer.decode(sample_ids) after_vocab = after_tokenizer.get_vocab() @@ -309,7 +309,7 @@ def test_save_and_load_tokenizer(self): before_vocab = tokenizer.get_vocab() tokenizer.save_pretrained(tmpdirname) - after_tokenizer = tokenizer.__class__.from_pretrained(tmpdirname, from_pt=True) + after_tokenizer = tokenizer.__class__.from_pretrained(tmpdirname) after_tokens = after_tokenizer.decode(sample_ids) after_vocab = after_tokenizer.get_vocab() @@ -365,8 +365,8 @@ def test_pretrained_checkpoints_are_set_correctly(self): # group norm don't have their tokenizer return the # attention_mask for model_id in WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST: - config = Wav2Vec2Config.from_pretrained(model_id, from_pt=True) - tokenizer = Wav2Vec2Tokenizer.from_pretrained(model_id, from_pt=True) + config = Wav2Vec2Config.from_pretrained(model_id) + tokenizer = Wav2Vec2Tokenizer.from_pretrained(model_id) # only "layer" feature extraction norm should make use of # attention_mask @@ -392,10 +392,10 @@ def setUp(self): def get_tokenizer(self, **kwargs): kwargs.update(self.special_tokens_map) - return Wav2Vec2CTCTokenizer.from_pretrained(self.tmpdirname, from_pt=True, **kwargs) + return Wav2Vec2CTCTokenizer.from_pretrained(self.tmpdirname, **kwargs) def test_tokenizer_add_token_chars(self): - tokenizer = self.tokenizer_class.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True) + tokenizer = self.tokenizer_class.from_pretrained("facebook/wav2vec2-base-960h") # check adding a single token tokenizer.add_tokens("x") @@ -411,7 +411,7 @@ def test_tokenizer_add_token_chars(self): self.assertEqual(token_ids, [19, 33, 7, 4, 35]) def test_tokenizer_add_token_words(self): - tokenizer = self.tokenizer_class.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True) + tokenizer = self.tokenizer_class.from_pretrained("facebook/wav2vec2-base-960h") # check adding a single token tokenizer.add_tokens("xxx") @@ -427,7 +427,7 @@ def test_tokenizer_add_token_words(self): self.assertEqual(token_ids, [19, 33, 7, 4, 35, 4, 24, 4, 24]) def test_tokenizer_decode(self): - tokenizer = self.tokenizer_class.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True) + tokenizer = self.tokenizer_class.from_pretrained("facebook/wav2vec2-base-960h") sample_ids = [ [11, 5, 15, tokenizer.pad_token_id, 15, 8, 98], @@ -439,7 +439,7 @@ def test_tokenizer_decode(self): self.assertEqual(batch_tokens, ["HELLO", "BYE BYE"]) def test_tokenizer_decode_special(self): - tokenizer = self.tokenizer_class.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True) + tokenizer = self.tokenizer_class.from_pretrained("facebook/wav2vec2-base-960h") # fmt: off sample_ids = [ @@ -458,7 +458,7 @@ def test_tokenizer_decode_special(self): self.assertEqual(batch_tokens, ["HELLO", "BYE BYE"]) def test_tokenizer_decode_added_tokens(self): - tokenizer = self.tokenizer_class.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True) + tokenizer = self.tokenizer_class.from_pretrained("facebook/wav2vec2-base-960h") tokenizer.add_tokens(["!", "?"]) tokenizer.add_special_tokens({"cls_token": "$$$"}) @@ -487,7 +487,7 @@ def test_special_characters_in_vocab(self): self.assertEqual(sent, expected_sent) tokenizer.save_pretrained(os.path.join(self.tmpdirname, "special_tokenizer")) - tokenizer = Wav2Vec2CTCTokenizer.from_pretrained(os.path.join(self.tmpdirname, "special_tokenizer"), from_pt=True) + tokenizer = Wav2Vec2CTCTokenizer.from_pretrained(os.path.join(self.tmpdirname, "special_tokenizer")) expected_sent = tokenizer.decode(tokenizer(sent).input_ids, spaces_between_special_tokens=True) self.assertEqual(sent, expected_sent) @@ -644,15 +644,15 @@ def recursive_check(list_or_dict_1, list_or_dict_2): check_list_tuples_equal(outputs_batch, outputs) def test_offsets_integration(self): - tokenizer = self.tokenizer_class.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True) + tokenizer = self.tokenizer_class.from_pretrained("facebook/wav2vec2-base-960h") # pred_ids correspond to the following code # ``` # from transformers import AutoTokenizer, AutoFeatureExtractor, AutoModelForCTC # from datasets import load_dataset # import datasets # import torch - # model = AutoModelForCTC.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True) - # feature_extractor = AutoFeatureExtractor.from_pretrained("facebook/wav2vec2-base-960h", from_pt=True) + # model = AutoModelForCTC.from_pretrained("facebook/wav2vec2-base-960h") + # feature_extractor = AutoFeatureExtractor.from_pretrained("facebook/wav2vec2-base-960h") # # ds = load_dataset("common_voice", "en", split="train", streaming=True) # ds = ds.cast_column("audio", datasets.Audio(sampling_rate=16_000)) @@ -820,14 +820,14 @@ def check_tokenizer(tokenizer, check_ita_first=False): with open(tempfile_path, "w") as temp_file: json.dump(nested_vocab, temp_file) - tokenizer = Wav2Vec2CTCTokenizer.from_pretrained(tempdir, from_pt=True, target_lang="eng") + tokenizer = Wav2Vec2CTCTokenizer.from_pretrained(tempdir, target_lang="eng") check_tokenizer(tokenizer) with tempfile.TemporaryDirectory() as tempdir: # should have saved target lang as "ita" since it was last one tokenizer.save_pretrained(tempdir) - tokenizer = Wav2Vec2CTCTokenizer.from_pretrained(tempdir, from_pt=True) + tokenizer = Wav2Vec2CTCTokenizer.from_pretrained(tempdir) self.assertEqual(tokenizer.target_lang, "ita") check_tokenizer(tokenizer, check_ita_first=True) diff --git a/tests/ut/transformers/models/whisper/test_modeling_whisper.py b/tests/ut/transformers/models/whisper/test_modeling_whisper.py index 605b8f33d..fc957c10a 100644 --- a/tests/ut/transformers/models/whisper/test_modeling_whisper.py +++ b/tests/ut/transformers/models/whisper/test_modeling_whisper.py @@ -867,7 +867,7 @@ def test_generate_with_prompt_ids_max_length(self): class WhisperModelIntegrationTests(MindNLPTestCase): @cached_property def default_processor(self): - return WhisperProcessor.from_pretrained("openai/whisper-base", from_pt=True) + return WhisperProcessor.from_pretrained("openai/whisper-base") def _load_datasamples(self, num_samples): ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation") @@ -880,7 +880,7 @@ def _load_datasamples(self, num_samples): @slow def test_tiny_logits_librispeech(self): set_seed(0) - model = WhisperModel.from_pretrained("openai/whisper-tiny", from_pt=True) + model = WhisperModel.from_pretrained("openai/whisper-tiny") input_speech = self._load_datasamples(1) feature_extractor = WhisperFeatureExtractor() input_features = feature_extractor(input_speech, return_tensors="ms").input_features @@ -924,7 +924,7 @@ def test_tiny_logits_librispeech(self): @slow def test_small_en_logits_librispeech(self): set_seed(0) - model = WhisperModel.from_pretrained("openai/whisper-small.en", from_pt=True) + model = WhisperModel.from_pretrained("openai/whisper-small.en") input_speech = self._load_datasamples(1) @@ -959,11 +959,11 @@ def test_small_en_logits_librispeech(self): def test_large_logits_librispeech(self): set_seed(0) - model = WhisperModel.from_pretrained("openai/whisper-large", from_pt=True) + model = WhisperModel.from_pretrained("openai/whisper-large") input_speech = self._load_datasamples(1) - processor = WhisperProcessor.from_pretrained("openai/whisper-large", from_pt=True) + processor = WhisperProcessor.from_pretrained("openai/whisper-large") processed_inputs = processor( audio=input_speech, text="This part of the speech", add_special_tokens=False, return_tensors="ms" ) @@ -997,8 +997,8 @@ def test_large_logits_librispeech(self): @slow def test_tiny_en_generation(self): set_seed(0) - processor = WhisperProcessor.from_pretrained("openai/whisper-tiny.en", from_pt=True) - model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en", from_pt=True) + processor = WhisperProcessor.from_pretrained("openai/whisper-tiny.en") + model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en") model.config.decoder_start_token_id = 50257 input_speech = self._load_datasamples(1) @@ -1017,8 +1017,8 @@ def test_tiny_en_generation(self): @slow def test_tiny_generation(self): set_seed(0) - processor = WhisperProcessor.from_pretrained("openai/whisper-tiny", from_pt=True) - model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny", from_pt=True) + processor = WhisperProcessor.from_pretrained("openai/whisper-tiny") + model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny") input_speech = self._load_datasamples(1) input_features = processor.feature_extractor(raw_speech=input_speech, return_tensors="ms").input_features @@ -1036,8 +1036,8 @@ def test_tiny_generation(self): @slow def test_large_generation(self): set_seed(0) - processor = WhisperProcessor.from_pretrained("openai/whisper-large", from_pt=True) - model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-large", from_pt=True) + processor = WhisperProcessor.from_pretrained("openai/whisper-large") + model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-large") input_speech = self._load_datasamples(1) input_features = processor.feature_extractor(raw_speech=input_speech, return_tensors="ms").input_features @@ -1052,8 +1052,8 @@ def test_large_generation(self): @slow def test_large_generation_multilingual(self): - processor = WhisperProcessor.from_pretrained("openai/whisper-large", from_pt=True) - model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-large", from_pt=True) + processor = WhisperProcessor.from_pretrained("openai/whisper-large") + model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-large") token = os.getenv("HF_HUB_READ_TOKEN", True) ds = load_dataset("mozilla-foundation/common_voice_6_1", "ja", split="test", streaming=True, token=token) @@ -1089,8 +1089,8 @@ def test_large_generation_multilingual(self): @slow def test_large_batched_generation(self): set_seed(0) - processor = WhisperProcessor.from_pretrained("openai/whisper-large", from_pt=True) - model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-large", from_pt=True) + processor = WhisperProcessor.from_pretrained("openai/whisper-large") + model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-large") input_speech = self._load_datasamples(4) input_features = processor.feature_extractor(raw_speech=input_speech, return_tensors="ms").input_features @@ -1125,8 +1125,8 @@ def test_large_batched_generation(self): @slow def test_tiny_en_batched_generation(self): set_seed(0) - processor = WhisperProcessor.from_pretrained("openai/whisper-tiny.en", from_pt=True) - model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en", from_pt=True) + processor = WhisperProcessor.from_pretrained("openai/whisper-tiny.en") + model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en") input_speech = self._load_datasamples(4) input_features = processor.feature_extractor(raw_speech=input_speech, return_tensors="ms").input_features @@ -1162,8 +1162,8 @@ def test_tiny_en_batched_generation(self): @slow def test_tiny_timestamp_generation(self): set_seed(0) - processor = WhisperProcessor.from_pretrained("openai/whisper-tiny", from_pt=True) - model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny", from_pt=True) + processor = WhisperProcessor.from_pretrained("openai/whisper-tiny") + model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny") input_speech = np.concatenate(self._load_datasamples(4)) input_features = processor.feature_extractor(raw_speech=input_speech, return_tensors="ms").input_features @@ -1225,8 +1225,8 @@ def test_tiny_timestamp_generation(self): @slow def test_tiny_token_timestamp_generation(self): set_seed(0) - processor = WhisperProcessor.from_pretrained("openai/whisper-tiny", from_pt=True) - model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny", from_pt=True) + processor = WhisperProcessor.from_pretrained("openai/whisper-tiny") + model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny") model.generation_config.alignment_heads = [[2, 2], [3, 0], [3, 2], [3, 3], [3, 4], [3, 5]] input_speech = self._load_datasamples(4) @@ -1253,7 +1253,7 @@ def test_tiny_token_timestamp_generation(self): def test_tiny_specaugment_librispeech(self): set_seed(0) # Apply SpecAugment - model = WhisperModel.from_pretrained("openai/whisper-tiny", apply_spec_augment=True, from_pt=True) + model = WhisperModel.from_pretrained("openai/whisper-tiny", apply_spec_augment=True) # Set model to training mode to enable SpecAugment model.set_train() input_speech = self._load_datasamples(1) @@ -1284,8 +1284,8 @@ def test_tiny_specaugment_librispeech(self): @slow def test_generate_with_prompt_ids(self): - processor = WhisperProcessor.from_pretrained("openai/whisper-tiny", from_pt=True) - model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny", from_pt=True) + processor = WhisperProcessor.from_pretrained("openai/whisper-tiny") + model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny") input_speech = self._load_datasamples(4)[-1:] input_features = processor(input_speech, return_tensors="ms").input_features @@ -1301,8 +1301,8 @@ def test_generate_with_prompt_ids(self): @slow def test_generate_with_prompt_ids_and_forced_decoder_ids(self): - processor = WhisperProcessor.from_pretrained("openai/whisper-tiny", from_pt=True) - model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny", from_pt=True) + processor = WhisperProcessor.from_pretrained("openai/whisper-tiny") + model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny") input_speech = self._load_datasamples(1) input_features = processor(input_speech, return_tensors="ms").input_features task = "translate" @@ -1320,8 +1320,8 @@ def test_generate_with_prompt_ids_and_forced_decoder_ids(self): @slow def test_generate_with_prompt_ids_and_no_non_prompt_forced_decoder_ids(self): - processor = WhisperProcessor.from_pretrained("openai/whisper-tiny.en", from_pt=True) - model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en", from_pt=True) + processor = WhisperProcessor.from_pretrained("openai/whisper-tiny.en") + model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en") input_speech = self._load_datasamples(1) input_features = processor(input_speech, return_tensors="ms").input_features prompt = "test prompt" diff --git a/tests/ut/transformers/models/xlm_roberta/test_modeling_xlm_roberta.py b/tests/ut/transformers/models/xlm_roberta/test_modeling_xlm_roberta.py index 7f7b6d69a..30feb4546 100644 --- a/tests/ut/transformers/models/xlm_roberta/test_modeling_xlm_roberta.py +++ b/tests/ut/transformers/models/xlm_roberta/test_modeling_xlm_roberta.py @@ -28,7 +28,7 @@ class XLMRobertaModelIntegrationTest(MindNLPTestCase): @pytest.mark.download def test_xlm_roberta_base(self): """test_xlm_roberta_base""" - model = XLMRobertaModel.from_pretrained("xlm-roberta-base", from_pt=True) + model = XLMRobertaModel.from_pretrained("xlm-roberta-base") input_ids = mindspore.tensor([[0, 581, 10269, 83, 99942, 136, 60742, 23, 70, 80583, 18276, 2]]) # The dog is cute and lives in the garden house @@ -44,7 +44,7 @@ def test_xlm_roberta_base(self): @pytest.mark.download def test_xlm_roberta_large(self): """test_xlm_roberta_large""" - model = XLMRobertaModel.from_pretrained("xlm-roberta-large", from_pt=True) + model = XLMRobertaModel.from_pretrained("xlm-roberta-large") input_ids = mindspore.tensor([[0, 581, 10269, 83, 99942, 136, 60742, 23, 70, 80583, 18276, 2]]) # The dog is cute and lives in the garden house