mirror of
https://github.com/openai/CLIP.git
synced 2026-11-05 01:37:26 +00:00
[GH-ISSUE #468] RuntimeError: Input is too long for context length 77. No truncation passed #399
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openai/CLIP#399
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hessaAlawwad on GitHub (Oct 21, 2024).
Original GitHub issue: https://github.com/openai/CLIP/issues/468
Hello,
So I am trying to embed text using CLIP, I got the error that my text is too long but from the huggingface I see that I can fix the variable:
max_position_embeddings (int, optional, defaults to 77) — The maximum sequence length that this model might ever be used with. Typically set this to something large just in case (e.g., 512 or 1024 or 2048).any ideas on how can I do this?
My code is as follow:
and do I need to adjust the image embeddings size too in order to calculate the similarty with the text?
Thanks in advance
@DeadLineChaser commented on GitHub (Jan 7, 2025):
hello,i met the same problem as you did,have,do you know how to change 'max_position_embeddings ' now? waiting for your replay,thanks in advance
@99991 commented on GitHub (Jan 23, 2025):
Your code example is for openai/CLIP, but
max_position_embeddingsis for HuggingFace CLIP, which are different implementations.Either way, there simply are no positional embeddings for tokens in longer texts. If you change
context_length, you need to retrain the model (or at least the new parameters ofpositional_embedding).github.com/openai/CLIP@dcba3cb2e2/clip/model.py (L291)You have a few options: