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 truncation to CLIP model #2969

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add truncation to CLIP model #2969

wants to merge 1 commit into from

Conversation

MrLoh
Copy link

@MrLoh MrLoh commented Oct 1, 2024

It seems that sentence transformer does currently not support truncation on CLIP models, which leads to an error when calling SentenceTransformer("sentence-transformers/clip-ViT-L-14").encode("my long text" * 26)

Token indices sequence length is longer than the specified maximum sequence length for this model (81 > 77). Running this sequence through the model will result in indexing errors

This PR adds support for truncation to the clip model. Allowing to pass in the standard sentence transformer max_seq_length argument and defaulting it to processor.tokenizer.model_max_length (i.e. 77).

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.

1 participant