Skip to content

Exporters automatic task detection#445

Merged
michaelbenayoun merged 4 commits intohuggingface:mainfrom
michaelbenayoun:exporters_automatic_task_detection
Nov 3, 2022
Merged

Exporters automatic task detection#445
michaelbenayoun merged 4 commits intohuggingface:mainfrom
michaelbenayoun:exporters_automatic_task_detection

Conversation

@michaelbenayoun
Copy link
Member

@michaelbenayoun michaelbenayoun commented Nov 3, 2022

What does this PR do?

This PR enables automatic task detection for optimum.exporters.

  • Task detection for local directories
  • Task detection for model repos on the Hub

@michaelbenayoun michaelbenayoun mentioned this pull request Nov 3, 2022
8 tasks
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Nov 3, 2022

The documentation is not available anymore as the PR was closed or merged.

@julien-c julien-c self-requested a review November 3, 2022 14:07
Comment on lines 678 to 679
# TODO: implement this.
raise NotImplementedError("Cannot infer the task from a local directory yet.")
Copy link
Member

Choose a reason for hiding this comment

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

not sure we even want to support this, in a first version at least

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, changed the message and the exception to something that does not open the door for future support (even though it might come someday).

Copy link
Member

@julien-c julien-c left a comment

Choose a reason for hiding this comment

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

looks food from quick glance!

transformers_info = model_info.transformersInfo
if transformers_info is None or transformers_info.get("auto_model") is None:
raise RuntimeError(f"Could not infer the task from the model repo {model_name_or_path}")
auto_model_class_name = f"{class_name_prefix}{transformers_info['auto_model']}"
Copy link
Member

Choose a reason for hiding this comment

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

i think auto_model can start with TF already in some cases so you just only prepend it if it's not already there

@julien-c
Copy link
Member

julien-c commented Nov 3, 2022

BTW context for anyone reading this PR: the Hub determines AutoModel-type from models' config.json using:

@julien-c
Copy link
Member

julien-c commented Nov 3, 2022

This will pave the way to build a really cool "official" Space under the official ONNX org, WDYT @fxmarty?

e.g. under https://huggingface.co/spaces/onnx/convert (for consistency with other converters)

@fxmarty
Copy link
Contributor

fxmarty commented Nov 3, 2022

LGTM, hopefully we put out a space tonight or tomorrow!

@michaelbenayoun michaelbenayoun merged commit 4e646c0 into huggingface:main Nov 3, 2022
@michaelbenayoun michaelbenayoun deleted the exporters_automatic_task_detection branch November 3, 2022 15:15
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