Skip to content

Fixes issue #38709 for CLIP and XCLIP #38764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Vishu26
Copy link

@Vishu26 Vishu26 commented Jun 11, 2025

What does this PR do?

Fixes #38709 (at least for CLIP and XCLIP for now and is fully backward compatible and existing functionality remains unaffected).

Previously, get_<>_features function in CLIP and XCLIP always return the pooled_output. Now, if output_hidden_states is set, the function returns a dict. It is set to None by default, so the existing behavior will be unaffected.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • [x ] Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@Rocketknight1
Copy link
Member

Hmmn, I was thinking maybe returning a dict with hidden states and pooler output as separate keys. cc @zucchini-nlp, do you know what this method is for, and why it accepts output_hidden_states as an argument but basically ignores it?

@zucchini-nlp
Copy link
Member

Hmm, seems like the helper used by researchers to obtain pooled features for single modality, since the forward call expects both modalities to be present. We use the same helper in Vision LLMs to return image_features after encoding+projection, reasy to be merged with text embeddings

I think it is not necessary to return hidden states and attention for these helper functions. If users want to obtain hidden states, they can load and call only the text/vision model (e.g. ClipTextModel)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

get_video_features in XCLIPModel always returns pooled_output
3 participants