inseq-team / inseq

Interpretability for sequence generation models 🐛 🔍
https://inseq.org
Apache License 2.0
378 stars 36 forks source link

Add support for PEFT models #197

Open DanielSc4 opened 1 year ago

DanielSc4 commented 1 year ago

Add support for PEFT models

Description

Currently, only models corresponding to the PreTrainedModel instance are supported. It would be useful to add support for models using Parameter-Efficient Fine-Tuning (🤗 PEFT) methods.

Motivation

Adding support for 🤗 PEFT models would allow the same analyses to be performed on models optimised and trained to be efficient on consumer hardware.

Additional context

Mostly tbd, as PEFT uses a small number of different (trainable) parameters to those in the original PreTrainedModel model.

Commit to Help

gsarti commented 1 year ago

Thanks for the report @DanielSc4! We'll evaluate how complex it would be to support out-of-the-box PeftModel classes in Inseq.

In the meantime, a viable workaround is to use model.merge_and_unload() to convert the model in its equivalent type in transformers (XXXForSeq2SeqLM or XXXForCausalLM) before passing it to inseq.load_model.