Skip to content
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

Add optional flag in the text model config to return embeddings for all tokens in sequence instead of just the EOS embedding. #456

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

Conversation

mkaic
Copy link
Contributor

@mkaic mkaic commented Mar 2, 2023

This is a small QOL PR that implements an optional parameter.

Currently, there is no way to have the CLIP text model return the entirety of its (batch x seq_length x embed_dim)-shaped output tensor, something that's quite useful if you want to use your model as part of, say, a Stable Diffusion training run.

I've added an optional parameter, return_all_embeddings, that can be included in the text_cfg section of a model config. It defaults to False, so this pull request won't change any default behavior. If it's set to True, the model will return the output vectors for all tokens in its input, not just the one for the EOS token.

@mkaic mkaic marked this pull request as draft March 3, 2023 03:18
@mkaic mkaic marked this pull request as ready for review March 10, 2023 21:11
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.

None yet

1 participant