Skip to content

Generation: fix test#34369

Merged
zucchini-nlp merged 4 commits intohuggingface:mainfrom
zucchini-nlp:generation-test-embeds
Oct 29, 2024
Merged

Generation: fix test#34369
zucchini-nlp merged 4 commits intohuggingface:mainfrom
zucchini-nlp:generation-test-embeds

Conversation

@zucchini-nlp
Copy link
Member

What does this PR do?

Fixes one part of the test that was not being triggered when we run it with pytest because it had typo in cache_position(S). Fixing the typo resulted in a whole bunch of errors most of which are caused by apparently non-deterministic output when setting the repetition_penalty. Thus I moved the test for beam-search + input-embeds to another place

The main idea when writing this test was to make sure beam search works with inputs embeds for decoder-only models that now support new cache format, so I think the change should be fine

@zucchini-nlp zucchini-nlp requested a review from gante October 24, 2024 09:41
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Contributor

@gante gante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

# code is up to date with our most recent standards
if (
"inputs_embeds" in prepare_inputs_for_generation_args
and "cache_positions" in prepare_inputs_for_generation_args
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this part was never executed, because of the typo in cache_positions -- correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep :)

outputs_from_ids = model.generate(
input_ids, max_new_tokens=5, return_dict_in_generate=True, output_scores=True
)
outputs_from_ids = model.generate(input_ids, max_new_tokens=5, **generation_kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: max_new_tokens can be moved to generation_kwargs

@gante gante requested a review from ArthurZucker October 25, 2024 11:56
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@zucchini-nlp zucchini-nlp merged commit 808d6c5 into huggingface:main Oct 29, 2024
BernardZach pushed a commit to BernardZach/transformers that referenced this pull request Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants