Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Conversation

@joecummings
Copy link
Member

@joecummings joecummings commented Sep 30, 2022

Add the ability to load a T5 model from pretrained HuggingFace weights

Changes

  • Adds a build_model_from_huggingface_ckpt static method to the T5Bundler.

Testing

  • Adds integration tests to check that an HF model loaded with HF weights and a TorchText T5 model loaded with HF weights both return the same thing when applied to data

Future considerations: This does not support loading from external URLs - planning on adding this in a follow-up Diff from the internal FB side so I can test with Manifold (+ possible GDrive, static public links, Github).

@joecummings joecummings requested a review from Nayef211 October 3, 2022 18:14
@joecummings joecummings marked this pull request as ready for review October 3, 2022 18:14
@joecummings joecummings changed the title Add ability to load HF checkpoints into T5 model [Feature] Add ability to load HF checkpoints into T5 model Oct 3, 2022
Copy link
Contributor

@Nayef211 Nayef211 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 this capability @joecummings! I would recommend pulling in these changes and ensuring it works with internal Meta infra before merging in the PR. 😄

) -> T5Model:
"""Build T5Model model from a HuggingFace checkpoint.
Note: Only works with Huggingface models saved in the PyTorch format. Will not work \
Copy link
Contributor

@Nayef211 Nayef211 Oct 4, 2022

Choose a reason for hiding this comment

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

nit: do we need the \ in the docstrings?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry - not entirely sure what you're referring to here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry updated the comment. Looks like backslash characters don't show up when you put quotes around them which was a noob mistake 😅

@joecummings joecummings merged commit de54db6 into pytorch:main Oct 5, 2022
@joecummings joecummings deleted the hf-to-pt-t5 branch October 5, 2022 12:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants