-
Notifications
You must be signed in to change notification settings - Fork 107
[wip] fix some hackable level 1 problems #118
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
base: main
Are you sure you want to change the base?
Conversation
1a619ee to
9c60c2f
Compare
|
Thanks for your PR addressing the MSELoss validation issue. I noticed you used Pareto(0.01, 0.15) for the fix. A quick technical note: with For Pareto distributions: We need Happy to discuss further! |
|
whoops you are totally right! mistake on my part moving the decimal point up. |
9c60c2f to
d96a823
Compare
With inputs sampled from Unif(0,1), the Huber Loss is effectively MSE, which we know can be hacked via statistical properties of the loss fn/inputs. We use the Pareto distribution to sample inputs w/finite mean and infinite variance to prevent hacking this way.
With inputs sampled from Unif(0,1), we can directly compute the expected value of the output using the mean of the targets. We use the Pareto distribution to sample inputs w/finite mean and infinite variance to prevent hacking this way.
d96a823 to
a3c7f8a
Compare
|
Changes make sense to me and good that we are improving this on the problem definition side as people might just take the problems for their use case(we can do more on the eval fuzzing side too). Since now KenrelBench supports more precision ( |
adds some tests for problems 94, 96, and 100. for each problem we test a hacked solution and a correct solution. we run these on the old inputs (sampled from uniform) and the new inputs (sampled from gaussian with mean/std sampled from uniform). also updates verify_bench.py to check for overflow after casting inputs. verified that the new input sampling approach passes correct kernel implementations, fails hacked ones, and does not overflow precision.
My replication in Issue 97 may help. |
As stated in this issue and this PR by @doux-jy, it's possible to hack 94: MSE via the statistical properties of the input.
96: Huber Loss and 99: Hinge Loss also face the same problem and we can fix these issues the same way, by sampling inputs from a heavy-tailed distribution.
Huber Loss
For the Huber Loss, given some targets$y$ and predictions $\hat{y}$ , we compute:
If$y, \hat{y}, s \sim \text{Unif}(0,1)$ , where $s$ is the scale, then $|y - \hat{y}|$ can never exceed 1, implying that the Huber Loss problem is functionally just computing the MSE Loss. Since we know this can be hacked via direct expectation computation, the Huber Loss problem is also vulnerable.
Hinge Loss
For the Hinge Loss, given some targets$y$ that are $\pm 1$ and predictions $\hat{y}$ , we compute:
averaged across all indices. Given that$\hat{y}\sim\text{Unif}(0,1)$ and $y_i$ is $\pm 1$ with equal probability, we can say:
So,
which we get by substituting$n_{\text{neg}} = n - n_{\text{pos}}$ .
Finally, by construction of$y$ :
This means we can use the mean of the targets to compute the expected value of the output (
1.0 - 0.5*targets.mean())