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

Loss Scale for Training Siglip #115

Open
lezhang7 opened this issue Jun 24, 2024 · 1 comment
Open

Loss Scale for Training Siglip #115

lezhang7 opened this issue Jun 24, 2024 · 1 comment

Comments

@lezhang7
Copy link

Hi,

Thanks for your great work. I was trying to apply siglip loss for training contrastive models. However, I find the loss scale is quiet small, usually around 0.003 at the begging. I wonder if any thing goes wrong in my implementation.

    n = logits.size(0)
    labels = 2 * torch.eye(n) - torch.ones(n, n)  # -1 with diagonal 1
    labels = labels.to(logits.device)
    loss = -torch.mean(F.logsigmoid(labels * logits)) / n    
    return loss```
@udion
Copy link

udion commented Sep 2, 2024

Did you normalize your feature vectors before creating the logits? the feature vectors should be unit vectors (normalize your vectors with L2 norm of the vector)

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

No branches or pull requests

2 participants