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 support for loading adapters from HuggingFace Model Hub #162

Merged
merged 4 commits into from
Jun 11, 2021

Conversation

calpt
Copy link
Member

@calpt calpt commented May 6, 2021

WIP for adding HuggingFace's model hub as a second source for loading adapters. Implementation via https://github.com/huggingface/huggingface_hub.

Example

Adapter: https://huggingface.co/calpt/adapter-bert-base-squad1

Loading from HF Hub

model = BertForSequenceClassification.from_pretrained("bert-base-uncased")
model.load_adapter("calpt/adapter-bert-base-squad1", source="hf")

Loading (the same adapter) from AdapterHub

model = BertForSequenceClassification.from_pretrained("bert-base-uncased")
model.load_adapter("squad1", config="houlsby", source="ah")  # source="ah" is default & can be omitted

@calpt calpt marked this pull request as ready for review May 19, 2021 14:22
@osanseviero
Copy link

Hi @calpt!

This PR looks awesome 🔥 thank you! I'll follow-up with some things from our side. What do you think of having a code snippet and a tag so people can search for all adapters in the 🤗 Hub?

This is an example of a code snippet that we could have. Let me know what you think

from transformers import AutoModelWithHeads

model = AutoModelWithHeads.from_pretrained("{model inferred from model_name in adapter_config.json}")
model.load_adapter("model name", source="hf")

Thanks once more!

@calpt
Copy link
Member Author

calpt commented May 21, 2021

Hi @osanseviero!

Looks great! Thanks for looking into this and let me know if you need anything else from our side.

@osanseviero
Copy link

Hey Calpt! Nothing else from your side at the moment until this PR is submitted. We're adding code snippets for adapter transformers which reads from adapter_config.json as discussed 🚀 🌔 . Feel free to take a look:

huggingface/huggingface_hub#62

@osanseviero
Copy link

From the Hub side, if you add - adapter-transformers to the tags, you get a working code snippet that uses adapter_config.json. Check out https://huggingface.co/calpt/adapter-bert-base-squad1 for example.

@calpt calpt changed the base branch from master to develop June 11, 2021 13:01
@calpt
Copy link
Member Author

calpt commented Jun 11, 2021

@osanseviero Looks great! Thanks so much for your support on this! We'll add some documentation on our side and release this with the next feature update.

@calpt calpt merged commit d4b61f1 into adapter-hub:develop Jun 11, 2021
@calpt calpt deleted the dev/hf-hub branch June 11, 2021 13:05
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