committed by
GitHub
parent
fe76b60370
commit
808d6c50f8
@@ -773,7 +773,8 @@ class IdeficsForVisionText2TextTest(IdeficsModelTest, GenerationTesterMixin, uni
|
||||
@unittest.skip(
|
||||
reason="IDEFICS has specific requirements for working with inputs embeds like passing also the ids and pixels"
|
||||
)
|
||||
def test_generate_from_inputs_embeds_decoder_only(self):
|
||||
@parameterized.expand([(1,), (2,)])
|
||||
def test_generate_from_inputs_embeds_decoder_only(self, num_beams):
|
||||
pass
|
||||
|
||||
@unittest.skip(reason="IDEFICS cannot compile due to dynamic control flow when checking inputs")
|
||||
|
||||
@@ -204,7 +204,8 @@ class Mamba2ModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMix
|
||||
pass
|
||||
|
||||
@unittest.skip(reason="To fix, Mamba 2 cache slicing test case is an edge case")
|
||||
def test_generate_from_inputs_embeds_decoder_only(self):
|
||||
@parameterized.expand([(1,), (2,)])
|
||||
def test_generate_from_inputs_embeds_decoder_only(self, num_beams):
|
||||
pass
|
||||
|
||||
@unittest.skip(reason="To fix, Mamba 2 cache slicing test case is an edge case")
|
||||
|
||||
@@ -656,16 +656,21 @@ class MoshiTest(ModelTesterMixin, GenerationTesterMixin, unittest.TestCase):
|
||||
)
|
||||
|
||||
@pytest.mark.generate
|
||||
def test_generate_from_inputs_embeds_decoder_only(self):
|
||||
@parameterized.expand([(1,), (2,)])
|
||||
def test_generate_from_inputs_embeds_decoder_only(self, num_beams):
|
||||
for model_class in self.all_generative_model_classes:
|
||||
config, input_ids, _, inputs_dict = self._get_input_ids_and_config()
|
||||
|
||||
model = model_class(config).to(torch_device).eval()
|
||||
generation_kwargs = {
|
||||
"return_dict_in_generate": True,
|
||||
"output_scores": True,
|
||||
"num_beams": num_beams,
|
||||
"do_sample": False,
|
||||
}
|
||||
|
||||
# Traditional way of generating text
|
||||
outputs_from_ids = model.generate(
|
||||
input_ids, max_new_tokens=5, return_dict_in_generate=True, output_scores=True, **inputs_dict
|
||||
)
|
||||
outputs_from_ids = model.generate(input_ids, max_new_tokens=5, **generation_kwargs, **inputs_dict)
|
||||
self.assertEqual(outputs_from_ids.sequences.shape, (input_ids.shape[0], input_ids.shape[1] + 5))
|
||||
|
||||
# Same thing, but from input embeddings (`input_ids` is passed so the prompt is present in the output)
|
||||
@@ -674,8 +679,7 @@ class MoshiTest(ModelTesterMixin, GenerationTesterMixin, unittest.TestCase):
|
||||
input_ids,
|
||||
inputs_embeds=inputs_embeds,
|
||||
max_new_tokens=5,
|
||||
return_dict_in_generate=True,
|
||||
output_scores=True,
|
||||
**generation_kwargs,
|
||||
**inputs_dict,
|
||||
)
|
||||
|
||||
@@ -686,8 +690,7 @@ class MoshiTest(ModelTesterMixin, GenerationTesterMixin, unittest.TestCase):
|
||||
input_ids,
|
||||
inputs_embeds=random_embeds,
|
||||
max_new_tokens=5,
|
||||
return_dict_in_generate=True,
|
||||
output_scores=True,
|
||||
**generation_kwargs,
|
||||
**inputs_dict,
|
||||
)
|
||||
for i in range(len(outputs_from_rand_embeds.scores)):
|
||||
@@ -697,8 +700,7 @@ class MoshiTest(ModelTesterMixin, GenerationTesterMixin, unittest.TestCase):
|
||||
outputs_from_embeds_wo_ids = model.generate(
|
||||
inputs_embeds=inputs_embeds,
|
||||
max_new_tokens=5,
|
||||
return_dict_in_generate=True,
|
||||
output_scores=True,
|
||||
**generation_kwargs,
|
||||
**inputs_dict,
|
||||
)
|
||||
self.assertListEqual(
|
||||
|
||||
Reference in New Issue
Block a user