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

Flops regularizer looks odd #41

Open
dangkhoasdc opened this issue Mar 20, 2025 · 1 comment
Open

Flops regularizer looks odd #41

dangkhoasdc opened this issue Mar 20, 2025 · 1 comment

Comments

@dangkhoasdc
Copy link
Contributor

dangkhoasdc commented Mar 20, 2025

This implement does not look similar to the formula mentioned in SPLADE paper. Also, to minimize this, the 2nd operand need to be equal to threshold, which is not the goal of FLOPS.

input=torch.mean(input=torch.abs(input=activations), dim=0) ** 2, dim=0

There is another implementation more akin to the formula:

https://github.com/thongnt99/learned-sparse-retrieval/blob/d702026aacf1ab7c47011f55edcb2646a6bb646d/lsr/losses/regularizer.py#L56

@raphaelsty
Copy link
Owner

Hi @dangkhoasdc, I wrote this so it act as a margin-based flop loss, the model is asked to achieve a certain amount of flops.

Feel free to make a MR which will provide by default the correct flop loss :)

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