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

Add text2text-generation-with-past test for encoder-decoder model #1338

Conversation

mht-sharma
Copy link
Contributor

@mht-sharma mht-sharma commented Sep 3, 2023

What does this PR do?

Creating a test for an text2text-generation-with-past tasks for an encoder-decoder model #851

  • Fixes a bug to use --with-past with the model

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

Copy link
Member

@michaelbenayoun michaelbenayoun left a comment

Choose a reason for hiding this comment

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

Left a few nits.
I do not understand everyting, but looks good to me from what I could read.
Thanks @mht-sharma !

for model_id in model_ids:
if (
model_arch == "encoder-decoder"
and use_cache is True
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
and use_cache is True
and use_cache

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess this is the common terminology used in the repo, to explicitly check the value?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's me who advocated to use that :D But more and more I agree with Michael, we should not explicitly check is True when the type is bool, we should only for Optional[bool].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess this explicit check is something which is also followed in the transformers, I remember Lewis mentioning this, but yeah I agree

Comment on lines +3085 to +3091
def _get_model_ids(self, model_arch):
model_ids = MODEL_NAMES[model_arch]
if isinstance(model_ids, dict):
model_ids = list(model_ids.keys())
else:
model_ids = [model_ids]
return model_ids
Copy link
Member

Choose a reason for hiding this comment

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

So what you call model_arch is a "model type" like bert, t5 and so on?
This function returns a list of model ids from the Hub for a given architecture?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a helper function for the test to get the list of model_ids for a given model_arch(model_type) from MODEL_NAMES. Earlier there was one model_id for a model_arch. But with this PR there can be multiple (Format is same as used in onnx export).

for model_id in model_ids:
if (
model_arch == "encoder-decoder"
and use_cache is True
Copy link
Member

Choose a reason for hiding this comment

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

nit

Suggested change
and use_cache is True
and use_cache

for model_id in model_ids:
if (
model_arch == "encoder-decoder"
and use_cache is True
Copy link
Member

Choose a reason for hiding this comment

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

Same

@mht-sharma mht-sharma changed the title Add test autoreg decoder in encoder decoder models Add text2text-generation-with-past test for encoder-decoder model Sep 4, 2023
Copy link
Contributor

@fxmarty fxmarty left a comment

Choose a reason for hiding this comment

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

LGTM thanks for adding the tests! It is fine to me as long as they pass.

@mht-sharma
Copy link
Contributor Author

LGTM thanks for adding the tests! It is fine to me as long as they pass.

Merging as the test error are not related to PR

@mht-sharma mht-sharma merged commit f729266 into huggingface:main Sep 7, 2023
64 of 68 checks passed
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.

3 participants