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

[AutoModel] Add AutoModelForTextEncoding #24305

Merged
merged 9 commits into from
Jun 23, 2023

Conversation

sanchit-gandhi
Copy link
Contributor

What does this PR do?

Adds AutoModel for text encoding (used in the circumstance when you want to extract the text encoder from an encoder-decoder architecture).

This facilitates loading a t5 encoder from t5 enc-dec model weights (as is done in Music Gen in #24109)

@@ -1011,6 +1011,36 @@
]
)

MODEL_FOR_TEXT_ENCODING_MAPPING_NAMES = OrderedDict(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this list good for you @amyeroberts? It's the most popular encoder-only architectures, and enc-dec ones where we have the encoder model separated as an import

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep! We can always add as needed :)

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

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

Thanks for adding!

Just a comment on some potential missing imports for TF model in the init

@@ -1011,6 +1011,36 @@
]
)

MODEL_FOR_TEXT_ENCODING_MAPPING_NAMES = OrderedDict(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep! We can always add as needed :)

@@ -716,6 +716,13 @@ def __init__(self, *args, **kwargs):
requires_backends(self, ["torch"])


class AutoModelForTextEncoding(metaclass=DummyObject):
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should be the equivalent TFAutoModelForTextEncoding in dummy_tf_objects.py

Copy link
Contributor Author

@sanchit-gandhi sanchit-gandhi Jun 16, 2023

Choose a reason for hiding this comment

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

Ah perfect! Thanks for flagging! Resolved in 8b003f7

@@ -1084,6 +1084,7 @@
"AutoModelForSequenceClassification",
"AutoModelForSpeechSeq2Seq",
"AutoModelForTableQuestionAnswering",
"AutoModelForTextEncoding",
Copy link
Collaborator

Choose a reason for hiding this comment

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

The TF equivalent class should be in this init too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved in 8b003f7

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jun 16, 2023

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

@sanchit-gandhi sanchit-gandhi merged commit ea91c2a into huggingface:main Jun 23, 2023
@sanchit-gandhi sanchit-gandhi deleted the auto-text-encoder branch June 23, 2023 09:01
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