Skip to content
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

Generation: fix test #34369

Merged
merged 4 commits into from
Oct 29, 2024
Merged

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
Member

@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
Member

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
Member

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
20 checks passed
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