-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Load generation config from nested configs #42922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
bf730c3
7b469ff
83d985c
dcf820f
d628f35
71b057d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,7 +67,6 @@ | |
| AutoModelForImageTextToText, | ||
| AutoModelForSeq2SeqLM, | ||
| AutoModelForSpeechSeq2Seq, | ||
| AutoModelForVision2Seq, | ||
| BartForConditionalGeneration, | ||
| BartTokenizer, | ||
| DataCollatorWithFlattening, | ||
|
|
@@ -4401,7 +4400,7 @@ def test_generate_vision2text_conditioning(self): | |
| """Test that `decoder_input_ids` can be used to condition the generation in vision-to-text models""" | ||
| pixel_values = floats_tensor((2, 3, 30, 30)) | ||
| conditioning_input = torch.tensor([[10], [10]]) # this should be the 2nd output token, after the BOS token | ||
| model = AutoModelForVision2Seq.from_pretrained( | ||
| model = AutoModelForImageTextToText.from_pretrained( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks unrelated? Nothing to change just noticed
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the mapping was deprecated in favor of |
||
| "hf-internal-testing/tiny-random-VisionEncoderDecoderModel-vit-gpt2" | ||
| ) | ||
| pixel_values = pixel_values.to(torch_device) | ||
|
|
@@ -4421,6 +4420,24 @@ def test_generate_vision2text_conditioning(self): | |
| self.assertTrue(np.array_equal(output_sequences_decoder_input_ids, output_sequences_input_ids)) | ||
| self.assertTrue(np.array_equal(output_sequences_decoder_input_ids[:, 1:2], conditioning_input)) | ||
|
|
||
| @pytest.mark.generate | ||
| def test_load_generation_config_from_text_subconfig(self): | ||
| """ | ||
| Tests that generation config is be loaded from model's `text_config` when not present | ||
| in the model repo. We should infer the text config correctly and re-use special tokens | ||
| for generation. See https://github.com/huggingface/transformers/issues/42794 | ||
| """ | ||
| model = AutoModelForImageTextToText.from_pretrained( | ||
| "hf-internal-testing/tiny-random-LlavaForConditionalGeneration-no-generation-config", | ||
| device_map=torch_device, | ||
| ) | ||
| self.assertTrue(model.generation_config.eos_token_id is not None) | ||
| self.assertTrue(model.generation_config.bos_token_id is not None) | ||
| self.assertTrue(model.generation_config.pad_token_id is not None) | ||
|
|
||
| # test that we can generate without inputs, i.e. from BOS | ||
| _ = model.generate() | ||
|
|
||
| @require_read_token | ||
| @slow | ||
| @require_torch_accelerator | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.