fix typos in the tests directory (#36717)

This commit is contained in:
Afanti
2025-03-18 01:45:57 +08:00
committed by GitHub
parent cbfb8d7b27
commit 7f5077e536
14 changed files with 22 additions and 22 deletions

View File

@@ -193,7 +193,7 @@ class GenerationConfigTest(unittest.TestCase):
generation_config_bad_temperature.update(temperature=None)
self.assertEqual(len(captured_warnings), 0)
# Impossible sets of contraints/parameters will raise an exception
# Impossible sets of constraints/parameters will raise an exception
with self.assertRaises(ValueError):
GenerationConfig(do_sample=False, num_beams=1, num_return_sequences=2)
with self.assertRaises(ValueError):

View File

@@ -751,7 +751,7 @@ class LogitsProcessorTest(unittest.TestCase):
scores = self._get_uniform_logits(batch_size, vocab_size)
processed_scores = logits_processor(input_ids, scores)
self.assertTrue(torch.isneginf(processed_scores[:, bos_token_id + 1 :]).all())
# score for bos_token_id shold be zero
# score for bos_token_id should be zero
self.assertListEqual(processed_scores[:, bos_token_id].tolist(), 4 * [0])
# processor should not change logits in-place
@@ -972,7 +972,7 @@ class LogitsProcessorTest(unittest.TestCase):
watermark = WatermarkLogitsProcessor(vocab_size=vocab_size, device=input_ids.device)
# use fixed id for last token, needed for reprodicibility and tests
# use fixed id for last token, needed for reproducibility and tests
input_ids[:, -1] = 10
scores_wo_bias = scores[:, -1].clone()
out = watermark(input_ids=input_ids, scores=scores)

View File

@@ -256,7 +256,7 @@ class StoppingCriteriaTestCase(unittest.TestCase):
]
)
# trigger stopping when at leat one criteria is satisfied, one value per batch
# trigger stopping when at least one criteria is satisfied, one value per batch
self.assertTrue(criteria(inputs["input_ids"], scores))
# return False when neither is satisfied
@@ -283,7 +283,7 @@ class StoppingCriteriaTestCase(unittest.TestCase):
]
)
# trigger stopping when at leat one criteria is satisfied
# trigger stopping when at least one criteria is satisfied
self.assertListEqual(criteria(inputs["input_ids"], scores).tolist(), [True, False, False])
# False when neither is satisfied

View File

@@ -173,7 +173,7 @@ class GenerationTesterMixin:
def _check_similar_generate_outputs(self, output_1, output_2, atol=1e-5, rtol=1e-5):
"""
Checks whether a pair of generate outputs are similar. Two `generate` call outputs are considered similar in
the following siturations:
the following situations:
1. The sequences are the same
2. The sequences are different, but the scores up to (and including) the first mismatch are nearly identical
"""
@@ -1617,7 +1617,7 @@ class GenerationTesterMixin:
embed_dim = getattr(text_config, "d_model", text_config.hidden_size)
per_head_embed_dim = embed_dim // num_attention_heads
# some models have diffent num-head for query vs key/value so we need to assign correct value
# some models have different num-head for query vs key/value so we need to assign correct value
# BUT only after `per_head_embed_dim` is set
num_attention_heads = (
text_config.num_key_value_heads
@@ -2316,7 +2316,7 @@ class GenerationTesterMixin:
def _test_attention_implementation(self, attn_implementation):
"""
Compares the output of generate with the eager attention implementation against other implementations.
NOTE: despite the test logic being the same, different implementations actually need diferent decorators, hence
NOTE: despite the test logic being the same, different implementations actually need different decorators, hence
this separate function.
"""
max_new_tokens = 30
@@ -4619,7 +4619,7 @@ class GenerationIntegrationTests(unittest.TestCase):
self.assertTrue(diff < 1e-4)
def test_generate_input_ids_as_kwarg(self):
"""Test that `input_ids` work equaly as a positional and keyword argument in decoder-only models"""
"""Test that `input_ids` work equally as a positional and keyword argument in decoder-only models"""
article = "I need input_ids to generate"
tokenizer = AutoTokenizer.from_pretrained("hf-internal-testing/tiny-random-gpt2")
model = AutoModelForCausalLM.from_pretrained("hf-internal-testing/tiny-random-gpt2", max_length=15)
@@ -4636,7 +4636,7 @@ class GenerationIntegrationTests(unittest.TestCase):
self.assertEqual(output_sequences.shape, (1, 15))
def test_generate_input_ids_as_encoder_kwarg(self):
"""Test that `input_ids` work equaly as a positional and keyword argument in encoder-decoder models"""
"""Test that `input_ids` work equally as a positional and keyword argument in encoder-decoder models"""
article = "Justin Timberlake and Jessica Biel, welcome to parenthood."
tokenizer = AutoTokenizer.from_pretrained("hf-internal-testing/tiny-random-bart")
model = AutoModelForSeq2SeqLM.from_pretrained("hf-internal-testing/tiny-random-bart")