# CLIPTextModel's get\_text\_features VS pooled outputs

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcliptextmodels-get-text-features-vs-pooled-outputs%2F104646%3E%5C
**Category:** 🤗Transformers\
**Created:** [August 30, 2024, 10:11am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcliptextmodels-get-text-features-vs-pooled-outputs%2F104646 "2024-08-30T10:11:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thejinzhe](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@thejinzhe](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fthejinzhe)%5C
**Post date:** [August 30, 2024, 10:11am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcliptextmodels-get-text-features-vs-pooled-outputs%2F104646%2F1 "2024-08-30T10:11:07Z")

</div>

Hi all,

I am trying to obtain embedding vectors for text using CLIP that will eventually be used for cross-attention with a latent diffusion model (the standard text-to-image approach). For context, the embedding vectors will first pass through some of my own linear projection layers during training before being fed into the UNet.

A common practice for obtaining CLIP text embeddings is to use `CLIPTextModel`’s `get_text_features` method. From the [code](https://github.com/huggingface/transformers/blob/95754b47a6d4fbdad3440a45762531e8c471c528/src/transformers/models/clip/modeling_clip.py#L1016), I can see that it’s projecting the pooled outputs using a linear `self.text_projection` layer. I have also verified that this is true by comparing against the`.pooler_output` from `CLIPTextModel`.

My question is, what’s this `self.text_projection` for specifically? Its projecting from 768 to 768 so dimensionality doesn’t change. Does the `text_projection` matter at all in my case if I can just use the pooled outputs directly from `CLIPTextModel`? I also observe people using pooled outputs for obtaining CLIP’s text embeddings so it’s confusing when to do what here.

Apologies if this question might be a bit nuanced.

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [August 30, 2024, 10:34am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcliptextmodels-get-text-features-vs-pooled-outputs%2F104646%2F2 "2024-08-30T10:34:51Z")

</div>

I think the projection layer is just there to project the text features (coming from the text encoder) and the image features (coming from the vision encoder) into the same embedding space. The vision encoder uses a different dimensionality (e.g. 1024 for [openai/clip-vit-large-patch14 · Hugging Face](https://huggingface.co/openai/clip-vit-large-patch14)), so the projection layers on both the text and vision sides make sure this is projected to the same dimensionality (like 512 or 768).
