From 5b573bebb9793c393da035afd985c7078a460498 Mon Sep 17 00:00:00 2001 From: co63oc Date: Thu, 1 May 2025 21:58:58 +0800 Subject: [PATCH] Fix typos in strings and comments (#37910) --- examples/legacy/multiple_choice/utils_multiple_choice.py | 2 +- examples/legacy/question-answering/run_squad.py | 4 ++-- examples/legacy/question-answering/run_squad_trainer.py | 2 +- examples/legacy/run_transfo_xl.py | 2 +- examples/legacy/seq2seq/pack_dataset.py | 2 +- .../run_speech_recognition_ctc_adapter.py | 2 +- src/transformers/integrations/executorch.py | 2 +- src/transformers/loss/loss_d_fine.py | 4 ++-- src/transformers/models/d_fine/configuration_d_fine.py | 2 +- src/transformers/models/d_fine/modular_d_fine.py | 2 +- src/transformers/models/sam_hq/modeling_sam_hq.py | 2 +- src/transformers/models/sam_hq/modular_sam_hq.py | 2 +- tests/models/d_fine/test_modeling_d_fine.py | 8 ++++---- tests/models/fsmt/test_modeling_fsmt.py | 2 +- tests/models/gemma2/test_modeling_gemma2.py | 2 +- tests/models/qwen2_5_omni/test_processor_qwen2_5_omni.py | 2 +- tests/models/sam_hq/test_modeling_sam_hq.py | 8 ++++---- 17 files changed, 25 insertions(+), 25 deletions(-) diff --git a/examples/legacy/multiple_choice/utils_multiple_choice.py b/examples/legacy/multiple_choice/utils_multiple_choice.py index ddae47e588..cc07ffb2ef 100644 --- a/examples/legacy/multiple_choice/utils_multiple_choice.py +++ b/examples/legacy/multiple_choice/utils_multiple_choice.py @@ -539,7 +539,7 @@ def convert_examples_to_features( if "num_truncated_tokens" in inputs and inputs["num_truncated_tokens"] > 0: logger.info( "Attention! you are cropping tokens (swag task is ok). " - "If you are training ARC and RACE and you are poping question + options, " + "If you are training ARC and RACE and you are popping question + options, " "you need to try to use a bigger max seq length!" ) diff --git a/examples/legacy/question-answering/run_squad.py b/examples/legacy/question-answering/run_squad.py index 5ba8309fee..39ba14a12a 100644 --- a/examples/legacy/question-answering/run_squad.py +++ b/examples/legacy/question-answering/run_squad.py @@ -745,7 +745,7 @@ def main(): args.tokenizer_name if args.tokenizer_name else args.model_name_or_path, do_lower_case=args.do_lower_case, cache_dir=args.cache_dir if args.cache_dir else None, - use_fast=False, # SquadDataset is not compatible with Fast tokenizers which have a smarter overflow handeling + use_fast=False, # SquadDataset is not compatible with Fast tokenizers which have a smarter overflow handling ) model = AutoModelForQuestionAnswering.from_pretrained( args.model_name_or_path, @@ -795,7 +795,7 @@ def main(): # Load a trained model and vocabulary that you have fine-tuned model = AutoModelForQuestionAnswering.from_pretrained(args.output_dir) # , force_download=True) - # SquadDataset is not compatible with Fast tokenizers which have a smarter overflow handeling + # SquadDataset is not compatible with Fast tokenizers which have a smarter overflow handling # So we use use_fast=False here for now until Fast-tokenizer-compatible-examples are out tokenizer = AutoTokenizer.from_pretrained(args.output_dir, do_lower_case=args.do_lower_case, use_fast=False) model.to(args.device) diff --git a/examples/legacy/question-answering/run_squad_trainer.py b/examples/legacy/question-answering/run_squad_trainer.py index 159569c327..d3730d1bc0 100644 --- a/examples/legacy/question-answering/run_squad_trainer.py +++ b/examples/legacy/question-answering/run_squad_trainer.py @@ -122,7 +122,7 @@ def main(): tokenizer = AutoTokenizer.from_pretrained( model_args.tokenizer_name if model_args.tokenizer_name else model_args.model_name_or_path, cache_dir=model_args.cache_dir, - use_fast=False, # SquadDataset is not compatible with Fast tokenizers which have a smarter overflow handeling + use_fast=False, # SquadDataset is not compatible with Fast tokenizers which have a smarter overflow handling ) model = AutoModelForQuestionAnswering.from_pretrained( model_args.model_name_or_path, diff --git a/examples/legacy/run_transfo_xl.py b/examples/legacy/run_transfo_xl.py index 7da9ee7fe9..1af855be13 100755 --- a/examples/legacy/run_transfo_xl.py +++ b/examples/legacy/run_transfo_xl.py @@ -71,7 +71,7 @@ def main(): # You can also build the corpus yourself using TransfoXLCorpus methods # The pre-processing involve computing word frequencies to prepare the Adaptive input and SoftMax # and tokenizing the dataset - # The pre-processed corpus is a convertion (using the conversion script ) + # The pre-processed corpus is a conversion (using the conversion script ) corpus = TransfoXLCorpus.from_pretrained(args.model_name) va_iter = corpus.get_iterator("valid", args.batch_size, args.tgt_len, device=device, ext_len=args.ext_len) diff --git a/examples/legacy/seq2seq/pack_dataset.py b/examples/legacy/seq2seq/pack_dataset.py index 5c13c74f41..034537d1cf 100755 --- a/examples/legacy/seq2seq/pack_dataset.py +++ b/examples/legacy/seq2seq/pack_dataset.py @@ -40,7 +40,7 @@ def pack_examples(tok, src_examples, tgt_examples, max_tokens=1024): for src, tgt in tqdm(sorted_examples[1:]): cand_src = new_src + " " + src cand_tgt = new_tgt + " " + tgt - if is_too_big(cand_src) or is_too_big(cand_tgt): # cant fit, finalize example + if is_too_big(cand_src) or is_too_big(cand_tgt): # can't fit, finalize example finished_src.append(new_src) finished_tgt.append(new_tgt) new_src, new_tgt = src, tgt diff --git a/examples/pytorch/speech-recognition/run_speech_recognition_ctc_adapter.py b/examples/pytorch/speech-recognition/run_speech_recognition_ctc_adapter.py index 511e7bc3d4..8c1a66c7f6 100755 --- a/examples/pytorch/speech-recognition/run_speech_recognition_ctc_adapter.py +++ b/examples/pytorch/speech-recognition/run_speech_recognition_ctc_adapter.py @@ -804,7 +804,7 @@ def main(): if "common_voice" in data_args.dataset_name: kwargs["language"] = config_name - # make sure that adapter weights are saved seperately + # make sure that adapter weights are saved separately adapter_file = WAV2VEC2_ADAPTER_SAFE_FILE.format(data_args.target_language) adapter_file = os.path.join(training_args.output_dir, adapter_file) logger.info(f"Saving adapter weights under {adapter_file}...") diff --git a/src/transformers/integrations/executorch.py b/src/transformers/integrations/executorch.py index 88dfe4640c..c0a3839afb 100644 --- a/src/transformers/integrations/executorch.py +++ b/src/transformers/integrations/executorch.py @@ -516,7 +516,7 @@ def convert_and_export_with_cache( "Dynamic shapes spec will be ignored by convert_and_export_with_cache for torch < 2.6.0." ) if strict is not None: - logging.warning("The strict flag will be ingored by convert_and_export_with_cache for torch < 2.6.0.") + logging.warning("The strict flag will be ignored by convert_and_export_with_cache for torch < 2.6.0.") # We have to keep this path for BC. # # Due to issue https://github.com/pytorch/pytorch/issues/128394, we need to switch to use an internal diff --git a/src/transformers/loss/loss_d_fine.py b/src/transformers/loss/loss_d_fine.py index 722c5949c1..010c044924 100644 --- a/src/transformers/loss/loss_d_fine.py +++ b/src/transformers/loss/loss_d_fine.py @@ -152,8 +152,8 @@ def bbox2distance(points, bbox, max_num_bins, reg_scale, up, eps=0.1): points (Tensor): (n, 4) [x, y, w, h], where (x, y) is the center. bbox (Tensor): (n, 4) bounding boxes in "xyxy" format. max_num_bins (float): Maximum bin value. - reg_scale (float): Controling curvarture of W(n). - up (Tensor): Controling upper bounds of W(n). + reg_scale (float): Controlling curvarture of W(n). + up (Tensor): Controlling upper bounds of W(n). eps (float): Small value to ensure target < max_num_bins. Returns: diff --git a/src/transformers/models/d_fine/configuration_d_fine.py b/src/transformers/models/d_fine/configuration_d_fine.py index 4775203f19..7acd58c96a 100644 --- a/src/transformers/models/d_fine/configuration_d_fine.py +++ b/src/transformers/models/d_fine/configuration_d_fine.py @@ -28,7 +28,7 @@ logger = logging.get_logger(__name__) # TODO: Attribute map assignment logic should be fixed in modular -# as well as super() call parsing becuase otherwise we cannot re-write args after initialization +# as well as super() call parsing because otherwise we cannot re-write args after initialization class DFineConfig(PretrainedConfig): """ This is the configuration class to store the configuration of a [`DFineModel`]. It is used to instantiate a D-FINE diff --git a/src/transformers/models/d_fine/modular_d_fine.py b/src/transformers/models/d_fine/modular_d_fine.py index adbfa68477..f4fd0992e4 100644 --- a/src/transformers/models/d_fine/modular_d_fine.py +++ b/src/transformers/models/d_fine/modular_d_fine.py @@ -47,7 +47,7 @@ logger = logging.get_logger(__name__) # TODO: Attribute map assignment logic should be fixed in modular -# as well as super() call parsing becuase otherwise we cannot re-write args after initialization +# as well as super() call parsing because otherwise we cannot re-write args after initialization class DFineConfig(PretrainedConfig): """ This is the configuration class to store the configuration of a [`DFineModel`]. It is used to instantiate a D-FINE diff --git a/src/transformers/models/sam_hq/modeling_sam_hq.py b/src/transformers/models/sam_hq/modeling_sam_hq.py index 21d9a60f2d..80a276b5bd 100644 --- a/src/transformers/models/sam_hq/modeling_sam_hq.py +++ b/src/transformers/models/sam_hq/modeling_sam_hq.py @@ -1615,7 +1615,7 @@ class SamHQModel(SamHQPreTrainedModel): Input boxes for the points, this is used by the prompt encoder to encode the prompt. Generally yields to much better generated masks. The boxes can be obtained by passing a list of list of list to the processor, that will generate a `torch` tensor, with each dimension corresponding respectively to the image batch - size, the number of boxes per image and the coordinates of the top left and botton right point of the box. + size, the number of boxes per image and the coordinates of the top left and bottom right point of the box. In the order (`x1`, `y1`, `x2`, `y2`): - `x1`: the x coordinate of the top left point of the input box diff --git a/src/transformers/models/sam_hq/modular_sam_hq.py b/src/transformers/models/sam_hq/modular_sam_hq.py index b86e300006..50b5f2aecc 100644 --- a/src/transformers/models/sam_hq/modular_sam_hq.py +++ b/src/transformers/models/sam_hq/modular_sam_hq.py @@ -551,7 +551,7 @@ class SamHQModel(SamModel): Input boxes for the points, this is used by the prompt encoder to encode the prompt. Generally yields to much better generated masks. The boxes can be obtained by passing a list of list of list to the processor, that will generate a `torch` tensor, with each dimension corresponding respectively to the image batch - size, the number of boxes per image and the coordinates of the top left and botton right point of the box. + size, the number of boxes per image and the coordinates of the top left and bottom right point of the box. In the order (`x1`, `y1`, `x2`, `y2`): - `x1`: the x coordinate of the top left point of the input box diff --git a/tests/models/d_fine/test_modeling_d_fine.py b/tests/models/d_fine/test_modeling_d_fine.py index 3590ed1035..433db70df2 100644 --- a/tests/models/d_fine/test_modeling_d_fine.py +++ b/tests/models/d_fine/test_modeling_d_fine.py @@ -586,10 +586,10 @@ class DFineModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): self.model_tester.num_labels, ) self.assertEqual(outputs.logits.shape, expected_shape) - # Confirm out_indices was propogated to backbone + # Confirm out_indices was propagated to backbone self.assertEqual(len(model.model.backbone.intermediate_channel_sizes), 3) else: - # Confirm out_indices was propogated to backbone + # Confirm out_indices was propagated to backbone self.assertEqual(len(model.backbone.intermediate_channel_sizes), 3) self.assertTrue(outputs) @@ -618,10 +618,10 @@ class DFineModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): self.model_tester.num_labels, ) self.assertEqual(outputs.logits.shape, expected_shape) - # Confirm out_indices was propogated to backbone + # Confirm out_indices was propagated to backbone self.assertEqual(len(model.model.backbone.intermediate_channel_sizes), 3) else: - # Confirm out_indices was propogated to backbone + # Confirm out_indices was propagated to backbone self.assertEqual(len(model.backbone.intermediate_channel_sizes), 3) self.assertTrue(outputs) diff --git a/tests/models/fsmt/test_modeling_fsmt.py b/tests/models/fsmt/test_modeling_fsmt.py index e10a5fbae9..8c9d007f46 100644 --- a/tests/models/fsmt/test_modeling_fsmt.py +++ b/tests/models/fsmt/test_modeling_fsmt.py @@ -423,7 +423,7 @@ class FSMTHeadTests(unittest.TestCase): def _assert_tensors_equal(a, b, atol=1e-12, prefix=""): - """If tensors not close, or a and b arent both tensors, raise a nice Assertion error.""" + """If tensors not close, or a and b aren't both tensors, raise a nice Assertion error.""" if a is None and b is None: return True try: diff --git a/tests/models/gemma2/test_modeling_gemma2.py b/tests/models/gemma2/test_modeling_gemma2.py index c05f319d5a..d08a5ee6a7 100644 --- a/tests/models/gemma2/test_modeling_gemma2.py +++ b/tests/models/gemma2/test_modeling_gemma2.py @@ -149,7 +149,7 @@ class Gemma2ModelTest(GemmaModelTest, unittest.TestCase): @unittest.skip( reason="HybridCache can't be gathered because it is not iterable. Adding a simple iter and dumping `distributed_iterator`" - " as in Dynamic Cache doesnt work. NOTE: @gante all cache objects would need better compatibility with multi gpu setting" + " as in Dynamic Cache doesn't work. NOTE: @gante all cache objects would need better compatibility with multi gpu setting" ) def test_multi_gpu_data_parallel_forward(self): pass diff --git a/tests/models/qwen2_5_omni/test_processor_qwen2_5_omni.py b/tests/models/qwen2_5_omni/test_processor_qwen2_5_omni.py index 60b4622968..b4b9d99c8e 100644 --- a/tests/models/qwen2_5_omni/test_processor_qwen2_5_omni.py +++ b/tests/models/qwen2_5_omni/test_processor_qwen2_5_omni.py @@ -567,7 +567,7 @@ class Qwen2_5OmniProcessorTest(ProcessorTesterMixin, unittest.TestCase): signature.parameters.get("videos") is not None and signature.parameters["videos"].annotation == inspect._empty ): - self.skipTest(f"{self.processor_class} does not suport video inputs") + self.skipTest(f"{self.processor_class} does not support video inputs") if "feature_extractor" not in self.processor_class.attributes: self.skipTest(f"feature_extractor attribute not present in {self.processor_class}") diff --git a/tests/models/sam_hq/test_modeling_sam_hq.py b/tests/models/sam_hq/test_modeling_sam_hq.py index 6c62d19746..fa5a2a78bc 100644 --- a/tests/models/sam_hq/test_modeling_sam_hq.py +++ b/tests/models/sam_hq/test_modeling_sam_hq.py @@ -244,13 +244,13 @@ class SamHQVisionModelTest(ModelTesterMixin, unittest.TestCase): pass @unittest.skip( - reason="This architecure seem to not compute gradients properly when using GC, check: https://github.com/huggingface/transformers/pull/27124" + reason="This architecture seem to not compute gradients properly when using GC, check: https://github.com/huggingface/transformers/pull/27124" ) def test_training_gradient_checkpointing_use_reentrant(self): pass @unittest.skip( - reason="This architecure seem to not compute gradients properly when using GC, check: https://github.com/huggingface/transformers/pull/27124" + reason="This architecture seem to not compute gradients properly when using GC, check: https://github.com/huggingface/transformers/pull/27124" ) def test_training_gradient_checkpointing_use_reentrant_false(self): pass @@ -682,13 +682,13 @@ class SamHQModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip( - reason="This architecure seem to not compute gradients properly when using GC, check: https://github.com/huggingface/transformers/pull/27124" + reason="This architecture seem to not compute gradients properly when using GC, check: https://github.com/huggingface/transformers/pull/27124" ) def test_training_gradient_checkpointing_use_reentrant(self): pass @unittest.skip( - reason="This architecure seem to not compute gradients properly when using GC, check: https://github.com/huggingface/transformers/pull/27124" + reason="This architecture seem to not compute gradients properly when using GC, check: https://github.com/huggingface/transformers/pull/27124" ) def test_training_gradient_checkpointing_use_reentrant_false(self): pass