adapter-hub / adapters

A Unified Library for Parameter-Efficient and Modular Transfer Learning

Home Page:https://docs.adapterhub.ml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

load adapters from safetensor files (enhancement)

swoldemichael opened this issue · comments

commented

I tried loading my adapter after converting the pickle files into safetensors.

AutoAdapterModel.from_pretrained loads with safetensors (GOOD)

For example: model = AutoAdapterModel.from_pretrained("roberta-base", use_safetensors=True)

However when loading the adapter to the model, it is always looking for the pickle (bin) versions. (NOT SUPPORTED)

Moving forward, I think support for safetensors should be provided.

Afterwards, I uploaded the pickle versions and it did work with those.

For example load_adapters should be enhanced with:

model.load_adapter("solwol/my-awesome-adapter", source="hf", set_active=True, use_safetensors=True)

Screenshot 2024-03-24 at 17-56-11 solwol_my-awesome-adapter at main

commented

I mentioned the use of use_safetensors in AutoAdapterModel.from_pretrained("roberta-base", use_safetensors=True).
But the flag is not required as models like roberta-base are converted into safetensors.

The issue with the load_adapter method is that it always looks for the pickle binaries to load the weights. When I put the pickle bins back, it downloaded all files including safetensors, but uses the pickle bins.

Moving forward the enhancement should work with no pickle files present but all binaries provided in safetensors. I hope this makes sense.

Support for safetensors is currently being added in #692, thanks for your suggestion!