# Blip-2 as a classification model

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fblip-2-as-a-classification-model%2F103383%3E%5C
**Category:** Models\
**Created:** [August 21, 2024, 6:29pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fblip-2-as-a-classification-model%2F103383 "2024-08-21T18:29:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![atomwalk12](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@atomwalk12](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fatomwalk12)%5C
**Post date:** [August 21, 2024, 6:29pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fblip-2-as-a-classification-model%2F103383%2F1 "2024-08-21T18:29:31Z")

</div>

I was wondering is it even possible to use the Blip-2 model (Blip2ForConditionalGeneration) for classification-like tasks. I have not been able to find any thorough information on how to use this model using a classification head.

Also, if the answer is yes, then which features should be extracted to train the classifier on. I can think of two possibilities:

1. Use the last\_hidden\_layer from the q-former and combine these features with the last\_hidden\_layer of the vision model; or
2. Use the pooled output of the q-former.

I feel like this is an interesting topic, which unfortunately was not able to find much information about.  
Any related tips would be really appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![AmlEsmail](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@AmlEsmail](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAmlEsmail)%5C
**Post date:** [November 23, 2025, 12:53am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fblip-2-as-a-classification-model%2F103383%2F2 "2025-11-23T00:53:11Z")

</div>

Hey, any luck on that?

I use it for classifying if an image matches a text or not, I just take the embeddings from image and text, find the cosine similarity then use a threshold to see if it’s matching or not

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [November 23, 2025, 5:46am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fblip-2-as-a-classification-model%2F103383%2F3 "2025-11-23T05:46:44Z")

</div>

BLIP-2 can also handle this, but [for the purpose of completing this task, there seems to be no need to limit it to BLIP-2](https://huggingface.co/datasets/John6666/forum2/blob/main/blip2_classification_1.md) today…
