Update GPT-6 Luna benchmark results
#36
by jfbrown95 - opened
- README.md +16 -16
- assets/bug-tradeoff.svg +0 -0
- assets/lint-tradeoff.svg +30 -19
- assets/security-tradeoff.svg +0 -0
- openai_decisions.py +66 -20
- predictions/current/bug/openai-decisions.jsonl +2 -2
- predictions/current/lint/openai-decisions.jsonl +2 -2
- predictions/current/security/openai-decisions.jsonl +2 -2
- results-current.jsonl +6 -6
- results.jsonl +6 -6
- test_openai_decisions.py +62 -0
- test_tradeoff.py +42 -0
- tradeoff.py +22 -16
README.md
CHANGED
|
@@ -29,7 +29,7 @@ Pairs come from open-source projects in Rust, JavaScript, TypeScript, Python, Go
|
|
| 29 |
|
| 30 |
## Reading the results
|
| 31 |
|
| 32 |
-
Each line shows
|
| 33 |
|
| 34 |
The tables use each run's recorded alert settings. A value of 20% under ‘Clean methods wrongly flagged’ means one in five clean methods received an alert. Models are ranked by recall minus that percentage. Bold marks the best full-set value in each column; cost compares priced runs captured here.
|
| 35 |
|
|
@@ -39,14 +39,14 @@ Failed requests count as incorrect decisions: a failed issue is a miss; a failed
|
|
| 39 |
|
| 40 |
[Public pairs](https://huggingface.co/datasets/perchscan/bug-pairs-public)
|
| 41 |
|
| 42 |
-
 | 17.7% | 12.7% | 5.0% | **0** | $0.551 |
|
| 51 |
| [SemiF](https://github.com/TheoLeeCJ/SemIf) | 43.0% | 39.7% | 3.3% | **0** | $0.239 |
|
| 52 |
| [TypeLLM](https://typellm.ai/docs) | 8.3% | 5.5% | 2.7% | **0** | $0.576 |
|
|
@@ -62,7 +62,7 @@ Failed requests count as incorrect decisions: a failed issue is a miss; a failed
|
|
| 62 |
|
| 63 |
| Model | Recall | Clean methods wrongly flagged | Recall − false-positive rate | Failed requests | Inference cost |
|
| 64 |
| --- | ---: | ---: | ---: | ---: | ---: |
|
| 65 |
-
| [GPT-6 Luna Decisions](https://developers.openai.com/api/docs/guides/decisions) |
|
| 66 |
| [DiffusionGemma Jev](https://github.com/razorback16/openjev) | 35.8% | 27.3% | 8.6% | **0** | $0.054 |
|
| 67 |
| [TypeLLM](https://typellm.ai/docs) | 11.3% | 5.8% | 5.6% | **0** | $0.129 |
|
| 68 |
| [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) | 20.0% | 15.6% | 4.5% | **0** | $0.123 |
|
|
@@ -76,7 +76,7 @@ Failed requests count as incorrect decisions: a failed issue is a miss; a failed
|
|
| 76 |
|
| 77 |
[Public pairs](https://huggingface.co/datasets/perchscan/security-pairs-public)
|
| 78 |
|
| 79 |
-
 | 34.6% | 23.6% | **11.0%** | **0** | $0.507 |
|
| 86 |
| [TypeLLM](https://typellm.ai/docs) | 27.8% | 17.4% | 10.5% | **0** | $0.566 |
|
|
|
|
| 87 |
| [Liquid d1](https://docs.liquid.ai/lfm/models/decision-models) | 55.6% | 46.8% | 8.8% | **0** | Free tier |
|
| 88 |
| [DiffusionGemma Jev](https://github.com/razorback16/openjev) | 33.1% | 25.8% | 7.3% | **0** | **$0.208** |
|
| 89 |
-
| [GPT-6 Luna Decisions](https://developers.openai.com/api/docs/guides/decisions) | 22.6% | 15.9% | 6.6% | 50 | $1.775 |
|
| 90 |
| [Span-01](https://www.respan.ai/docs/documentation/span-01/concept) | 21.0% | 17.2% | 3.9% | **0** | $0.251 |
|
| 91 |
| [CodeQL](https://codeql.github.com/)* | 4.8% | 1.5% | 3.3% | — | — |
|
| 92 |
| [GLiNER-2.5-Decide](https://huggingface.co/fastino/GLiNER2.5-Decide) | 2.1% | **1.6%** | 0.5% | 6 | $0.434 |
|
|
@@ -99,8 +99,8 @@ Failed requests count as incorrect decisions: a failed issue is a miss; a failed
|
|
| 99 |
|
| 100 |
| Model | Recall | Clean methods wrongly flagged | Recall − false-positive rate | Failed requests | Inference cost |
|
| 101 |
| --- | ---: | ---: | ---: | ---: | ---: |
|
| 102 |
-
| [
|
| 103 |
-
| [
|
| 104 |
| [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) | 20.6% | 16.7% | 3.9% | **0** | $0.182 |
|
| 105 |
| [DiffusionGemma Jev](https://github.com/razorback16/openjev) | 21.9% | 18.5% | 3.3% | **0** | **$0.074** |
|
| 106 |
| [TypeLLM](https://typellm.ai/docs) | 8.8% | 6.2% | 2.5% | **0** | $0.203 |
|
|
@@ -113,14 +113,14 @@ Failed requests count as incorrect decisions: a failed issue is a miss; a failed
|
|
| 113 |
|
| 114 |
[Public pairs](https://huggingface.co/datasets/perchscan/perch-lint-bench-public)
|
| 115 |
|
| 116 |
-
 | 50.0% | 0.5% | 49.5% | **0** | $0.048 |
|
| 125 |
| [Liquid d1](https://docs.liquid.ai/lfm/models/decision-models) | 49.1% | 0.9% | 48.1% | **0** | Free tier |
|
| 126 |
| [DiffusionGemma Jev](https://github.com/razorback16/openjev) | 52.8% | 5.1% | 47.7% | **0** | $0.018 |
|
|
@@ -133,10 +133,10 @@ Failed requests count as incorrect decisions: a failed issue is a miss; a failed
|
|
| 133 |
|
| 134 |
| Model | Recall | Clean methods wrongly flagged | Recall − false-positive rate | Failed requests | Inference cost |
|
| 135 |
| --- | ---: | ---: | ---: | ---: | ---: |
|
| 136 |
-
| [
|
|
|
|
| 137 |
| [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) | 53.5% | 1.4% | 52.1% | **0** | $0.016 |
|
| 138 |
| [Liquid d1](https://docs.liquid.ai/lfm/models/decision-models) | 49.3% | 1.4% | 47.9% | **0** | Free tier |
|
| 139 |
-
| [GPT-6 Luna Decisions](https://developers.openai.com/api/docs/guides/decisions) | 50.7% | 2.8% | 47.9% | **0** | $0.030 |
|
| 140 |
| [DiffusionGemma Jev](https://github.com/razorback16/openjev) | 53.5% | 8.5% | 45.1% | **0** | $0.006 |
|
| 141 |
| [Span-01](https://www.respan.ai/docs/documentation/span-01/concept) | 45.1% | 8.5% | 36.6% | **0** | $0.005 |
|
| 142 |
| [CLM-v0.1-8B](https://huggingface.co/Contrastive-LM/CLM-v0.1-8B) | 50.7% | 49.3% | 1.4% | **0** | **~$0.003** |
|
|
@@ -157,7 +157,7 @@ Inference costs cover scoring the method sides in each table. Jev costs are esti
|
|
| 157 |
|
| 158 |
JevLike (192-byte input), Laya (512-token input), and Kev (packed-branch limit) could not score every full-context method. NanoJev was unavailable on Beam. They are excluded rather than ranked on partial results.
|
| 159 |
|
| 160 |
-
GPT-6 Luna Decisions receives each method's saved context with all applicable checks as
|
| 161 |
|
| 162 |
## Files and reproduction
|
| 163 |
|
|
@@ -203,7 +203,7 @@ To run OpenAI Decisions, download each public `benchmark.jsonl` into
|
|
| 203 |
`public/bug/`, `public/security/` and `public/lint/`, then set `OPENAI_API_KEY`:
|
| 204 |
|
| 205 |
```sh
|
| 206 |
-
python3 openai_decisions.py --manifest openai-decisions-manifest.json --out decisions-results
|
| 207 |
```
|
| 208 |
|
| 209 |
The runner preserves the configured question floors and 70% semantic-lint
|
|
|
|
| 29 |
|
| 30 |
## Reading the results
|
| 31 |
|
| 32 |
+
Each line shows recall minus the false-positive rate as the score cutoff changes. Higher is better; farther left means fewer clean methods flagged. The dashed zero line means issues and clean methods are flagged at equal rates.
|
| 33 |
|
| 34 |
The tables use each run's recorded alert settings. A value of 20% under ‘Clean methods wrongly flagged’ means one in five clean methods received an alert. Models are ranked by recall minus that percentage. Bold marks the best full-set value in each column; cost compares priced runs captured here.
|
| 35 |
|
|
|
|
| 39 |
|
| 40 |
[Public pairs](https://huggingface.co/datasets/perchscan/bug-pairs-public)
|
| 41 |
|
| 42 |
+

|
| 43 |
|
| 44 |
### Public — 2,220 pairs
|
| 45 |
|
| 46 |
| Model | Recall | Clean methods wrongly flagged | Recall − false-positive rate | Failed requests | Inference cost |
|
| 47 |
| --- | ---: | ---: | ---: | ---: | ---: |
|
| 48 |
+
| [GPT-6 Luna Decisions](https://developers.openai.com/api/docs/guides/decisions) | 48.7% | 38.7% | **10.0%** | **0** | $1.102 |
|
| 49 |
+
| [DiffusionGemma Jev](https://github.com/razorback16/openjev) | 33.4% | 27.1% | 6.3% | **0** | $0.239 |
|
| 50 |
| [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) | 17.7% | 12.7% | 5.0% | **0** | $0.551 |
|
| 51 |
| [SemiF](https://github.com/TheoLeeCJ/SemIf) | 43.0% | 39.7% | 3.3% | **0** | $0.239 |
|
| 52 |
| [TypeLLM](https://typellm.ai/docs) | 8.3% | 5.5% | 2.7% | **0** | $0.576 |
|
|
|
|
| 62 |
|
| 63 |
| Model | Recall | Clean methods wrongly flagged | Recall − false-positive rate | Failed requests | Inference cost |
|
| 64 |
| --- | ---: | ---: | ---: | ---: | ---: |
|
| 65 |
+
| [GPT-6 Luna Decisions](https://developers.openai.com/api/docs/guides/decisions) | 52.4% | 41.3% | **11.1%** | **0** | $0.247 |
|
| 66 |
| [DiffusionGemma Jev](https://github.com/razorback16/openjev) | 35.8% | 27.3% | 8.6% | **0** | $0.054 |
|
| 67 |
| [TypeLLM](https://typellm.ai/docs) | 11.3% | 5.8% | 5.6% | **0** | $0.129 |
|
| 68 |
| [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) | 20.0% | 15.6% | 4.5% | **0** | $0.123 |
|
|
|
|
| 76 |
|
| 77 |
[Public pairs](https://huggingface.co/datasets/perchscan/security-pairs-public)
|
| 78 |
|
| 79 |
+

|
| 80 |
|
| 81 |
### Public — 1,311 pairs
|
| 82 |
|
|
|
|
| 84 |
| --- | ---: | ---: | ---: | ---: | ---: |
|
| 85 |
| [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) | 34.6% | 23.6% | **11.0%** | **0** | $0.507 |
|
| 86 |
| [TypeLLM](https://typellm.ai/docs) | 27.8% | 17.4% | 10.5% | **0** | $0.566 |
|
| 87 |
+
| [GPT-6 Luna Decisions](https://developers.openai.com/api/docs/guides/decisions) | 54.1% | 44.5% | 9.7% | **0** | $1.469 |
|
| 88 |
| [Liquid d1](https://docs.liquid.ai/lfm/models/decision-models) | 55.6% | 46.8% | 8.8% | **0** | Free tier |
|
| 89 |
| [DiffusionGemma Jev](https://github.com/razorback16/openjev) | 33.1% | 25.8% | 7.3% | **0** | **$0.208** |
|
|
|
|
| 90 |
| [Span-01](https://www.respan.ai/docs/documentation/span-01/concept) | 21.0% | 17.2% | 3.9% | **0** | $0.251 |
|
| 91 |
| [CodeQL](https://codeql.github.com/)* | 4.8% | 1.5% | 3.3% | — | — |
|
| 92 |
| [GLiNER-2.5-Decide](https://huggingface.co/fastino/GLiNER2.5-Decide) | 2.1% | **1.6%** | 0.5% | 6 | $0.434 |
|
|
|
|
| 99 |
|
| 100 |
| Model | Recall | Clean methods wrongly flagged | Recall − false-positive rate | Failed requests | Inference cost |
|
| 101 |
| --- | ---: | ---: | ---: | ---: | ---: |
|
| 102 |
+
| [GPT-6 Luna Decisions](https://developers.openai.com/api/docs/guides/decisions) | 40.5% | 31.5% | **9.0%** | **0** | $0.530 |
|
| 103 |
+
| [Liquid d1](https://docs.liquid.ai/lfm/models/decision-models) | 34.2% | 29.0% | 5.2% | **0** | Free tier |
|
| 104 |
| [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) | 20.6% | 16.7% | 3.9% | **0** | $0.182 |
|
| 105 |
| [DiffusionGemma Jev](https://github.com/razorback16/openjev) | 21.9% | 18.5% | 3.3% | **0** | **$0.074** |
|
| 106 |
| [TypeLLM](https://typellm.ai/docs) | 8.8% | 6.2% | 2.5% | **0** | $0.203 |
|
|
|
|
| 113 |
|
| 114 |
[Public pairs](https://huggingface.co/datasets/perchscan/perch-lint-bench-public)
|
| 115 |
|
| 116 |
+

|
| 117 |
|
| 118 |
### Public — 214 pairs
|
| 119 |
|
| 120 |
| Model | Recall | Clean methods wrongly flagged | Recall − false-positive rate | Failed requests | Inference cost |
|
| 121 |
| --- | ---: | ---: | ---: | ---: | ---: |
|
| 122 |
+
| [GPT-6 Luna Decisions](https://developers.openai.com/api/docs/guides/decisions) | **76.6%** | 4.7% | **72.0%** | **0** | $0.093 |
|
| 123 |
+
| [TypeLLM](https://typellm.ai/docs) | 61.7% | 2.8% | 58.9% | **0** | $0.050 |
|
| 124 |
| [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) | 50.0% | 0.5% | 49.5% | **0** | $0.048 |
|
| 125 |
| [Liquid d1](https://docs.liquid.ai/lfm/models/decision-models) | 49.1% | 0.9% | 48.1% | **0** | Free tier |
|
| 126 |
| [DiffusionGemma Jev](https://github.com/razorback16/openjev) | 52.8% | 5.1% | 47.7% | **0** | $0.018 |
|
|
|
|
| 133 |
|
| 134 |
| Model | Recall | Clean methods wrongly flagged | Recall − false-positive rate | Failed requests | Inference cost |
|
| 135 |
| --- | ---: | ---: | ---: | ---: | ---: |
|
| 136 |
+
| [GPT-6 Luna Decisions](https://developers.openai.com/api/docs/guides/decisions) | **84.5%** | 7.0% | **77.5%** | **0** | $0.030 |
|
| 137 |
+
| [TypeLLM](https://typellm.ai/docs) | 59.2% | 5.6% | 53.5% | **0** | $0.016 |
|
| 138 |
| [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) | 53.5% | 1.4% | 52.1% | **0** | $0.016 |
|
| 139 |
| [Liquid d1](https://docs.liquid.ai/lfm/models/decision-models) | 49.3% | 1.4% | 47.9% | **0** | Free tier |
|
|
|
|
| 140 |
| [DiffusionGemma Jev](https://github.com/razorback16/openjev) | 53.5% | 8.5% | 45.1% | **0** | $0.006 |
|
| 141 |
| [Span-01](https://www.respan.ai/docs/documentation/span-01/concept) | 45.1% | 8.5% | 36.6% | **0** | $0.005 |
|
| 142 |
| [CLM-v0.1-8B](https://huggingface.co/Contrastive-LM/CLM-v0.1-8B) | 50.7% | 49.3% | 1.4% | **0** | **~$0.003** |
|
|
|
|
| 157 |
|
| 158 |
JevLike (192-byte input), Laya (512-token input), and Kev (packed-branch limit) could not score every full-context method. NanoJev was unavailable on Beam. They are excluded rather than ranked on partial results.
|
| 159 |
|
| 160 |
+
GPT-6 Luna Decisions receives each method's saved context with all applicable checks as two-option choice questions in one request. True and false criteria define the options. Semantic lint scores invert the probability that the rule is satisfied. Costs use API-reported input tokens at [$0.10 per million](https://developers.openai.com/api/docs/guides/decisions#pricing-and-availability); output and cache operations carry no extra charge.
|
| 161 |
|
| 162 |
## Files and reproduction
|
| 163 |
|
|
|
|
| 203 |
`public/bug/`, `public/security/` and `public/lint/`, then set `OPENAI_API_KEY`:
|
| 204 |
|
| 205 |
```sh
|
| 206 |
+
python3 openai_decisions.py --protocol choice --manifest openai-decisions-manifest.json --out decisions-results
|
| 207 |
```
|
| 208 |
|
| 209 |
The runner preserves the configured question floors and 70% semantic-lint
|
assets/bug-tradeoff.svg
CHANGED
|
|
|
|
assets/lint-tradeoff.svg
CHANGED
|
|
|
|
assets/security-tradeoff.svg
CHANGED
|
|
|
|
openai_decisions.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
"""Run OpenAI Decisions on the Perch bug, security and semantic lint benchmarks.
|
| 3 |
|
| 4 |
Each method is independent. Applicable checks share its complete saved context.
|
| 5 |
-
Predicates retain the frozen question and answer criteria. No repair is shown.
|
| 6 |
Failed requests are saved once and counted as wrong decisions, without scores.
|
| 7 |
"""
|
| 8 |
from __future__ import annotations
|
|
@@ -27,6 +27,7 @@ MODEL_ID = 'openai-decisions'
|
|
| 27 |
API = 'https://api.openai.com/v1/decisions'
|
| 28 |
PRICE = .10
|
| 29 |
PROTOCOL = 'openai-decisions-perch-predicate-v1'
|
|
|
|
| 30 |
spec = importlib.util.spec_from_file_location('perch_benchmark', ROOT / 'benchmark.py')
|
| 31 |
core = importlib.util.module_from_spec(spec)
|
| 32 |
spec.loader.exec_module(core)
|
|
@@ -74,47 +75,83 @@ def questions_for(pair, domain, pack):
|
|
| 74 |
|
| 75 |
def predicate(check):
|
| 76 |
question = check['question']
|
|
|
|
|
|
|
|
|
|
| 77 |
return {'type': 'predicate', 'name': check['name'],
|
| 78 |
'instructions': question['instructions'].strip() + '\nTrue: ' +
|
| 79 |
question['criteria']['true'].strip() + '\nFalse: ' +
|
| 80 |
question['criteria']['false'].strip()}
|
| 81 |
|
| 82 |
|
| 83 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
checks = questions_for(pair, domain, pack)
|
| 85 |
if not checks:
|
| 86 |
raise ValueError('No applicable detection questions')
|
| 87 |
context = 'Perch method context (JSON):\n' + json.dumps(
|
| 88 |
pair[role]['state'], ensure_ascii=False, separators=(',', ':'))
|
| 89 |
-
return {'model': MODEL, 'input': context,
|
|
|
|
| 90 |
|
| 91 |
|
| 92 |
-
def prediction(pair, role, domain, pack, response, elapsed, request_id):
|
| 93 |
checks = questions_for(pair, domain, pack)
|
| 94 |
if response.get('model') != MODEL:
|
| 95 |
raise ValueError('Decisions returned a different model')
|
| 96 |
answers = response.get('answers', [])
|
| 97 |
if len(answers) != len(checks) or {a['name'] for a in answers} != {c['name'] for c in checks}:
|
| 98 |
raise ValueError('Decisions returned missing, duplicate or unexpected answers')
|
| 99 |
-
|
| 100 |
-
|
|
|
|
|
|
|
| 101 |
raise AnswerError('Decisions returned ' + types, response, request_id, elapsed)
|
| 102 |
-
probabilities = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
scores = {c['name']: core.raised_score(c, probabilities[c['name']]) for c in checks}
|
| 104 |
score, alert = (scores['semantic'], scores['semantic'] > .7) if domain == 'lint' else core.scan_result(scores, checks, domain, .5)
|
| 105 |
usage = response.get('usage', {})
|
| 106 |
if not isinstance(usage.get('input_tokens'), int) or usage['input_tokens'] < 0:
|
| 107 |
raise ValueError('Decisions did not return billable input-token usage')
|
| 108 |
-
|
| 109 |
-
'model_id': MODEL_ID
|
|
|
|
| 110 |
'pack_sha256': pack['pack_sha256'] if domain != 'lint' else None,
|
| 111 |
'score': score, 'alert': alert, 'question_scores': scores,
|
| 112 |
-
'
|
| 113 |
'latency_seconds': elapsed, 'request_id': request_id}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
|
| 116 |
-
def predict(key, pair, role, domain, pack, timeout, limiter):
|
| 117 |
-
payload, _ = payload_for(pair, role, domain, pack)
|
| 118 |
body = json.dumps(payload, ensure_ascii=False).encode()
|
| 119 |
estimated_tokens = max(1, len(body) // 3)
|
| 120 |
started = time.monotonic()
|
|
@@ -126,7 +163,7 @@ def predict(key, pair, role, domain, pack, timeout, limiter):
|
|
| 126 |
with urlopen(request, timeout=timeout) as result:
|
| 127 |
response = json.load(result)
|
| 128 |
request_id = result.headers.get('x-request-id')
|
| 129 |
-
return prediction(pair, role, domain, pack, response, time.monotonic() - started, request_id)
|
| 130 |
except HTTPError as exc:
|
| 131 |
detail = json.loads(exc.read()).get('error', {})
|
| 132 |
code = detail.get('code')
|
|
@@ -138,7 +175,7 @@ def predict(key, pair, role, domain, pack, timeout, limiter):
|
|
| 138 |
raise AssertionError('unreachable')
|
| 139 |
|
| 140 |
|
| 141 |
-
def report(group, pack):
|
| 142 |
pairs, predictions, failures = group['pairs'], group['predictions'], group['failures']
|
| 143 |
domain = group['domain']
|
| 144 |
counts = dict(tp=0, fp=0, fn=0, tn=0)
|
|
@@ -164,13 +201,20 @@ def report(group, pack):
|
|
| 164 |
tokens = sum(r.get('usage', {}).get('input_tokens', 0) for r in [*predictions.values(), *failures.values()])
|
| 165 |
latencies = sorted(r['latency_seconds'] for r in predictions.values())
|
| 166 |
ordering = {'correct': correct, 'ties': ties, 'eligible': eligible}
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
'benchmark_sha256': group['digest'], 'benchmark_pairs': len(pairs), 'benchmark_methods': 2 * len(pairs),
|
| 170 |
'answered_methods': len(predictions), 'failed_methods': len(failures),
|
| 171 |
'complete': len(predictions) + len(failures) == 2 * len(pairs),
|
| 172 |
'failure_policy': 'failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering',
|
| 173 |
'failure_counts': dict(Counter(r['error'] for r in failures.values())),
|
|
|
|
|
|
|
|
|
|
| 174 |
'confusion': counts, 'precision': tp / (tp + fp) if tp + fp else 0,
|
| 175 |
'recall': tp / (tp + fn) if tp + fn else 0, 'false_positive_rate': fp / (fp + tn) if fp + tn else 0,
|
| 176 |
'f1': 2 * tp / (2 * tp + fp + fn) if 2 * tp + fp + fn else 0,
|
|
@@ -198,7 +242,9 @@ def main():
|
|
| 198 |
parser.add_argument('--timeout', type=float, default=45)
|
| 199 |
parser.add_argument('--budget', type=float, default=5)
|
| 200 |
parser.add_argument('--score-saved', action='store_true')
|
|
|
|
| 201 |
args = parser.parse_args()
|
|
|
|
| 202 |
pack = core.load_pack(args.question_pack)
|
| 203 |
groups, pending_groups = [], []
|
| 204 |
for dataset in json.loads(args.manifest.read_text())['datasets']:
|
|
@@ -218,7 +264,7 @@ def main():
|
|
| 218 |
identity = r['pair_id'], r['role']
|
| 219 |
if identity not in expected or identity in preds or identity in fails:
|
| 220 |
raise ValueError('Invalid or duplicate saved outcome')
|
| 221 |
-
if r['dataset_sha256'] != digest or r['protocol_id'] !=
|
| 222 |
raise ValueError('Saved outcome uses a different dataset, model or protocol')
|
| 223 |
if r.get('pack_sha256') != (pack['pack_sha256'] if dataset['domain'] != 'lint' else None):
|
| 224 |
raise ValueError('Saved outcome uses a different question pack')
|
|
@@ -230,7 +276,7 @@ def main():
|
|
| 230 |
if (pair['pair_id'], role) not in preds and (pair['pair_id'], role) not in fails])
|
| 231 |
pending = [job for row in zip_longest(*pending_groups) for job in row if job is not None]
|
| 232 |
def save_reports():
|
| 233 |
-
reports = [report(g, pack) for g in groups]
|
| 234 |
for g, result in zip(groups, reports):
|
| 235 |
(g['directory'] / 'report.json').write_text(json.dumps(result, indent=2) + '\n')
|
| 236 |
status = {'model': MODEL, 'reports': reports,
|
|
@@ -256,7 +302,7 @@ def main():
|
|
| 256 |
job = next(iterator, None)
|
| 257 |
if job:
|
| 258 |
group, pair, role = job
|
| 259 |
-
active[pool.submit(predict, key, pair, role, group['domain'], pack, args.timeout, limiter)] = job
|
| 260 |
for _ in range(args.workers):
|
| 261 |
submit()
|
| 262 |
try:
|
|
@@ -273,7 +319,7 @@ def main():
|
|
| 273 |
raise
|
| 274 |
except Exception as exc:
|
| 275 |
row = {'pair_id': pair['pair_id'], 'role': role, 'domain': group['domain'],
|
| 276 |
-
'model_revision': MODEL, 'protocol_id':
|
| 277 |
'pack_sha256': pack['pack_sha256'] if group['domain'] != 'lint' else None,
|
| 278 |
'status': 'failed', 'error': str(exc),
|
| 279 |
'usage': getattr(exc, 'usage', {}), 'answers': getattr(exc, 'answers', []),
|
|
|
|
| 2 |
"""Run OpenAI Decisions on the Perch bug, security and semantic lint benchmarks.
|
| 3 |
|
| 4 |
Each method is independent. Applicable checks share its complete saved context.
|
| 5 |
+
Predicates and choices retain the frozen question and answer criteria. No repair is shown.
|
| 6 |
Failed requests are saved once and counted as wrong decisions, without scores.
|
| 7 |
"""
|
| 8 |
from __future__ import annotations
|
|
|
|
| 27 |
API = 'https://api.openai.com/v1/decisions'
|
| 28 |
PRICE = .10
|
| 29 |
PROTOCOL = 'openai-decisions-perch-predicate-v1'
|
| 30 |
+
CHOICE_PROTOCOL = 'openai-decisions-perch-choice-v1'
|
| 31 |
spec = importlib.util.spec_from_file_location('perch_benchmark', ROOT / 'benchmark.py')
|
| 32 |
core = importlib.util.module_from_spec(spec)
|
| 33 |
spec.loader.exec_module(core)
|
|
|
|
| 75 |
|
| 76 |
def predicate(check):
|
| 77 |
question = check['question']
|
| 78 |
+
if not question.get('criteria'):
|
| 79 |
+
return {'type': 'predicate', 'name': check['name'],
|
| 80 |
+
'instructions': question['instructions']}
|
| 81 |
return {'type': 'predicate', 'name': check['name'],
|
| 82 |
'instructions': question['instructions'].strip() + '\nTrue: ' +
|
| 83 |
question['criteria']['true'].strip() + '\nFalse: ' +
|
| 84 |
question['criteria']['false'].strip()}
|
| 85 |
|
| 86 |
|
| 87 |
+
def decision_question(check, protocol=PROTOCOL):
|
| 88 |
+
question = check['question']
|
| 89 |
+
criteria = question.get('criteria') or {}
|
| 90 |
+
if protocol == CHOICE_PROTOCOL and 'true' in criteria and 'false' in criteria:
|
| 91 |
+
return {'type': 'choice', 'name': check['name'],
|
| 92 |
+
'instructions': question['instructions'],
|
| 93 |
+
'choices': [{'value': value, 'description': criteria[value]}
|
| 94 |
+
for value in ('true', 'false')]}
|
| 95 |
+
return predicate(check)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def payload_for(pair, role, domain, pack, protocol=PROTOCOL):
|
| 99 |
checks = questions_for(pair, domain, pack)
|
| 100 |
if not checks:
|
| 101 |
raise ValueError('No applicable detection questions')
|
| 102 |
context = 'Perch method context (JSON):\n' + json.dumps(
|
| 103 |
pair[role]['state'], ensure_ascii=False, separators=(',', ':'))
|
| 104 |
+
return {'model': MODEL, 'input': context,
|
| 105 |
+
'questions': [decision_question(c, protocol) for c in checks]}, checks
|
| 106 |
|
| 107 |
|
| 108 |
+
def prediction(pair, role, domain, pack, response, elapsed, request_id, protocol=PROTOCOL):
|
| 109 |
checks = questions_for(pair, domain, pack)
|
| 110 |
if response.get('model') != MODEL:
|
| 111 |
raise ValueError('Decisions returned a different model')
|
| 112 |
answers = response.get('answers', [])
|
| 113 |
if len(answers) != len(checks) or {a['name'] for a in answers} != {c['name'] for c in checks}:
|
| 114 |
raise ValueError('Decisions returned missing, duplicate or unexpected answers')
|
| 115 |
+
expected_types = {c['name']: decision_question(c, protocol)['type'] for c in checks}
|
| 116 |
+
if any(a.get('type') != expected_types[a['name']] for a in answers):
|
| 117 |
+
types = ', '.join(a['name'] + ':' + str(a.get('type')) for a in answers
|
| 118 |
+
if a.get('type') != expected_types[a['name']])
|
| 119 |
raise AnswerError('Decisions returned ' + types, response, request_id, elapsed)
|
| 120 |
+
probabilities = {}
|
| 121 |
+
try:
|
| 122 |
+
for answer in answers:
|
| 123 |
+
if answer['type'] == 'choice':
|
| 124 |
+
options = answer['probabilities']
|
| 125 |
+
if len(options) != 2 or {p['value'] for p in options} != {'true', 'false'}:
|
| 126 |
+
raise ValueError('Expected exactly true and false probabilities')
|
| 127 |
+
values = {p['value']: core.probability(p['probability']) for p in options}
|
| 128 |
+
if abs(sum(values.values()) - 1) > .001:
|
| 129 |
+
raise ValueError('Choice probabilities do not sum to one')
|
| 130 |
+
probabilities[answer['name']] = values['true']
|
| 131 |
+
else:
|
| 132 |
+
probabilities[answer['name']] = core.probability(answer['probability'])
|
| 133 |
+
except (KeyError, TypeError, ValueError) as exc:
|
| 134 |
+
raise AnswerError('Invalid Decisions probabilities: ' + str(exc), response, request_id, elapsed) from exc
|
| 135 |
scores = {c['name']: core.raised_score(c, probabilities[c['name']]) for c in checks}
|
| 136 |
score, alert = (scores['semantic'], scores['semantic'] > .7) if domain == 'lint' else core.scan_result(scores, checks, domain, .5)
|
| 137 |
usage = response.get('usage', {})
|
| 138 |
if not isinstance(usage.get('input_tokens'), int) or usage['input_tokens'] < 0:
|
| 139 |
raise ValueError('Decisions did not return billable input-token usage')
|
| 140 |
+
row = {'pair_id': pair['pair_id'], 'role': role, 'domain': domain,
|
| 141 |
+
'model_id': MODEL_ID if protocol == PROTOCOL else MODEL_ID + '-choice',
|
| 142 |
+
'model_revision': MODEL, 'protocol_id': protocol,
|
| 143 |
'pack_sha256': pack['pack_sha256'] if domain != 'lint' else None,
|
| 144 |
'score': score, 'alert': alert, 'question_scores': scores,
|
| 145 |
+
'usage': usage,
|
| 146 |
'latency_seconds': elapsed, 'request_id': request_id}
|
| 147 |
+
row['predicate_probabilities' if protocol == PROTOCOL else 'true_probabilities'] = probabilities
|
| 148 |
+
if protocol == CHOICE_PROTOCOL:
|
| 149 |
+
row['answers'] = answers
|
| 150 |
+
return row
|
| 151 |
|
| 152 |
|
| 153 |
+
def predict(key, pair, role, domain, pack, timeout, limiter, protocol=PROTOCOL):
|
| 154 |
+
payload, _ = payload_for(pair, role, domain, pack, protocol)
|
| 155 |
body = json.dumps(payload, ensure_ascii=False).encode()
|
| 156 |
estimated_tokens = max(1, len(body) // 3)
|
| 157 |
started = time.monotonic()
|
|
|
|
| 163 |
with urlopen(request, timeout=timeout) as result:
|
| 164 |
response = json.load(result)
|
| 165 |
request_id = result.headers.get('x-request-id')
|
| 166 |
+
return prediction(pair, role, domain, pack, response, time.monotonic() - started, request_id, protocol)
|
| 167 |
except HTTPError as exc:
|
| 168 |
detail = json.loads(exc.read()).get('error', {})
|
| 169 |
code = detail.get('code')
|
|
|
|
| 175 |
raise AssertionError('unreachable')
|
| 176 |
|
| 177 |
|
| 178 |
+
def report(group, pack, protocol=PROTOCOL):
|
| 179 |
pairs, predictions, failures = group['pairs'], group['predictions'], group['failures']
|
| 180 |
domain = group['domain']
|
| 181 |
counts = dict(tp=0, fp=0, fn=0, tn=0)
|
|
|
|
| 201 |
tokens = sum(r.get('usage', {}).get('input_tokens', 0) for r in [*predictions.values(), *failures.values()])
|
| 202 |
latencies = sorted(r['latency_seconds'] for r in predictions.values())
|
| 203 |
ordering = {'correct': correct, 'ties': ties, 'eligible': eligible}
|
| 204 |
+
per_question = Counter(a['name'] for r in failures.values() for a in r.get('answers', [])
|
| 205 |
+
if a.get('type') == 'refusal')
|
| 206 |
+
return {'domain': domain, 'track': group['split'],
|
| 207 |
+
'model_id': MODEL_ID if protocol == PROTOCOL else MODEL_ID + '-choice',
|
| 208 |
+
'model_revision': MODEL, 'protocol_id': protocol,
|
| 209 |
+
'run_id': 'openai-decisions-20261006' if protocol == PROTOCOL else 'openai-decisions-choice-20261006',
|
| 210 |
'benchmark_sha256': group['digest'], 'benchmark_pairs': len(pairs), 'benchmark_methods': 2 * len(pairs),
|
| 211 |
'answered_methods': len(predictions), 'failed_methods': len(failures),
|
| 212 |
'complete': len(predictions) + len(failures) == 2 * len(pairs),
|
| 213 |
'failure_policy': 'failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering',
|
| 214 |
'failure_counts': dict(Counter(r['error'] for r in failures.values())),
|
| 215 |
+
'failure_counts_per_question': dict(per_question),
|
| 216 |
+
'refused_methods': sum(any(a.get('type') == 'refusal' for a in r.get('answers', []))
|
| 217 |
+
for r in failures.values()),
|
| 218 |
'confusion': counts, 'precision': tp / (tp + fp) if tp + fp else 0,
|
| 219 |
'recall': tp / (tp + fn) if tp + fn else 0, 'false_positive_rate': fp / (fp + tn) if fp + tn else 0,
|
| 220 |
'f1': 2 * tp / (2 * tp + fp + fn) if 2 * tp + fp + fn else 0,
|
|
|
|
| 242 |
parser.add_argument('--timeout', type=float, default=45)
|
| 243 |
parser.add_argument('--budget', type=float, default=5)
|
| 244 |
parser.add_argument('--score-saved', action='store_true')
|
| 245 |
+
parser.add_argument('--protocol', choices=('predicate', 'choice'), default='predicate')
|
| 246 |
args = parser.parse_args()
|
| 247 |
+
protocol = PROTOCOL if args.protocol == 'predicate' else CHOICE_PROTOCOL
|
| 248 |
pack = core.load_pack(args.question_pack)
|
| 249 |
groups, pending_groups = [], []
|
| 250 |
for dataset in json.loads(args.manifest.read_text())['datasets']:
|
|
|
|
| 264 |
identity = r['pair_id'], r['role']
|
| 265 |
if identity not in expected or identity in preds or identity in fails:
|
| 266 |
raise ValueError('Invalid or duplicate saved outcome')
|
| 267 |
+
if r['dataset_sha256'] != digest or r['protocol_id'] != protocol or r['model_revision'] != MODEL:
|
| 268 |
raise ValueError('Saved outcome uses a different dataset, model or protocol')
|
| 269 |
if r.get('pack_sha256') != (pack['pack_sha256'] if dataset['domain'] != 'lint' else None):
|
| 270 |
raise ValueError('Saved outcome uses a different question pack')
|
|
|
|
| 276 |
if (pair['pair_id'], role) not in preds and (pair['pair_id'], role) not in fails])
|
| 277 |
pending = [job for row in zip_longest(*pending_groups) for job in row if job is not None]
|
| 278 |
def save_reports():
|
| 279 |
+
reports = [report(g, pack, protocol) for g in groups]
|
| 280 |
for g, result in zip(groups, reports):
|
| 281 |
(g['directory'] / 'report.json').write_text(json.dumps(result, indent=2) + '\n')
|
| 282 |
status = {'model': MODEL, 'reports': reports,
|
|
|
|
| 302 |
job = next(iterator, None)
|
| 303 |
if job:
|
| 304 |
group, pair, role = job
|
| 305 |
+
active[pool.submit(predict, key, pair, role, group['domain'], pack, args.timeout, limiter, protocol)] = job
|
| 306 |
for _ in range(args.workers):
|
| 307 |
submit()
|
| 308 |
try:
|
|
|
|
| 319 |
raise
|
| 320 |
except Exception as exc:
|
| 321 |
row = {'pair_id': pair['pair_id'], 'role': role, 'domain': group['domain'],
|
| 322 |
+
'model_revision': MODEL, 'protocol_id': protocol,
|
| 323 |
'pack_sha256': pack['pack_sha256'] if group['domain'] != 'lint' else None,
|
| 324 |
'status': 'failed', 'error': str(exc),
|
| 325 |
'usage': getattr(exc, 'usage', {}), 'answers': getattr(exc, 'answers', []),
|
predictions/current/bug/openai-decisions.jsonl
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e8ed2c9159299b95911a2879284777ee04d29f3c6394c8c99cf59902b9eaf82e
|
| 3 |
+
size 5317543
|
predictions/current/lint/openai-decisions.jsonl
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f3c5817f3973524f258865ac1f972da2bf1a8b143215bec23bb2c0c52ebf40fa
|
| 3 |
+
size 394083
|
predictions/current/security/openai-decisions.jsonl
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:26ce3b6291e12a8be72af0b42a3f475a5a4324e79054ae019e91c82cc3f31e88
|
| 3 |
+
size 14582673
|
results-current.jsonl
CHANGED
|
@@ -46,9 +46,9 @@
|
|
| 46 |
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 996, "average_precision_answered_methods": 0.43547986367375113, "benchmark_methods": 996, "benchmark_pairs": 498, "benchmark_sha256": "3df4ade65fedd1128d30bc17c9c9869c8ab9bd526e666156d0e16685e78f8a73", "complete": true, "confusion": {"fn": 417, "fp": 12, "tn": 560, "tp": 7}, "cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "domain": "bug", "f1": 0.03160270880361174, "failed_methods": 0, "failure_counts": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.02097902097902098, "inference_cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "inference_cost_usd": 0.039281729999999994, "inference_endpoint": "https://api.fastino.ai/v1/chat/completions", "inference_host": "Fastino API", "input_tokens": 1309391, "model_id": "gliner25-decide", "model_revision": "fastino/GLiNER-2.5-Decide", "pair_order": 0.5211970074812967, "pair_order_correct": 209, "pair_order_eligible": 401, "precision": 0.3684210526315789, "protocol_id": "gliner25-decide-perch-sized-classification-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.01650943396226415, "run_id": "gliner25-decide-perch-sized-20261002", "sizing": {"adapter_sha256": "6be2c1e0003b8181ea7725193c039ed21b3a86fa80bafe46f99d7759b76c6b93", "max_questions": null, "perch_revision": "3db94f007ca49433c816b4a3855253d15f7b8139", "request_budget": 1800, "state_budget": 1200}, "split": "private", "threshold": 0.5, "track": "private", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 209, "eligible": 401, "ties": 28}}
|
| 47 |
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 2616, "average_precision_answered_methods": 0.4560152509236216, "benchmark_methods": 2622, "benchmark_pairs": 1311, "benchmark_sha256": "2407059caa3486371749884138b997d89043eec646e548ee8f44ba3ab08514b8", "complete": true, "confusion": {"fn": 1118, "fp": 23, "tn": 1457, "tp": 24}, "cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "domain": "security", "f1": 0.040370058873002525, "failed_methods": 6, "failure_counts": {"other": 6}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.015540540540540541, "inference_cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "inference_cost_usd": 0.43368182999999993, "inference_endpoint": "https://api.fastino.ai/v1/chat/completions", "inference_host": "Fastino API", "input_tokens": 14456061, "model_id": "gliner25-decide", "model_revision": "fastino/GLiNER-2.5-Decide", "pair_order": 0.45729537366548045, "pair_order_correct": 514, "pair_order_eligible": 1124, "precision": 0.5106382978723404, "protocol_id": "gliner25-decide-perch-sized-classification-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.021015761821366025, "run_id": "gliner25-decide-perch-sized-20261002", "sizing": {"adapter_sha256": "6be2c1e0003b8181ea7725193c039ed21b3a86fa80bafe46f99d7759b76c6b93", "max_questions": null, "perch_revision": "3db94f007ca49433c816b4a3855253d15f7b8139", "request_budget": 1800, "state_budget": 1200}, "split": "public", "threshold": 0.5, "track": "public", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 514, "eligible": 1124, "ties": 35}}
|
| 48 |
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 877, "average_precision_answered_methods": 0.44020539336977416, "benchmark_methods": 878, "benchmark_pairs": 439, "benchmark_sha256": "a4b81728e9e520cf1c6f342974bec369d72f5b7d8aabc1c9cf2aceba966f8051", "complete": true, "confusion": {"fn": 390, "fp": 7, "tn": 473, "tp": 8}, "cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "domain": "security", "f1": 0.0387409200968523, "failed_methods": 1, "failure_counts": {"other": 1}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.014583333333333334, "inference_cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "inference_cost_usd": 0.14154047999999997, "inference_endpoint": "https://api.fastino.ai/v1/chat/completions", "inference_host": "Fastino API", "input_tokens": 4718016, "model_id": "gliner25-decide", "model_revision": "fastino/GLiNER-2.5-Decide", "pair_order": 0.4949748743718593, "pair_order_correct": 197, "pair_order_eligible": 398, "precision": 0.5333333333333333, "protocol_id": "gliner25-decide-perch-sized-classification-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.020100502512562814, "run_id": "gliner25-decide-perch-sized-20261002", "sizing": {"adapter_sha256": "6be2c1e0003b8181ea7725193c039ed21b3a86fa80bafe46f99d7759b76c6b93", "max_questions": null, "perch_revision": "3db94f007ca49433c816b4a3855253d15f7b8139", "request_budget": 1800, "state_budget": 1200}, "split": "private", "threshold": 0.5, "track": "private", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 197, "eligible": 398, "ties": 8}}
|
| 49 |
-
{"alert_rule": "
|
| 50 |
-
{"alert_rule": "
|
| 51 |
-
{"alert_rule": "
|
| 52 |
-
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods":
|
| 53 |
-
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods":
|
| 54 |
-
{"alert_rule": "
|
|
|
|
| 46 |
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 996, "average_precision_answered_methods": 0.43547986367375113, "benchmark_methods": 996, "benchmark_pairs": 498, "benchmark_sha256": "3df4ade65fedd1128d30bc17c9c9869c8ab9bd526e666156d0e16685e78f8a73", "complete": true, "confusion": {"fn": 417, "fp": 12, "tn": 560, "tp": 7}, "cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "domain": "bug", "f1": 0.03160270880361174, "failed_methods": 0, "failure_counts": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.02097902097902098, "inference_cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "inference_cost_usd": 0.039281729999999994, "inference_endpoint": "https://api.fastino.ai/v1/chat/completions", "inference_host": "Fastino API", "input_tokens": 1309391, "model_id": "gliner25-decide", "model_revision": "fastino/GLiNER-2.5-Decide", "pair_order": 0.5211970074812967, "pair_order_correct": 209, "pair_order_eligible": 401, "precision": 0.3684210526315789, "protocol_id": "gliner25-decide-perch-sized-classification-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.01650943396226415, "run_id": "gliner25-decide-perch-sized-20261002", "sizing": {"adapter_sha256": "6be2c1e0003b8181ea7725193c039ed21b3a86fa80bafe46f99d7759b76c6b93", "max_questions": null, "perch_revision": "3db94f007ca49433c816b4a3855253d15f7b8139", "request_budget": 1800, "state_budget": 1200}, "split": "private", "threshold": 0.5, "track": "private", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 209, "eligible": 401, "ties": 28}}
|
| 47 |
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 2616, "average_precision_answered_methods": 0.4560152509236216, "benchmark_methods": 2622, "benchmark_pairs": 1311, "benchmark_sha256": "2407059caa3486371749884138b997d89043eec646e548ee8f44ba3ab08514b8", "complete": true, "confusion": {"fn": 1118, "fp": 23, "tn": 1457, "tp": 24}, "cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "domain": "security", "f1": 0.040370058873002525, "failed_methods": 6, "failure_counts": {"other": 6}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.015540540540540541, "inference_cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "inference_cost_usd": 0.43368182999999993, "inference_endpoint": "https://api.fastino.ai/v1/chat/completions", "inference_host": "Fastino API", "input_tokens": 14456061, "model_id": "gliner25-decide", "model_revision": "fastino/GLiNER-2.5-Decide", "pair_order": 0.45729537366548045, "pair_order_correct": 514, "pair_order_eligible": 1124, "precision": 0.5106382978723404, "protocol_id": "gliner25-decide-perch-sized-classification-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.021015761821366025, "run_id": "gliner25-decide-perch-sized-20261002", "sizing": {"adapter_sha256": "6be2c1e0003b8181ea7725193c039ed21b3a86fa80bafe46f99d7759b76c6b93", "max_questions": null, "perch_revision": "3db94f007ca49433c816b4a3855253d15f7b8139", "request_budget": 1800, "state_budget": 1200}, "split": "public", "threshold": 0.5, "track": "public", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 514, "eligible": 1124, "ties": 35}}
|
| 48 |
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 877, "average_precision_answered_methods": 0.44020539336977416, "benchmark_methods": 878, "benchmark_pairs": 439, "benchmark_sha256": "a4b81728e9e520cf1c6f342974bec369d72f5b7d8aabc1c9cf2aceba966f8051", "complete": true, "confusion": {"fn": 390, "fp": 7, "tn": 473, "tp": 8}, "cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "domain": "security", "f1": 0.0387409200968523, "failed_methods": 1, "failure_counts": {"other": 1}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.014583333333333334, "inference_cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "inference_cost_usd": 0.14154047999999997, "inference_endpoint": "https://api.fastino.ai/v1/chat/completions", "inference_host": "Fastino API", "input_tokens": 4718016, "model_id": "gliner25-decide", "model_revision": "fastino/GLiNER-2.5-Decide", "pair_order": 0.4949748743718593, "pair_order_correct": 197, "pair_order_eligible": 398, "precision": 0.5333333333333333, "protocol_id": "gliner25-decide-perch-sized-classification-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.020100502512562814, "run_id": "gliner25-decide-perch-sized-20261002", "sizing": {"adapter_sha256": "6be2c1e0003b8181ea7725193c039ed21b3a86fa80bafe46f99d7759b76c6b93", "max_questions": null, "perch_revision": "3db94f007ca49433c816b4a3855253d15f7b8139", "request_budget": 1800, "state_budget": 1200}, "split": "private", "threshold": 0.5, "track": "private", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 197, "eligible": 398, "ties": 8}}
|
| 49 |
+
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 4440, "average_precision_answered_methods": 0.4831610495664901, "benchmark_methods": 4440, "benchmark_pairs": 2220, "benchmark_sha256": "32bc68bc85d5535ad28e103adbfa0c09c73e09d0f53a53f7ca35ec219a96e6e2", "complete": true, "confusion": {"fn": 955, "fp": 997, "tn": 1582, "tp": 906}, "domain": "bug", "f1": 0.4814027630180659, "failed_methods": 0, "failure_counts": {}, "failure_counts_per_question": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.38658394726638234, "inference_cost_basis": "Decisions API-reported input tokens at $0.10/M; no output or cache charges; transport failures without returned usage excluded", "inference_cost_usd": 1.1018942, "inference_endpoint": "https://api.openai.com/v1/decisions", "inference_host": "OpenAI Decisions API", "input_tokens": 11018942, "latency_basis": "Per-method elapsed time, including client rate-limit waits and 429 backoff", "latency_median_seconds": 3.428778040979523, "latency_p95_seconds": 5.043582332989899, "model_id": "openai-decisions", "model_revision": "gpt-6-luna", "pair_order": 0.4797979797979798, "pair_order_correct": 855, "pair_order_eligible": 1782, "precision": 0.47609038360483447, "protocol_id": "openai-decisions-perch-choice-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.48683503492745833, "refused_methods": 0, "run_id": "openai-decisions-choice-20261006", "threshold": 0.5, "track": "public", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 855, "eligible": 1782, "ties": 105}}
|
| 50 |
+
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 2622, "average_precision_answered_methods": 0.5007223297716433, "benchmark_methods": 2622, "benchmark_pairs": 1311, "benchmark_sha256": "2407059caa3486371749884138b997d89043eec646e548ee8f44ba3ab08514b8", "complete": true, "confusion": {"fn": 524, "fp": 658, "tn": 822, "tp": 618}, "domain": "security", "f1": 0.511166253101737, "failed_methods": 0, "failure_counts": {}, "failure_counts_per_question": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.4445945945945946, "inference_cost_basis": "Decisions API-reported input tokens at $0.10/M; no output or cache charges; transport failures without returned usage excluded", "inference_cost_usd": 1.4690454000000002, "inference_endpoint": "https://api.openai.com/v1/decisions", "inference_host": "OpenAI Decisions API", "input_tokens": 14690454, "latency_basis": "Per-method elapsed time, including client rate-limit waits and 429 backoff", "latency_median_seconds": 3.770231959002558, "latency_p95_seconds": 5.241487499995856, "model_id": "openai-decisions", "model_revision": "gpt-6-luna", "pair_order": 0.48398576512455516, "pair_order_correct": 544, "pair_order_eligible": 1124, "precision": 0.4843260188087774, "protocol_id": "openai-decisions-perch-choice-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.5411558669001751, "refused_methods": 0, "run_id": "openai-decisions-choice-20261006", "threshold": 0.5, "track": "public", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 544, "eligible": 1124, "ties": 117}}
|
| 51 |
+
{"alert_rule": "rule violation probability > 0.7", "answered_methods": 428, "average_precision_answered_methods": 0.9607007525697188, "benchmark_methods": 428, "benchmark_pairs": 214, "benchmark_sha256": "534f6c2abddc507c40f4597607e97e07168c544011d617b83aa39e08abb35d75", "complete": true, "confusion": {"fn": 50, "fp": 10, "tn": 204, "tp": 164}, "domain": "lint", "f1": 0.845360824742268, "failed_methods": 0, "failure_counts": {}, "failure_counts_per_question": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.04672897196261682, "inference_cost_basis": "Decisions API-reported input tokens at $0.10/M; no output or cache charges; transport failures without returned usage excluded", "inference_cost_usd": 0.0929731, "inference_endpoint": "https://api.openai.com/v1/decisions", "inference_host": "OpenAI Decisions API", "input_tokens": 929731, "latency_basis": "Per-method elapsed time, including client rate-limit waits and 429 backoff", "latency_median_seconds": 3.5743396670150105, "latency_p95_seconds": 4.67788199998904, "model_id": "openai-decisions", "model_revision": "gpt-6-luna", "pair_order": 0.9626168224299065, "pair_order_correct": 206, "pair_order_eligible": 214, "precision": 0.9425287356321839, "protocol_id": "openai-decisions-perch-choice-v1", "question_pack_sha256": null, "recall": 0.7663551401869159, "refused_methods": 0, "run_id": "openai-decisions-choice-20261006", "threshold": 0.7, "track": "public", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 206, "eligible": 214, "ties": 3}}
|
| 52 |
+
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 996, "average_precision_answered_methods": 0.5038335285710763, "benchmark_methods": 996, "benchmark_pairs": 498, "benchmark_sha256": "3df4ade65fedd1128d30bc17c9c9869c8ab9bd526e666156d0e16685e78f8a73", "complete": true, "confusion": {"fn": 202, "fp": 236, "tn": 336, "tp": 222}, "domain": "bug", "f1": 0.5034013605442177, "failed_methods": 0, "failure_counts": {}, "failure_counts_per_question": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.4125874125874126, "inference_cost_basis": "Decisions API-reported input tokens at $0.10/M; no output or cache charges; transport failures without returned usage excluded", "inference_cost_usd": 0.2474223, "inference_endpoint": "https://api.openai.com/v1/decisions", "inference_host": "OpenAI Decisions API", "input_tokens": 2474223, "latency_basis": "Per-method elapsed time, including client rate-limit waits and 429 backoff", "latency_median_seconds": 3.7011702089803293, "latency_p95_seconds": 5.054382875008741, "model_id": "openai-decisions", "model_revision": "gpt-6-luna", "pair_order": 0.49875311720698257, "pair_order_correct": 200, "pair_order_eligible": 401, "precision": 0.4847161572052402, "protocol_id": "openai-decisions-perch-choice-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.5235849056603774, "refused_methods": 0, "run_id": "openai-decisions-choice-20261006", "threshold": 0.5, "track": "private", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 200, "eligible": 401, "ties": 29}}
|
| 53 |
+
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 878, "average_precision_answered_methods": 0.5143518871191308, "benchmark_methods": 878, "benchmark_pairs": 439, "benchmark_sha256": "a4b81728e9e520cf1c6f342974bec369d72f5b7d8aabc1c9cf2aceba966f8051", "complete": true, "confusion": {"fn": 237, "fp": 151, "tn": 329, "tp": 161}, "domain": "security", "f1": 0.4535211267605634, "failed_methods": 0, "failure_counts": {}, "failure_counts_per_question": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.3145833333333333, "inference_cost_basis": "Decisions API-reported input tokens at $0.10/M; no output or cache charges; transport failures without returned usage excluded", "inference_cost_usd": 0.5297818000000001, "inference_endpoint": "https://api.openai.com/v1/decisions", "inference_host": "OpenAI Decisions API", "input_tokens": 5297818, "latency_basis": "Per-method elapsed time, including client rate-limit waits and 429 backoff", "latency_median_seconds": 3.751356124994345, "latency_p95_seconds": 5.058746583003085, "model_id": "openai-decisions", "model_revision": "gpt-6-luna", "pair_order": 0.5301507537688442, "pair_order_correct": 211, "pair_order_eligible": 398, "precision": 0.5160256410256411, "protocol_id": "openai-decisions-perch-choice-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.4045226130653266, "refused_methods": 0, "run_id": "openai-decisions-choice-20261006", "threshold": 0.5, "track": "private", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 211, "eligible": 398, "ties": 21}}
|
| 54 |
+
{"alert_rule": "rule violation probability > 0.7", "answered_methods": 142, "average_precision_answered_methods": 0.9427382409373941, "benchmark_methods": 142, "benchmark_pairs": 71, "benchmark_sha256": "a6e9f2e4ee8ae77bdaf23af46920d97d1ba47375dc9ce03b950cdbe95c2777f9", "complete": true, "confusion": {"fn": 11, "fp": 5, "tn": 66, "tp": 60}, "domain": "lint", "f1": 0.8823529411764706, "failed_methods": 0, "failure_counts": {}, "failure_counts_per_question": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.07042253521126761, "inference_cost_basis": "Decisions API-reported input tokens at $0.10/M; no output or cache charges; transport failures without returned usage excluded", "inference_cost_usd": 0.0297267, "inference_endpoint": "https://api.openai.com/v1/decisions", "inference_host": "OpenAI Decisions API", "input_tokens": 297267, "latency_basis": "Per-method elapsed time, including client rate-limit waits and 429 backoff", "latency_median_seconds": 3.594590458989842, "latency_p95_seconds": 4.666571665991796, "model_id": "openai-decisions", "model_revision": "gpt-6-luna", "pair_order": 0.9295774647887324, "pair_order_correct": 66, "pair_order_eligible": 71, "precision": 0.9230769230769231, "protocol_id": "openai-decisions-perch-choice-v1", "question_pack_sha256": null, "recall": 0.8450704225352113, "refused_methods": 0, "run_id": "openai-decisions-choice-20261006", "threshold": 0.7, "track": "private", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 66, "eligible": 71, "ties": 1}}
|
results.jsonl
CHANGED
|
@@ -92,9 +92,9 @@
|
|
| 92 |
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 996, "average_precision_answered_methods": 0.43547986367375113, "benchmark_methods": 996, "benchmark_pairs": 498, "benchmark_sha256": "3df4ade65fedd1128d30bc17c9c9869c8ab9bd526e666156d0e16685e78f8a73", "complete": true, "confusion": {"fn": 417, "fp": 12, "tn": 560, "tp": 7}, "cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "domain": "bug", "f1": 0.03160270880361174, "failed_methods": 0, "failure_counts": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.02097902097902098, "inference_cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "inference_cost_usd": 0.039281729999999994, "inference_endpoint": "https://api.fastino.ai/v1/chat/completions", "inference_host": "Fastino API", "input_tokens": 1309391, "model_id": "gliner25-decide", "model_revision": "fastino/GLiNER-2.5-Decide", "pair_order": 0.5211970074812967, "pair_order_correct": 209, "pair_order_eligible": 401, "precision": 0.3684210526315789, "protocol_id": "gliner25-decide-perch-sized-classification-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.01650943396226415, "run_id": "gliner25-decide-perch-sized-20261002", "sizing": {"adapter_sha256": "6be2c1e0003b8181ea7725193c039ed21b3a86fa80bafe46f99d7759b76c6b93", "max_questions": null, "perch_revision": "3db94f007ca49433c816b4a3855253d15f7b8139", "request_budget": 1800, "state_budget": 1200}, "split": "private", "threshold": 0.5, "track": "private", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 209, "eligible": 401, "ties": 28}}
|
| 93 |
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 2616, "average_precision_answered_methods": 0.4560152509236216, "benchmark_methods": 2622, "benchmark_pairs": 1311, "benchmark_sha256": "2407059caa3486371749884138b997d89043eec646e548ee8f44ba3ab08514b8", "complete": true, "confusion": {"fn": 1118, "fp": 23, "tn": 1457, "tp": 24}, "cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "domain": "security", "f1": 0.040370058873002525, "failed_methods": 6, "failure_counts": {"other": 6}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.015540540540540541, "inference_cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "inference_cost_usd": 0.43368182999999993, "inference_endpoint": "https://api.fastino.ai/v1/chat/completions", "inference_host": "Fastino API", "input_tokens": 14456061, "model_id": "gliner25-decide", "model_revision": "fastino/GLiNER-2.5-Decide", "pair_order": 0.45729537366548045, "pair_order_correct": 514, "pair_order_eligible": 1124, "precision": 0.5106382978723404, "protocol_id": "gliner25-decide-perch-sized-classification-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.021015761821366025, "run_id": "gliner25-decide-perch-sized-20261002", "sizing": {"adapter_sha256": "6be2c1e0003b8181ea7725193c039ed21b3a86fa80bafe46f99d7759b76c6b93", "max_questions": null, "perch_revision": "3db94f007ca49433c816b4a3855253d15f7b8139", "request_budget": 1800, "state_budget": 1200}, "split": "public", "threshold": 0.5, "track": "public", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 514, "eligible": 1124, "ties": 35}}
|
| 94 |
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 877, "average_precision_answered_methods": 0.44020539336977416, "benchmark_methods": 878, "benchmark_pairs": 439, "benchmark_sha256": "a4b81728e9e520cf1c6f342974bec369d72f5b7d8aabc1c9cf2aceba966f8051", "complete": true, "confusion": {"fn": 390, "fp": 7, "tn": 473, "tp": 8}, "cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "domain": "security", "f1": 0.0387409200968523, "failed_methods": 1, "failure_counts": {"other": 1}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.014583333333333334, "inference_cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "inference_cost_usd": 0.14154047999999997, "inference_endpoint": "https://api.fastino.ai/v1/chat/completions", "inference_host": "Fastino API", "input_tokens": 4718016, "model_id": "gliner25-decide", "model_revision": "fastino/GLiNER-2.5-Decide", "pair_order": 0.4949748743718593, "pair_order_correct": 197, "pair_order_eligible": 398, "precision": 0.5333333333333333, "protocol_id": "gliner25-decide-perch-sized-classification-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.020100502512562814, "run_id": "gliner25-decide-perch-sized-20261002", "sizing": {"adapter_sha256": "6be2c1e0003b8181ea7725193c039ed21b3a86fa80bafe46f99d7759b76c6b93", "max_questions": null, "perch_revision": "3db94f007ca49433c816b4a3855253d15f7b8139", "request_budget": 1800, "state_budget": 1200}, "split": "private", "threshold": 0.5, "track": "private", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 197, "eligible": 398, "ties": 8}}
|
| 95 |
-
{"alert_rule": "
|
| 96 |
-
{"alert_rule": "
|
| 97 |
-
{"alert_rule": "
|
| 98 |
-
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods":
|
| 99 |
-
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods":
|
| 100 |
-
{"alert_rule": "
|
|
|
|
| 92 |
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 996, "average_precision_answered_methods": 0.43547986367375113, "benchmark_methods": 996, "benchmark_pairs": 498, "benchmark_sha256": "3df4ade65fedd1128d30bc17c9c9869c8ab9bd526e666156d0e16685e78f8a73", "complete": true, "confusion": {"fn": 417, "fp": 12, "tn": 560, "tp": 7}, "cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "domain": "bug", "f1": 0.03160270880361174, "failed_methods": 0, "failure_counts": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.02097902097902098, "inference_cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "inference_cost_usd": 0.039281729999999994, "inference_endpoint": "https://api.fastino.ai/v1/chat/completions", "inference_host": "Fastino API", "input_tokens": 1309391, "model_id": "gliner25-decide", "model_revision": "fastino/GLiNER-2.5-Decide", "pair_order": 0.5211970074812967, "pair_order_correct": 209, "pair_order_eligible": 401, "precision": 0.3684210526315789, "protocol_id": "gliner25-decide-perch-sized-classification-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.01650943396226415, "run_id": "gliner25-decide-perch-sized-20261002", "sizing": {"adapter_sha256": "6be2c1e0003b8181ea7725193c039ed21b3a86fa80bafe46f99d7759b76c6b93", "max_questions": null, "perch_revision": "3db94f007ca49433c816b4a3855253d15f7b8139", "request_budget": 1800, "state_budget": 1200}, "split": "private", "threshold": 0.5, "track": "private", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 209, "eligible": 401, "ties": 28}}
|
| 93 |
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 2616, "average_precision_answered_methods": 0.4560152509236216, "benchmark_methods": 2622, "benchmark_pairs": 1311, "benchmark_sha256": "2407059caa3486371749884138b997d89043eec646e548ee8f44ba3ab08514b8", "complete": true, "confusion": {"fn": 1118, "fp": 23, "tn": 1457, "tp": 24}, "cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "domain": "security", "f1": 0.040370058873002525, "failed_methods": 6, "failure_counts": {"other": 6}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.015540540540540541, "inference_cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "inference_cost_usd": 0.43368182999999993, "inference_endpoint": "https://api.fastino.ai/v1/chat/completions", "inference_host": "Fastino API", "input_tokens": 14456061, "model_id": "gliner25-decide", "model_revision": "fastino/GLiNER-2.5-Decide", "pair_order": 0.45729537366548045, "pair_order_correct": 514, "pair_order_eligible": 1124, "precision": 0.5106382978723404, "protocol_id": "gliner25-decide-perch-sized-classification-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.021015761821366025, "run_id": "gliner25-decide-perch-sized-20261002", "sizing": {"adapter_sha256": "6be2c1e0003b8181ea7725193c039ed21b3a86fa80bafe46f99d7759b76c6b93", "max_questions": null, "perch_revision": "3db94f007ca49433c816b4a3855253d15f7b8139", "request_budget": 1800, "state_budget": 1200}, "split": "public", "threshold": 0.5, "track": "public", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 514, "eligible": 1124, "ties": 35}}
|
| 94 |
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 877, "average_precision_answered_methods": 0.44020539336977416, "benchmark_methods": 878, "benchmark_pairs": 439, "benchmark_sha256": "a4b81728e9e520cf1c6f342974bec369d72f5b7d8aabc1c9cf2aceba966f8051", "complete": true, "confusion": {"fn": 390, "fp": 7, "tn": 473, "tp": 8}, "cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "domain": "security", "f1": 0.0387409200968523, "failed_methods": 1, "failure_counts": {"other": 1}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.014583333333333334, "inference_cost_basis": "API-reported prompt tokens; failed requests have no returned usage", "inference_cost_usd": 0.14154047999999997, "inference_endpoint": "https://api.fastino.ai/v1/chat/completions", "inference_host": "Fastino API", "input_tokens": 4718016, "model_id": "gliner25-decide", "model_revision": "fastino/GLiNER-2.5-Decide", "pair_order": 0.4949748743718593, "pair_order_correct": 197, "pair_order_eligible": 398, "precision": 0.5333333333333333, "protocol_id": "gliner25-decide-perch-sized-classification-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.020100502512562814, "run_id": "gliner25-decide-perch-sized-20261002", "sizing": {"adapter_sha256": "6be2c1e0003b8181ea7725193c039ed21b3a86fa80bafe46f99d7759b76c6b93", "max_questions": null, "perch_revision": "3db94f007ca49433c816b4a3855253d15f7b8139", "request_budget": 1800, "state_budget": 1200}, "split": "private", "threshold": 0.5, "track": "private", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 197, "eligible": 398, "ties": 8}}
|
| 95 |
+
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 4440, "average_precision_answered_methods": 0.4831610495664901, "benchmark_methods": 4440, "benchmark_pairs": 2220, "benchmark_sha256": "32bc68bc85d5535ad28e103adbfa0c09c73e09d0f53a53f7ca35ec219a96e6e2", "complete": true, "confusion": {"fn": 955, "fp": 997, "tn": 1582, "tp": 906}, "domain": "bug", "f1": 0.4814027630180659, "failed_methods": 0, "failure_counts": {}, "failure_counts_per_question": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.38658394726638234, "inference_cost_basis": "Decisions API-reported input tokens at $0.10/M; no output or cache charges; transport failures without returned usage excluded", "inference_cost_usd": 1.1018942, "inference_endpoint": "https://api.openai.com/v1/decisions", "inference_host": "OpenAI Decisions API", "input_tokens": 11018942, "latency_basis": "Per-method elapsed time, including client rate-limit waits and 429 backoff", "latency_median_seconds": 3.428778040979523, "latency_p95_seconds": 5.043582332989899, "model_id": "openai-decisions", "model_revision": "gpt-6-luna", "pair_order": 0.4797979797979798, "pair_order_correct": 855, "pair_order_eligible": 1782, "precision": 0.47609038360483447, "protocol_id": "openai-decisions-perch-choice-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.48683503492745833, "refused_methods": 0, "run_id": "openai-decisions-choice-20261006", "threshold": 0.5, "track": "public", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 855, "eligible": 1782, "ties": 105}}
|
| 96 |
+
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 2622, "average_precision_answered_methods": 0.5007223297716433, "benchmark_methods": 2622, "benchmark_pairs": 1311, "benchmark_sha256": "2407059caa3486371749884138b997d89043eec646e548ee8f44ba3ab08514b8", "complete": true, "confusion": {"fn": 524, "fp": 658, "tn": 822, "tp": 618}, "domain": "security", "f1": 0.511166253101737, "failed_methods": 0, "failure_counts": {}, "failure_counts_per_question": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.4445945945945946, "inference_cost_basis": "Decisions API-reported input tokens at $0.10/M; no output or cache charges; transport failures without returned usage excluded", "inference_cost_usd": 1.4690454000000002, "inference_endpoint": "https://api.openai.com/v1/decisions", "inference_host": "OpenAI Decisions API", "input_tokens": 14690454, "latency_basis": "Per-method elapsed time, including client rate-limit waits and 429 backoff", "latency_median_seconds": 3.770231959002558, "latency_p95_seconds": 5.241487499995856, "model_id": "openai-decisions", "model_revision": "gpt-6-luna", "pair_order": 0.48398576512455516, "pair_order_correct": 544, "pair_order_eligible": 1124, "precision": 0.4843260188087774, "protocol_id": "openai-decisions-perch-choice-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.5411558669001751, "refused_methods": 0, "run_id": "openai-decisions-choice-20261006", "threshold": 0.5, "track": "public", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 544, "eligible": 1124, "ties": 117}}
|
| 97 |
+
{"alert_rule": "rule violation probability > 0.7", "answered_methods": 428, "average_precision_answered_methods": 0.9607007525697188, "benchmark_methods": 428, "benchmark_pairs": 214, "benchmark_sha256": "534f6c2abddc507c40f4597607e97e07168c544011d617b83aa39e08abb35d75", "complete": true, "confusion": {"fn": 50, "fp": 10, "tn": 204, "tp": 164}, "domain": "lint", "f1": 0.845360824742268, "failed_methods": 0, "failure_counts": {}, "failure_counts_per_question": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.04672897196261682, "inference_cost_basis": "Decisions API-reported input tokens at $0.10/M; no output or cache charges; transport failures without returned usage excluded", "inference_cost_usd": 0.0929731, "inference_endpoint": "https://api.openai.com/v1/decisions", "inference_host": "OpenAI Decisions API", "input_tokens": 929731, "latency_basis": "Per-method elapsed time, including client rate-limit waits and 429 backoff", "latency_median_seconds": 3.5743396670150105, "latency_p95_seconds": 4.67788199998904, "model_id": "openai-decisions", "model_revision": "gpt-6-luna", "pair_order": 0.9626168224299065, "pair_order_correct": 206, "pair_order_eligible": 214, "precision": 0.9425287356321839, "protocol_id": "openai-decisions-perch-choice-v1", "question_pack_sha256": null, "recall": 0.7663551401869159, "refused_methods": 0, "run_id": "openai-decisions-choice-20261006", "threshold": 0.7, "track": "public", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 206, "eligible": 214, "ties": 3}}
|
| 98 |
+
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 996, "average_precision_answered_methods": 0.5038335285710763, "benchmark_methods": 996, "benchmark_pairs": 498, "benchmark_sha256": "3df4ade65fedd1128d30bc17c9c9869c8ab9bd526e666156d0e16685e78f8a73", "complete": true, "confusion": {"fn": 202, "fp": 236, "tn": 336, "tp": 222}, "domain": "bug", "f1": 0.5034013605442177, "failed_methods": 0, "failure_counts": {}, "failure_counts_per_question": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.4125874125874126, "inference_cost_basis": "Decisions API-reported input tokens at $0.10/M; no output or cache charges; transport failures without returned usage excluded", "inference_cost_usd": 0.2474223, "inference_endpoint": "https://api.openai.com/v1/decisions", "inference_host": "OpenAI Decisions API", "input_tokens": 2474223, "latency_basis": "Per-method elapsed time, including client rate-limit waits and 429 backoff", "latency_median_seconds": 3.7011702089803293, "latency_p95_seconds": 5.054382875008741, "model_id": "openai-decisions", "model_revision": "gpt-6-luna", "pair_order": 0.49875311720698257, "pair_order_correct": 200, "pair_order_eligible": 401, "precision": 0.4847161572052402, "protocol_id": "openai-decisions-perch-choice-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.5235849056603774, "refused_methods": 0, "run_id": "openai-decisions-choice-20261006", "threshold": 0.5, "track": "private", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 200, "eligible": 401, "ties": 29}}
|
| 99 |
+
{"alert_rule": "any issue score > max(0.5, question min)", "answered_methods": 878, "average_precision_answered_methods": 0.5143518871191308, "benchmark_methods": 878, "benchmark_pairs": 439, "benchmark_sha256": "a4b81728e9e520cf1c6f342974bec369d72f5b7d8aabc1c9cf2aceba966f8051", "complete": true, "confusion": {"fn": 237, "fp": 151, "tn": 329, "tp": 161}, "domain": "security", "f1": 0.4535211267605634, "failed_methods": 0, "failure_counts": {}, "failure_counts_per_question": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.3145833333333333, "inference_cost_basis": "Decisions API-reported input tokens at $0.10/M; no output or cache charges; transport failures without returned usage excluded", "inference_cost_usd": 0.5297818000000001, "inference_endpoint": "https://api.openai.com/v1/decisions", "inference_host": "OpenAI Decisions API", "input_tokens": 5297818, "latency_basis": "Per-method elapsed time, including client rate-limit waits and 429 backoff", "latency_median_seconds": 3.751356124994345, "latency_p95_seconds": 5.058746583003085, "model_id": "openai-decisions", "model_revision": "gpt-6-luna", "pair_order": 0.5301507537688442, "pair_order_correct": 211, "pair_order_eligible": 398, "precision": 0.5160256410256411, "protocol_id": "openai-decisions-perch-choice-v1", "question_pack_sha256": "afe116cc8461552aaca996f8f0b639cdf5e42e9d8291c59995482309b5c330dc", "recall": 0.4045226130653266, "refused_methods": 0, "run_id": "openai-decisions-choice-20261006", "threshold": 0.5, "track": "private", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 211, "eligible": 398, "ties": 21}}
|
| 100 |
+
{"alert_rule": "rule violation probability > 0.7", "answered_methods": 142, "average_precision_answered_methods": 0.9427382409373941, "benchmark_methods": 142, "benchmark_pairs": 71, "benchmark_sha256": "a6e9f2e4ee8ae77bdaf23af46920d97d1ba47375dc9ce03b950cdbe95c2777f9", "complete": true, "confusion": {"fn": 11, "fp": 5, "tn": 66, "tp": 60}, "domain": "lint", "f1": 0.8823529411764706, "failed_methods": 0, "failure_counts": {}, "failure_counts_per_question": {}, "failure_policy": "failed positive counts as FN; failed negative counts as FP; failed pair counts as incorrect ordering", "false_positive_rate": 0.07042253521126761, "inference_cost_basis": "Decisions API-reported input tokens at $0.10/M; no output or cache charges; transport failures without returned usage excluded", "inference_cost_usd": 0.0297267, "inference_endpoint": "https://api.openai.com/v1/decisions", "inference_host": "OpenAI Decisions API", "input_tokens": 297267, "latency_basis": "Per-method elapsed time, including client rate-limit waits and 429 backoff", "latency_median_seconds": 3.594590458989842, "latency_p95_seconds": 4.666571665991796, "model_id": "openai-decisions", "model_revision": "gpt-6-luna", "pair_order": 0.9295774647887324, "pair_order_correct": 66, "pair_order_eligible": 71, "precision": 0.9230769230769231, "protocol_id": "openai-decisions-perch-choice-v1", "question_pack_sha256": null, "recall": 0.8450704225352113, "refused_methods": 0, "run_id": "openai-decisions-choice-20261006", "threshold": 0.7, "track": "private", "vulnerable_or_buggy_before_above_fixed_after": {"correct": 66, "eligible": 71, "ties": 1}}
|
test_openai_decisions.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import unittest
|
|
|
|
| 2 |
|
| 3 |
import openai_decisions as decisions
|
| 4 |
|
|
@@ -60,6 +61,67 @@ class DecisionsTests(unittest.TestCase):
|
|
| 60 |
self.assertEqual(raised.exception.usage['input_tokens'], 123)
|
| 61 |
self.assertEqual(raised.exception.answers, response['answers'])
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
if __name__ == '__main__':
|
| 65 |
unittest.main()
|
|
|
|
| 1 |
import unittest
|
| 2 |
+
from unittest.mock import patch
|
| 3 |
|
| 4 |
import openai_decisions as decisions
|
| 5 |
|
|
|
|
| 61 |
self.assertEqual(raised.exception.usage['input_tokens'], 123)
|
| 62 |
self.assertEqual(raised.exception.answers, response['answers'])
|
| 63 |
|
| 64 |
+
def test_choice_payload_preserves_instructions_and_two_options(self):
|
| 65 |
+
payload, checks = decisions.payload_for(self.pair, 'before', 'bug', self.pack,
|
| 66 |
+
decisions.CHOICE_PROTOCOL)
|
| 67 |
+
for sent, check in zip(payload['questions'], checks):
|
| 68 |
+
self.assertEqual(sent['type'], 'choice')
|
| 69 |
+
self.assertEqual(sent['instructions'], check['question']['instructions'])
|
| 70 |
+
self.assertEqual(sent['choices'], [
|
| 71 |
+
{'value': v, 'description': check['question']['criteria'][v]}
|
| 72 |
+
for v in ('true', 'false')])
|
| 73 |
+
lint, _ = decisions.payload_for(self.pair, 'before', 'lint', self.pack,
|
| 74 |
+
decisions.CHOICE_PROTOCOL)
|
| 75 |
+
self.assertEqual(lint['questions'][0]['choices'][1]['description'],
|
| 76 |
+
'Not so: ' + self.pair['rule']['ensure'])
|
| 77 |
+
check = {'name': 'plain', 'question': {'instructions': 'Is this safe?'}}
|
| 78 |
+
self.assertEqual(decisions.decision_question(check, decisions.CHOICE_PROTOCOL),
|
| 79 |
+
{'type': 'predicate', 'name': 'plain', 'instructions': 'Is this safe?'})
|
| 80 |
+
|
| 81 |
+
def test_choice_reads_true_option_not_selected_choice_or_confidence(self):
|
| 82 |
+
response = {'model': decisions.MODEL, 'usage': {'input_tokens': 101},
|
| 83 |
+
'answers': [{'type': 'choice', 'name': 'semantic', 'choice': 'false',
|
| 84 |
+
'confidence': .99, 'probabilities': [
|
| 85 |
+
{'value': 'false', 'probability': .9},
|
| 86 |
+
{'value': 'true', 'probability': .1}]}]}
|
| 87 |
+
row = decisions.prediction(self.pair, 'before', 'lint', self.pack, response,
|
| 88 |
+
.2, 'request', decisions.CHOICE_PROTOCOL)
|
| 89 |
+
self.assertAlmostEqual(row['score'], .9)
|
| 90 |
+
self.assertTrue(row['alert'])
|
| 91 |
+
self.assertEqual(row['true_probabilities'], {'semantic': .1})
|
| 92 |
+
self.assertEqual(row['protocol_id'], decisions.CHOICE_PROTOCOL)
|
| 93 |
+
response['answers'][0]['probabilities'][0]['value'] = 'true'
|
| 94 |
+
with self.assertRaises(decisions.AnswerError):
|
| 95 |
+
decisions.prediction(self.pair, 'before', 'lint', self.pack, response,
|
| 96 |
+
.2, 'request', decisions.CHOICE_PROTOCOL)
|
| 97 |
+
|
| 98 |
+
def test_mixed_choice_predicate_and_refusal_failure_counts(self):
|
| 99 |
+
checks = [
|
| 100 |
+
{'name': 'binary', 'question': {'instructions': 'Has a bug?',
|
| 101 |
+
'criteria': {'true': 'Bug', 'false': 'No bug'}}, 'type': 'noul', 'issue': {'on': True, 'type': 'defect'}},
|
| 102 |
+
{'name': 'plain', 'question': {'instructions': 'Has a bug?'}, 'type': 'noul', 'issue': {'on': True, 'type': 'defect'}}]
|
| 103 |
+
response = {'model': decisions.MODEL, 'usage': {'input_tokens': 111}, 'answers': [
|
| 104 |
+
{'type': 'predicate', 'name': 'plain', 'probability': .2},
|
| 105 |
+
{'type': 'choice', 'name': 'binary', 'probabilities': [
|
| 106 |
+
{'value': 'true', 'probability': .9}, {'value': 'false', 'probability': .1}]}]}
|
| 107 |
+
with patch.object(decisions, 'questions_for', return_value=checks):
|
| 108 |
+
row = decisions.prediction(self.pair, 'before', 'bug', self.pack, response,
|
| 109 |
+
.2, 'request', decisions.CHOICE_PROTOCOL)
|
| 110 |
+
self.assertTrue(row['alert'])
|
| 111 |
+
response['answers'][1] = {'name': 'binary', 'type': 'refusal'}
|
| 112 |
+
with self.assertRaises(decisions.AnswerError) as raised:
|
| 113 |
+
decisions.prediction(self.pair, 'after', 'bug', self.pack, response,
|
| 114 |
+
.2, 'request', decisions.CHOICE_PROTOCOL)
|
| 115 |
+
failure = {'error': str(raised.exception), 'answers': raised.exception.answers,
|
| 116 |
+
'usage': raised.exception.usage}
|
| 117 |
+
group = {'pairs': [self.pair], 'predictions': {},
|
| 118 |
+
'failures': {('repair', 'before'): failure, ('repair', 'after'): failure},
|
| 119 |
+
'domain': 'bug', 'split': 'public', 'digest': 'test'}
|
| 120 |
+
result = decisions.report(group, self.pack, decisions.CHOICE_PROTOCOL)
|
| 121 |
+
self.assertEqual(result['confusion'], {'tp': 0, 'fp': 1, 'fn': 1, 'tn': 0})
|
| 122 |
+
self.assertEqual(result['failure_counts_per_question'], {'binary': 2})
|
| 123 |
+
self.assertEqual(result['refused_methods'], 2)
|
| 124 |
+
|
| 125 |
|
| 126 |
if __name__ == '__main__':
|
| 127 |
unittest.main()
|
test_tradeoff.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
import tempfile
|
| 3 |
+
import unittest
|
| 4 |
+
import xml.etree.ElementTree as ET
|
| 5 |
+
|
| 6 |
+
import tradeoff
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class GraphTests(unittest.TestCase):
|
| 10 |
+
def test_equal_alert_rates_have_zero_margin_at_both_ends(self):
|
| 11 |
+
# Unequal class sizes prevent subtracting raw counts by mistake.
|
| 12 |
+
curves = {model: ([(0, 0), (2, 7), (20, 10)], 10, 20) for model in tradeoff.ORDER}
|
| 13 |
+
with tempfile.TemporaryDirectory() as temp:
|
| 14 |
+
output = Path(temp) / 'graph.svg'
|
| 15 |
+
tradeoff.svg('bug', curves, output)
|
| 16 |
+
root = ET.fromstring(output.read_text())
|
| 17 |
+
paths = root.findall('{http://www.w3.org/2000/svg}polyline')
|
| 18 |
+
self.assertEqual(len(paths), len(tradeoff.ORDER))
|
| 19 |
+
points = [tuple(map(float, point.split(','))) for point in paths[0].attrib['points'].split()]
|
| 20 |
+
self.assertEqual(points[0][1], points[2][1])
|
| 21 |
+
self.assertLess(points[1][1], points[0][1])
|
| 22 |
+
self.assertGreater(points[2][0], points[1][0])
|
| 23 |
+
labels = [e.text for e in root.findall('{http://www.w3.org/2000/svg}text')]
|
| 24 |
+
self.assertIn('100%', labels)
|
| 25 |
+
self.assertIn('Zero means issues and clean methods are flagged at equal rates.',
|
| 26 |
+
root.find('{http://www.w3.org/2000/svg}desc').text)
|
| 27 |
+
self.assertIn('Recall − false-positive rate (percentage points)', labels)
|
| 28 |
+
|
| 29 |
+
def test_negative_margins_remain_visible(self):
|
| 30 |
+
curves = {model: ([(0, 0), (10, 2), (20, 10)], 10, 20) for model in tradeoff.ORDER}
|
| 31 |
+
with tempfile.TemporaryDirectory() as temp:
|
| 32 |
+
output = Path(temp) / 'graph.svg'
|
| 33 |
+
tradeoff.svg('security', curves, output)
|
| 34 |
+
root = ET.fromstring(output.read_text())
|
| 35 |
+
path = root.find('{http://www.w3.org/2000/svg}polyline')
|
| 36 |
+
points = [tuple(map(float, point.split(','))) for point in path.attrib['points'].split()]
|
| 37 |
+
self.assertGreater(points[1][1], points[0][1])
|
| 38 |
+
self.assertLessEqual(points[1][1], 498)
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
if __name__ == '__main__':
|
| 42 |
+
unittest.main()
|
tradeoff.py
CHANGED
|
@@ -11,7 +11,7 @@ import argparse
|
|
| 11 |
from collections import defaultdict
|
| 12 |
import html
|
| 13 |
import json
|
| 14 |
-
from math import isfinite
|
| 15 |
from pathlib import Path
|
| 16 |
from tempfile import TemporaryDirectory
|
| 17 |
from urllib.request import urlopen
|
|
@@ -169,24 +169,29 @@ def svg(domain: str, curves: dict[str, tuple[list[tuple[int, int]], int, int]],
|
|
| 169 |
width, height = 1120, 580
|
| 170 |
left, right, top, bottom = 90, 40, 148, 82
|
| 171 |
plot_w, plot_h = width - left - right, height - top - bottom
|
| 172 |
-
#
|
|
|
|
| 173 |
x_max = 100
|
| 174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
def x(fp: int, negatives: int) -> float:
|
| 177 |
return left + (fp / negatives * 100) / x_max * plot_w
|
| 178 |
|
| 179 |
-
def y(
|
| 180 |
-
return top + (
|
| 181 |
|
| 182 |
title = {"bug": "Bug detection", "security": "Security detection", "lint": "Perch Lint Bench"}[domain]
|
| 183 |
out = [f'<svg xmlns="http://www.w3.org/2000/svg" width="{width}" height="{height}" viewBox="0 0 {width} {height}" role="img" aria-labelledby="title desc">',
|
| 184 |
-
f'<title id="title">{title}: recall
|
| 185 |
-
'<desc id="desc">
|
| 186 |
f'<rect width="{width}" height="{height}" rx="16" fill="#101318"/>',
|
| 187 |
f'<defs><clipPath id="plot"><rect x="{left}" y="{top}" width="{plot_w}" height="{plot_h}"/></clipPath></defs>',
|
| 188 |
f'<text x="{left}" y="43" fill="#f2f5fa" font-family="Arial,sans-serif" font-weight="700" font-size="28">{html.escape(title)}</text>',
|
| 189 |
-
f'<text x="{left}" y="70" fill="#aeb9c7" font-family="Arial,sans-serif" font-size="16">Public methods · recall
|
| 190 |
for i, model in enumerate(ORDER):
|
| 191 |
col = i % 4
|
| 192 |
row = i // 4
|
|
@@ -199,19 +204,20 @@ def svg(domain: str, curves: dict[str, tuple[list[tuple[int, int]], int, int]],
|
|
| 199 |
px = left + value / x_max * plot_w
|
| 200 |
out += [f'<line x1="{px:.1f}" y1="{top}" x2="{px:.1f}" y2="{top + plot_h}" stroke="#29303a"/>',
|
| 201 |
f'<text x="{px:.1f}" y="{top + plot_h + 25}" text-anchor="middle" fill="#aeb9c7" font-family="Arial,sans-serif" font-size="14">{value}%</text>']
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
py = top + (1 - (value / 100) / y_max) * plot_h
|
| 205 |
out += [f'<line x1="{left}" y1="{py:.1f}" x2="{left + plot_w}" y2="{py:.1f}" stroke="#29303a"/>',
|
| 206 |
-
f'<text x="{left - 12}" y="{py + 5:.1f}" text-anchor="end" fill="#aeb9c7" font-family="Arial,sans-serif" font-size="14">{value}
|
|
|
|
|
|
|
| 207 |
for model in ORDER:
|
| 208 |
points, positives, negatives = curves[model]
|
| 209 |
visible = [(fp, tp) for fp, tp in points if fp / negatives * 100 <= x_max]
|
| 210 |
if len(visible) > 1:
|
| 211 |
-
positions = " ".join(f"{x(fp, negatives):.2f},{y(tp
|
| 212 |
out.append(f'<polyline points="{positions}" fill="none" stroke="{COLORS[model]}" stroke-width="2.5" stroke-linejoin="round" stroke-linecap="round" clip-path="url(#plot)"/>')
|
| 213 |
out += [f'<text x="{left + plot_w / 2:.1f}" y="{height - 23}" text-anchor="middle" fill="#e1e7ef" font-family="Arial,sans-serif" font-size="17">Clean methods wrongly flagged →</text>',
|
| 214 |
-
f'<text transform="translate(23 {top + plot_h / 2:.1f}) rotate(-90)" text-anchor="middle" fill="#e1e7ef" font-family="Arial,sans-serif" font-size="
|
| 215 |
'</svg>']
|
| 216 |
output.parent.mkdir(parents=True, exist_ok=True)
|
| 217 |
output.write_text("\n".join(out) + "\n")
|
|
@@ -220,7 +226,7 @@ def svg(domain: str, curves: dict[str, tuple[list[tuple[int, int]], int, int]],
|
|
| 220 |
def render_sections(results: list[dict], curves_by_domain: dict[str, dict], output_dir: Path,
|
| 221 |
codeql_results: dict) -> str:
|
| 222 |
sections = ["## Reading the results", "",
|
| 223 |
-
"Each line shows
|
| 224 |
"The tables use each run's recorded alert settings. A value of 20% under ‘Clean methods wrongly flagged’ means one in five clean methods received an alert. Models are ranked by recall minus that percentage. Bold marks the best full-set value in each column; cost compares priced runs captured here.", ""]
|
| 225 |
if any(r.get("failed_methods") for r in results):
|
| 226 |
sections += ["Failed requests count as incorrect decisions: a failed issue is a miss; a failed clean method is a false positive. Failed cases receive no model score and remain incorrect across the plotted cutoffs.", ""]
|
|
@@ -243,7 +249,7 @@ def render_sections(results: list[dict], curves_by_domain: dict[str, dict], outp
|
|
| 243 |
image = output_dir / f"{domain}-tradeoff.svg"
|
| 244 |
svg(domain, curves_by_domain[domain], image)
|
| 245 |
sections += [f"## {title}", "", f"[Public pairs](https://huggingface.co/datasets/perchscan/{link})", "",
|
| 246 |
-
f"![{title} recall
|
| 247 |
f"### Public — {public[0]['benchmark_pairs']:,} pairs", "",
|
| 248 |
results_table(public), ""]
|
| 249 |
if domain in ("bug", "security"):
|
|
|
|
| 11 |
from collections import defaultdict
|
| 12 |
import html
|
| 13 |
import json
|
| 14 |
+
from math import ceil, floor, isfinite
|
| 15 |
from pathlib import Path
|
| 16 |
from tempfile import TemporaryDirectory
|
| 17 |
from urllib.request import urlopen
|
|
|
|
| 169 |
width, height = 1120, 580
|
| 170 |
left, right, top, bottom = 90, 40, 148, 82
|
| 171 |
plot_w, plot_h = width - left - right, height - top - bottom
|
| 172 |
+
# Subtract the diagonal so small ranking differences remain visible.
|
| 173 |
+
# Keep every cutoff and adapt only the vertical display range.
|
| 174 |
x_max = 100
|
| 175 |
+
step = 10 if domain == "lint" else 5
|
| 176 |
+
margins = [100 * (tp / positives - fp / negatives)
|
| 177 |
+
for points, positives, negatives in curves.values() for fp, tp in points]
|
| 178 |
+
y_min = min(-step, floor(min(margins) / step) * step)
|
| 179 |
+
y_max = max(step, ceil(max(margins) / step) * step)
|
| 180 |
|
| 181 |
def x(fp: int, negatives: int) -> float:
|
| 182 |
return left + (fp / negatives * 100) / x_max * plot_w
|
| 183 |
|
| 184 |
+
def y(margin: float) -> float:
|
| 185 |
+
return top + (y_max - margin) / (y_max - y_min) * plot_h
|
| 186 |
|
| 187 |
title = {"bug": "Bug detection", "security": "Security detection", "lint": "Perch Lint Bench"}[domain]
|
| 188 |
out = [f'<svg xmlns="http://www.w3.org/2000/svg" width="{width}" height="{height}" viewBox="0 0 {width} {height}" role="img" aria-labelledby="title desc">',
|
| 189 |
+
f'<title id="title">{title}: recall minus false-positive rate</title>',
|
| 190 |
+
'<desc id="desc">Public model curves across score cutoffs. The vertical axis subtracts the false-positive rate from recall. Zero means issues and clean methods are flagged at equal rates. Higher is better.</desc>',
|
| 191 |
f'<rect width="{width}" height="{height}" rx="16" fill="#101318"/>',
|
| 192 |
f'<defs><clipPath id="plot"><rect x="{left}" y="{top}" width="{plot_w}" height="{plot_h}"/></clipPath></defs>',
|
| 193 |
f'<text x="{left}" y="43" fill="#f2f5fa" font-family="Arial,sans-serif" font-weight="700" font-size="28">{html.escape(title)}</text>',
|
| 194 |
+
f'<text x="{left}" y="70" fill="#aeb9c7" font-family="Arial,sans-serif" font-size="16">Public methods · recall minus false-positive rate · higher is better</text>']
|
| 195 |
for i, model in enumerate(ORDER):
|
| 196 |
col = i % 4
|
| 197 |
row = i // 4
|
|
|
|
| 204 |
px = left + value / x_max * plot_w
|
| 205 |
out += [f'<line x1="{px:.1f}" y1="{top}" x2="{px:.1f}" y2="{top + plot_h}" stroke="#29303a"/>',
|
| 206 |
f'<text x="{px:.1f}" y="{top + plot_h + 25}" text-anchor="middle" fill="#aeb9c7" font-family="Arial,sans-serif" font-size="14">{value}%</text>']
|
| 207 |
+
for value in range(y_min, y_max + 1, step):
|
| 208 |
+
py = y(value)
|
|
|
|
| 209 |
out += [f'<line x1="{left}" y1="{py:.1f}" x2="{left + plot_w}" y2="{py:.1f}" stroke="#29303a"/>',
|
| 210 |
+
f'<text x="{left - 12}" y="{py + 5:.1f}" text-anchor="end" fill="#aeb9c7" font-family="Arial,sans-serif" font-size="14">{value}</text>']
|
| 211 |
+
zero_y = y(0)
|
| 212 |
+
out.append(f'<line x1="{left}" y1="{zero_y:.1f}" x2="{left + plot_w}" y2="{zero_y:.1f}" stroke="#aeb9c7" stroke-width="1.5" stroke-dasharray="5 5"/>')
|
| 213 |
for model in ORDER:
|
| 214 |
points, positives, negatives = curves[model]
|
| 215 |
visible = [(fp, tp) for fp, tp in points if fp / negatives * 100 <= x_max]
|
| 216 |
if len(visible) > 1:
|
| 217 |
+
positions = " ".join(f"{x(fp, negatives):.2f},{y(100 * (tp / positives - fp / negatives)):.2f}" for fp, tp in visible)
|
| 218 |
out.append(f'<polyline points="{positions}" fill="none" stroke="{COLORS[model]}" stroke-width="2.5" stroke-linejoin="round" stroke-linecap="round" clip-path="url(#plot)"/>')
|
| 219 |
out += [f'<text x="{left + plot_w / 2:.1f}" y="{height - 23}" text-anchor="middle" fill="#e1e7ef" font-family="Arial,sans-serif" font-size="17">Clean methods wrongly flagged →</text>',
|
| 220 |
+
f'<text transform="translate(23 {top + plot_h / 2:.1f}) rotate(-90)" text-anchor="middle" fill="#e1e7ef" font-family="Arial,sans-serif" font-size="14">Recall − false-positive rate (percentage points)</text>',
|
| 221 |
'</svg>']
|
| 222 |
output.parent.mkdir(parents=True, exist_ok=True)
|
| 223 |
output.write_text("\n".join(out) + "\n")
|
|
|
|
| 226 |
def render_sections(results: list[dict], curves_by_domain: dict[str, dict], output_dir: Path,
|
| 227 |
codeql_results: dict) -> str:
|
| 228 |
sections = ["## Reading the results", "",
|
| 229 |
+
"Each line shows recall minus the false-positive rate as the score cutoff changes. Higher is better; farther left means fewer clean methods flagged. The dashed zero line means issues and clean methods are flagged at equal rates.", "",
|
| 230 |
"The tables use each run's recorded alert settings. A value of 20% under ‘Clean methods wrongly flagged’ means one in five clean methods received an alert. Models are ranked by recall minus that percentage. Bold marks the best full-set value in each column; cost compares priced runs captured here.", ""]
|
| 231 |
if any(r.get("failed_methods") for r in results):
|
| 232 |
sections += ["Failed requests count as incorrect decisions: a failed issue is a miss; a failed clean method is a false positive. Failed cases receive no model score and remain incorrect across the plotted cutoffs.", ""]
|
|
|
|
| 249 |
image = output_dir / f"{domain}-tradeoff.svg"
|
| 250 |
svg(domain, curves_by_domain[domain], image)
|
| 251 |
sections += [f"## {title}", "", f"[Public pairs](https://huggingface.co/datasets/perchscan/{link})", "",
|
| 252 |
+
f"", "",
|
| 253 |
f"### Public — {public[0]['benchmark_pairs']:,} pairs", "",
|
| 254 |
results_table(public), ""]
|
| 255 |
if domain in ("bug", "security"):
|