1
0
Fork 0
mirror of https://github.com/p-e-w/heretic.git synced 2026-12-03 18:42:57 +07:00

[GH-ISSUE #236] [RFC] PIQA: A potential complement to KL divergence that could improve the quality of Heretic models #135

Closed
opened 2026-11-01 04:17:52 +07:00 by bsakaguchi · 12 comments
Owner

Originally created by @p-e-w on GitHub (Mar 19, 2026).
Original GitHub issue: https://github.com/p-e-w/heretic/issues/236

As part of refining #211, I am trying to figure out how we can predict the quality of the resulting model more reliably than with the KL divergence, while remaining fast enough to optimize for the metric. I have evaluated several small benchmark suites, and after a few days of testing, PIQA (Physical Interaction: Question Answering) has emerged as a promising candidate.

My main findings are:

  1. PIQA takes just seconds to run (e.g. 9 seconds for gpt-oss-20b BF16 on an RTX 6000 Pro).
  2. PIQA appears to correlate much more strongly with the proprietary UGI NatInt benchmark than the KL divergence.

 

The second point is illustrated by the following table:

Model PIQA acc_norm UGI NatInt Heretic KLD PIQA rank NatInt rank KLD rank
openai/gpt-oss-20b 0.7731 27.18 0 1 1 1
arnomatic/gpt-oss-20b-heretic-scanner-V1-2 0.7726 21.64 0.0534 2 3 3
MuXodious/gpt-oss-20b-RichardErkhov-heresy 0.7715 22.52 0.0640 3 2 4
kabachuha/gpt-oss-20b-SOMbliterated 0.7699 20.34 0.1158 4 4 6
p-e-w/gpt-oss-20b-heretic-ara-v3 0.7688 20.17 0.0437 5 5 2
coder3101/gpt-oss-20b-heretic 0.7666 20.11 0.2765 6 6 7
ArliAI/gpt-oss-20b-Derestricted 0.7622 18.31 0.1058 7 7 5
huihui-ai/Huihui-gpt-oss-20b-BF16-abliterated-v2 0.7427 10.89 1.2190 8 8 8

As you can see, PIQA and NatInt correlate almost perfectly (in a Spearman sense), and unlike the KLD, PIQA correctly predicts the poor NatInt score of ArliAI/gpt-oss-20b-Derestricted.

You can reproduce the PIQA scores using lm-evaluation-harness, with a command like lm_eval --model hf --model_args pretrained=<model> --tasks piqa --device cuda:0 --batch_size 64. You can reproduce the Heretic KLD scores with heretic --model <base_model> --evaluate-model <model>. The NatInt scores are taken from the UGI Leaderboard.

 

The very short evaluation time required for PIQA opens intriguing possibilities, including running PIQA on every trial, or (probably better), running it for all trials that are sufficiently close to the KLD-based Pareto front once the study completes. We can then re-build the Pareto front based on PIQA scores rather than KLD, which, according to these tests, should lead to improved prediction of model intelligence.

Originally created by @p-e-w on GitHub (Mar 19, 2026). Original GitHub issue: https://github.com/p-e-w/heretic/issues/236 As part of refining #211, I am trying to figure out how we can predict the quality of the resulting model more reliably than with the KL divergence, while remaining fast enough to optimize for the metric. I have evaluated several small benchmark suites, and after a few days of testing, [PIQA](https://arxiv.org/abs/1911.11641) (Physical Interaction: Question Answering) has emerged as a promising candidate. My main findings are: 1. PIQA takes just seconds to run (e.g. 9 seconds for `gpt-oss-20b` BF16 on an RTX 6000 Pro). 2. **PIQA appears to correlate much more strongly with the proprietary UGI NatInt benchmark than the KL divergence.** &nbsp; The second point is illustrated by the following table: | Model | PIQA `acc_norm` | UGI NatInt | Heretic KLD | PIQA rank | NatInt rank | KLD rank | | --- | --- | --- | --- | --- | --- | --- | | openai/gpt-oss-20b | 0.7731 | 27.18 | 0 | 1 | 1 | 1 | | arnomatic/gpt-oss-20b-heretic-scanner-V1-2 | 0.7726 | 21.64 | 0.0534 | 2 | 3 | 3 | | MuXodious/gpt-oss-20b-RichardErkhov-heresy | 0.7715 | 22.52 | 0.0640 | 3 | 2 | 4 | | kabachuha/gpt-oss-20b-SOMbliterated | 0.7699 | 20.34 | 0.1158 | 4 | 4 | 6 | | p-e-w/gpt-oss-20b-heretic-ara-v3 | 0.7688 | 20.17 | 0.0437 | 5 | 5 | 2 | | coder3101/gpt-oss-20b-heretic | 0.7666 | 20.11 | 0.2765 | 6 | 6 | 7 | | ArliAI/gpt-oss-20b-Derestricted | 0.7622 | 18.31 | 0.1058 | 7 | 7 | 5 | | huihui-ai/Huihui-gpt-oss-20b-BF16-abliterated-v2 | 0.7427 | 10.89 | 1.2190 | 8 | 8 | 8 | As you can see, PIQA and NatInt correlate almost perfectly (in a [Spearman](https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient) sense), and unlike the KLD, PIQA correctly predicts the poor NatInt score of `ArliAI/gpt-oss-20b-Derestricted`. You can reproduce the PIQA scores using [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness), with a command like `lm_eval --model hf --model_args pretrained=<model> --tasks piqa --device cuda:0 --batch_size 64`. You can reproduce the Heretic KLD scores with `heretic --model <base_model> --evaluate-model <model>`. The NatInt scores are taken from the [UGI Leaderboard](https://huggingface.co/spaces/DontPlanToEnd/UGI-Leaderboard). &nbsp; The very short evaluation time required for PIQA opens intriguing possibilities, including running PIQA on every trial, or (probably better), running it for all trials that are sufficiently close to the KLD-based Pareto front once the study completes. We can then re-build the Pareto front based on PIQA scores rather than KLD, which, according to these tests, should lead to improved prediction of model intelligence.
Author
Owner

@kabachuha commented on GitHub (Mar 21, 2026):

Are you sure PIQA from 2019 has not contaminated literally every LLM dataset as of today?

<!-- gh-comment-id:4102812463 --> @kabachuha commented on GitHub (Mar 21, 2026): Are you sure PIQA from 2019 has not contaminated literally every LLM dataset as of today?
Author
Owner

@p-e-w commented on GitHub (Mar 21, 2026):

It doesn't matter. This is about measuring quality degradation vs the base model, not about defeating benchmaxxing in models.

Comparing PIQA scores before and after abliteration provides a measure for quality retention, regardless of whether the model has been trained on the test data or not (arguably, even more so if it has).

<!-- gh-comment-id:4102847618 --> @p-e-w commented on GitHub (Mar 21, 2026): It doesn't matter. This is about measuring quality degradation vs the base model, not about defeating benchmaxxing in models. Comparing PIQA scores before and after abliteration provides a measure for quality retention, regardless of whether the model has been trained on the test data or not (arguably, even more so if it has).
Author
Owner

@erm14254 commented on GitHub (Mar 21, 2026):

I installed the new update, but now it seems like every trial is gonna take 10-11 minutes to complete:

Running trial 1 of 400...

  • Parameters:
    • start_layer_index = 13
    • end_layer_index = 31
    • preserve_good_behavior_weight = 0.6281
    • steer_bad_behavior_weight = 0.0004
    • overcorrect_relative_weight = 0.9344
    • neighbor_count = 2
  • Reloading model...
    Loading weights: 100%|█████████████████████████████████████████████████████████████| 1026/1026 [00:18<00:00, 55.11it/s]
  • Abliterating (Arbitrary-Rank Ablation)...
  • Evaluating...
    • Running PIQA benchmark...
      pretrained model kwarg is not of type str. Many other model arguments may be ignored. Please do not launch via accelerate or use parallelize=True if passing an existing model this way.
      Passed an already-initialized model through pretrained, assuming single-process call to evaluate() or custom distributed integration
      100%|████████████████████████████████████████████████████████████████████████████| 1838/1838 [00:00<00:00, 2252.90it/s]
      Running loglikelihood requests: 100%|██████████████████████████████████████████████| 3676/3676 [09:33<00:00, 6.41it/s]
    • PIQA acc_norm: 0.8281
    • Counting model refusals...
    • Refusals: 92/100

Elapsed time: 11m 44s

Running trial 2 of 400...

  • Parameters:
    • start_layer_index = 17
    • end_layer_index = 25
    • preserve_good_behavior_weight = 0.1043
    • steer_bad_behavior_weight = 0.3070
    • overcorrect_relative_weight = 1.0902
    • neighbor_count = 11
  • Reloading model...
    Loading weights: 100%|█████████████████████████████████████████████████████████████| 1026/1026 [00:18<00:00, 55.61it/s]
  • Abliterating (Arbitrary-Rank Ablation)...
  • Evaluating...
    • Running PIQA benchmark...
      pretrained model kwarg is not of type str. Many other model arguments may be ignored. Please do not launch via accelerate or use parallelize=True if passing an existing model this way.
      Passed an already-initialized model through pretrained, assuming single-process call to evaluate() or custom distributed integration
      100%|████████████████████████████████████████████████████████████████████████████| 1838/1838 [00:00<00:00, 2210.09it/s]
      Running loglikelihood requests: 100%|██████████████████████████████████████████████| 3676/3676 [08:13<00:00, 7.45it/s]
    • PIQA acc_norm: 0.5430
    • Counting model refusals...
    • Refusals: 0/100

Elapsed time: 21m 25s

Running trial 3 of 400...

  • Parameters:
    • start_layer_index = 15
    • end_layer_index = 30
    • preserve_good_behavior_weight = 0.8421
    • steer_bad_behavior_weight = 0.2257
    • overcorrect_relative_weight = 0.3091
    • neighbor_count = 7
  • Reloading model...
    Loading weights: 100%|█████████████████████████████████████████████████████████████| 1026/1026 [00:18<00:00, 55.06it/s]
  • Abliterating (Arbitrary-Rank Ablation)...
  • Evaluating...
    • Running PIQA benchmark...
      pretrained model kwarg is not of type str. Many other model arguments may be ignored. Please do not launch via accelerate or use parallelize=True if passing an existing model this way.
      Passed an already-initialized model through pretrained, assuming single-process call to evaluate() or custom distributed integration
      100%|████████████████████████████████████████████████████████████████████████████| 1838/1838 [00:00<00:00, 2225.20it/s]
      Running loglikelihood requests: 100%|██████████████████████████████████████████████| 3676/3676 [09:32<00:00, 6.42it/s]
    • PIQA acc_norm: 0.8308
    • Counting model refusals...
    • Refusals: 89/100

Elapsed time: 32m 26s

WTH? This would normally take 6-8 hours or so (depending on model) for 400 trials, but now it's gonna take ~70 hours for 400 trials...

You mentioned in the OP that running PIQA "for all trials that are sufficiently close to the KLD-based Pareto front once the study completes" would probably be better. Is that workflow planned? For now I'm using --no-use-piqa to keep trials fast.

<!-- gh-comment-id:4104633071 --> @erm14254 commented on GitHub (Mar 21, 2026): I installed the new update, but now it seems like every trial is gonna take 10-11 minutes to complete: > Running trial 1 of 400... > * Parameters: > * start_layer_index = 13 > * end_layer_index = 31 > * preserve_good_behavior_weight = 0.6281 > * steer_bad_behavior_weight = 0.0004 > * overcorrect_relative_weight = 0.9344 > * neighbor_count = 2 > * Reloading model... > Loading weights: 100%|█████████████████████████████████████████████████████████████| 1026/1026 [00:18<00:00, 55.11it/s] > * Abliterating (Arbitrary-Rank Ablation)... > * Evaluating... > * Running PIQA benchmark... > `pretrained` model kwarg is not of type `str`. Many other model arguments may be ignored. Please do not launch via accelerate or use `parallelize=True` if passing an existing model this way. > Passed an already-initialized model through `pretrained`, assuming single-process call to evaluate() or custom distributed integration > 100%|████████████████████████████████████████████████████████████████████████████| 1838/1838 [00:00<00:00, 2252.90it/s] > Running loglikelihood requests: 100%|██████████████████████████████████████████████| 3676/3676 [09:33<00:00, 6.41it/s] > * PIQA acc_norm: 0.8281 > * Counting model refusals... > * Refusals: 92/100 > > Elapsed time: 11m 44s > > Running trial 2 of 400... > * Parameters: > * start_layer_index = 17 > * end_layer_index = 25 > * preserve_good_behavior_weight = 0.1043 > * steer_bad_behavior_weight = 0.3070 > * overcorrect_relative_weight = 1.0902 > * neighbor_count = 11 > * Reloading model... > Loading weights: 100%|█████████████████████████████████████████████████████████████| 1026/1026 [00:18<00:00, 55.61it/s] > * Abliterating (Arbitrary-Rank Ablation)... > * Evaluating... > * Running PIQA benchmark... > `pretrained` model kwarg is not of type `str`. Many other model arguments may be ignored. Please do not launch via accelerate or use `parallelize=True` if passing an existing model this way. > Passed an already-initialized model through `pretrained`, assuming single-process call to evaluate() or custom distributed integration > 100%|████████████████████████████████████████████████████████████████████████████| 1838/1838 [00:00<00:00, 2210.09it/s] > Running loglikelihood requests: 100%|██████████████████████████████████████████████| 3676/3676 [08:13<00:00, 7.45it/s] > * PIQA acc_norm: 0.5430 > * Counting model refusals... > * Refusals: 0/100 > > Elapsed time: 21m 25s > > Running trial 3 of 400... > * Parameters: > * start_layer_index = 15 > * end_layer_index = 30 > * preserve_good_behavior_weight = 0.8421 > * steer_bad_behavior_weight = 0.2257 > * overcorrect_relative_weight = 0.3091 > * neighbor_count = 7 > * Reloading model... > Loading weights: 100%|█████████████████████████████████████████████████████████████| 1026/1026 [00:18<00:00, 55.06it/s] > * Abliterating (Arbitrary-Rank Ablation)... > * Evaluating... > * Running PIQA benchmark... > `pretrained` model kwarg is not of type `str`. Many other model arguments may be ignored. Please do not launch via accelerate or use `parallelize=True` if passing an existing model this way. > Passed an already-initialized model through `pretrained`, assuming single-process call to evaluate() or custom distributed integration > 100%|████████████████████████████████████████████████████████████████████████████| 1838/1838 [00:00<00:00, 2225.20it/s] > Running loglikelihood requests: 100%|██████████████████████████████████████████████| 3676/3676 [09:32<00:00, 6.42it/s] > * PIQA acc_norm: 0.8308 > * Counting model refusals... > * Refusals: 89/100 > > Elapsed time: 32m 26s WTH? This would normally take 6-8 hours or so (depending on model) for 400 trials, but now it's gonna take ~70 hours for 400 trials... You mentioned in the OP that running PIQA "for all trials that are sufficiently close to the KLD-based Pareto front once the study completes" would probably be better. Is that workflow planned? For now I'm using --no-use-piqa to keep trials fast.
Author
Owner

@p-e-w commented on GitHub (Mar 23, 2026):

See my comment in #246. That commit is purely to drive ARA development. It will not be merged into master.

<!-- gh-comment-id:4107627052 --> @p-e-w commented on GitHub (Mar 23, 2026): See my comment in #246. That commit is purely to drive ARA development. It will **not** be merged into master.
Author
Owner

@erm14254 commented on GitHub (Mar 23, 2026):

See my comment in #246. That commit is purely to drive ARA development. It will not be merged into master.

So you think it could be fixed?

<!-- gh-comment-id:4108669459 --> @erm14254 commented on GitHub (Mar 23, 2026): > See my comment in [#246](https://github.com/p-e-w/heretic/issues/246). That commit is purely to drive ARA development. It will **not** be merged into master. So you think it could be fixed?
Author
Owner

@p-e-w commented on GitHub (Mar 23, 2026):

No idea, and it's not my priority right now.

<!-- gh-comment-id:4108983846 --> @p-e-w commented on GitHub (Mar 23, 2026): No idea, and it's not my priority right now.
Author
Owner

@viaqlo commented on GitHub (Mar 23, 2026):

@erm14254 For me, the issue was the piqa batch size being set to auto. Setting this to 64 or whatever the card can handle should speed things up dramatically.

<!-- gh-comment-id:4112232215 --> @viaqlo commented on GitHub (Mar 23, 2026): @erm14254 For me, the issue was the [piqa batch size](https://github.com/p-e-w/heretic/pull/211/changes/c925f5e8023b2404cc90f00b73c68049cfda660d#diff-46688d60b3c8a529a42aa830a83d50927ababe2456f7787a7cd4212c3c07d8d8R105) being set to `auto`. Setting this to `64` or whatever the card can handle should speed things up dramatically.
Author
Owner

@erm14254 commented on GitHub (Mar 23, 2026):

@erm14254 For me, the issue was the piqa batch size being set to auto. Setting this to 64 or whatever the card can handle should speed things up dramatically.

I did, I changed it from auto to 128 and it's pretty much the same as before, nothing's changed and it's still super slow.

Elapsed time: 1h 19m
Estimated remaining time: 36h 43m

Running trial 15 of 400...

<!-- gh-comment-id:4114260973 --> @erm14254 commented on GitHub (Mar 23, 2026): > [@erm14254](https://github.com/erm14254) For me, the issue was the [piqa batch size](https://github.com/p-e-w/heretic/pull/211/changes/c925f5e8023b2404cc90f00b73c68049cfda660d#diff-46688d60b3c8a529a42aa830a83d50927ababe2456f7787a7cd4212c3c07d8d8R105) being set to `auto`. Setting this to `64` or whatever the card can handle should speed things up dramatically. I did, I changed it from auto to 128 and it's pretty much the same as before, nothing's changed and it's still super slow. Elapsed time: 1h 19m Estimated remaining time: 36h 43m Running trial 15 of 400...
Author
Owner

@p-e-w commented on GitHub (Mar 24, 2026):

I suspect the problem is that in Heretic, the model is wrapped in a PeftModel, though I'm not working on this at the moment.

<!-- gh-comment-id:4116332739 --> @p-e-w commented on GitHub (Mar 24, 2026): I suspect the problem is that in Heretic, the model is wrapped in a `PeftModel`, though I'm not working on this at the moment.
Author
Owner

@kabachuha commented on GitHub (Mar 24, 2026):

Personally, I think PIQA in heretic is a complete fiasco.

Not only it's a weak signal and giant slowdown of the whole process, it introduces a lot of factors to compute the loss when the words are sampled: the probabilities of the first one, selection of the order of the glue tokens ("the", "and", "in", etc.), paraphrasing of the same meaning in different words and lengths. It's not even MMLU / multichoice where you can judge by the logprobs of the selected letter.

The work could better be spent on developing novel techniques instead of squeezing a questionable multi-variable metric.

<!-- gh-comment-id:4116785512 --> @kabachuha commented on GitHub (Mar 24, 2026): Personally, I think PIQA in heretic is a complete fiasco. Not only it's a weak signal and giant slowdown of the whole process, it introduces a lot of factors to compute the loss when the words are sampled: the probabilities of the first one, selection of the order of the glue tokens ("the", "and", "in", etc.), paraphrasing of the same meaning in different words and lengths. It's not even MMLU / multichoice where you can judge by the logprobs of the selected letter. The work could better be spent on developing novel techniques instead of squeezing a questionable multi-variable metric.
Author
Owner

@p-e-w commented on GitHub (Mar 24, 2026):

Personally, I think PIQA in heretic is a complete fiasco.

PIQA isn't in Heretic. There's a temporary commit in the ARA branch for the purpose of developing ARA, and it has a switch to disable it.

The commit I pushed to that specific branch is not going to be merged, ever, which by now I have explicitly said multiple times. I never claimed it was going to be, I didn't even announce that I had implemented this, and I didn't ask others to test it.

c925f5e802 isn't the proposed implementation of this issue, which is why it is specifically not linked to this issue in either direction.

<!-- gh-comment-id:4116872598 --> @p-e-w commented on GitHub (Mar 24, 2026): > Personally, I think PIQA in heretic is a complete fiasco. PIQA isn't in Heretic. There's a **temporary** commit **in the ARA branch** for the purpose of developing ARA, and it has a switch to disable it. The commit I pushed to that specific branch is not going to be merged, ever, which by now I have explicitly said multiple times. I never claimed it was going to be, I didn't even announce that I had implemented this, and I didn't ask others to test it. c925f5e8023b2404cc90f00b73c68049cfda660d isn't the proposed implementation of this issue, which is why it is specifically not linked to this issue in either direction.
Author
Owner

@p-e-w commented on GitHub (Apr 1, 2026):

I have found and fixed the reason why running PIQA (and all other benchmarks) was much slower in Heretic than in lm_eval:

Contrary to the documentation, the batch size must be set on the HFLM object, not in the simple_evaluate arguments.

With this fix, benchmarks become up to 10 times faster depending on the hardware.

However, as stated before, the PIQA implementation in #211 remains experimental and will not be merged into master. The proper implementation will use #53.

<!-- gh-comment-id:4168766397 --> @p-e-w commented on GitHub (Apr 1, 2026): I have found and fixed the reason why running PIQA (and all other benchmarks) was much slower in Heretic than in `lm_eval`: **Contrary to the documentation, the batch size must be set on the `HFLM` object, not in the `simple_evaluate` arguments.** With this fix, benchmarks become up to 10 times faster depending on the hardware. However, as stated before, the PIQA implementation in #211 remains experimental and will not be merged into master. The proper implementation will use #53.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
p-e-w/heretic#135
No description provided.