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

Improving Pipelines by defaulting to framework='tf' when pytorch seems unavailable. #7728

Merged
merged 2 commits into from Oct 15, 2020

Conversation

Narsil
Copy link
Contributor

@Narsil Narsil commented Oct 12, 2020

What does this PR do?

When loading a model that was tf only and by passing only model by string without framework argument, it would fail with an odd error message:

>>> transformers.AutoModel.from_pretrained('Narsil/small')
OSError: Can't load weights for 'Narsil/small'. Make sure that:
- 'Narsil/small' is a correct model identifier listed on 'https://huggingface.co/models' (It exists and contains tf_model.h5)
- or 'Narsil/small' is the correct path to a directory containing a file named one of pytorch_model.bin, tf_model.h5, model.ckpt.

This PR corrects the get_framework that happens very early in the pipeline to detect the type of model
automatically. It does trigger an early download, but that will happen anyway later.

Before submitting

  • This PR fixes a typo or improves the docs (you can dimiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to the it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors which may be interested in your PR.

@mfuntowicz

Copy link
Member

@LysandreJik LysandreJik 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 @Narsil!

@Narsil
Copy link
Contributor Author

Narsil commented Oct 12, 2020

Actually, This introduced a pretty big bug where

nlp = pipeline(task) 

Would not work anymore. I tried a different solution around that.

defaults

Adding a new tests for each pipeline to check that pipeline(task) works
too without manually adding the framework too.
Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Cool, great that you completed the CI.

@@ -823,3 +833,4 @@ def test_pt_defaults(self):
for task in self.pipelines:
with self.subTest(msg="Testing Torch defaults with PyTorch and {}".format(task)):
pipeline(task, framework="pt")
pipeline(task)
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for completing the suite!

@Narsil Narsil merged commit 0911b6b into huggingface:master Oct 15, 2020
@Narsil Narsil deleted the pipelines_tf_auto branch October 15, 2020 07:42
fabiocapsouza pushed a commit to fabiocapsouza/transformers that referenced this pull request Nov 15, 2020
…s unavailable. (huggingface#7728)

* Improving Pipelines by defaulting to framework='tf' when

pytorch seems unavailable.

* Actually changing the default resolution order to account for model
defaults

Adding a new tests for each pipeline to check that pipeline(task) works
too without manually adding the framework too.
fabiocapsouza added a commit to fabiocapsouza/transformers that referenced this pull request Nov 15, 2020
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.

None yet

2 participants