# CLIP-like models do not support .add\_adapter method

**URL:** <https://discuss.huggingface.co/t/clip-like-models-do-not-support-add-adapter-method/76688>\
**Category:** 🤗Transformers\
**Created:** [March 9, 2024, 7:24pm UTC](https://discuss.huggingface.co/t/clip-like-models-do-not-support-add-adapter-method/76688 "2024-03-09T19:24:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andron00e](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/andron00e/32/21798_2.png) [@Andron00e](https://discuss.huggingface.co/u/Andron00e)\
**Post date:** [March 9, 2024, 7:24pm UTC](https://discuss.huggingface.co/t/clip-like-models-do-not-support-add-adapter-method/76688/1 "2024-03-09T19:24:21Z")

</div>

When working with LoRA, it is common to use .add\_adapter method to supply a particular layers of various NLP models such as DeBERTa, FLAN, T5, etc., with adapter inside those selected layers.  
This method differs from get\_peft\_model, because the first one do not create a wrapper outside basic the model which, sometimes, comes in handy.

The problem is that this .add\_adapter method is not supported for CLIP, ViT and other popular vision models.

If I am wrong, please tell me.  
Best regards.

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [March 10, 2024, 6:58pm UTC](https://discuss.huggingface.co/t/clip-like-models-do-not-support-add-adapter-method/76688/2 "2024-03-10T18:58:20Z")

</div>

Hi,

The following works for me:

```auto
from transformers import AutoModelForImageClassification
from peft import LoraConfig

config = LoraConfig(
    r=16,
    lora_alpha=16,
    target_modules=["query", "value"],
    lora_dropout=0.1,
    bias="none",
    modules_to_save=["classifier"],
)
model = AutoModelForImageClassification.from_pretrained("google/vit-base-patch16-224")

model.add_adapter(config)

for name, param in model.named_parameters():
    print(name, param.shape)

```

This is thanks to the PEFT integration in Transformers: [PEFT integrations](https://huggingface.co/docs/peft/tutorial/peft_integrations#transformers).

See also this tutorial: [Image classification using LoRA](https://huggingface.co/docs/peft/main/en/task_guides/image_classification_lora).
