KRISHNAPURI commited on
Commit
f9190c3
·
verified ·
1 Parent(s): 1e8124f

Correct headline metrics to reproducible 0.9395 + successor pointer to v4 detector

Browse files
Files changed (1) hide show
  1. README.md +77 -62
README.md CHANGED
@@ -1,62 +1,77 @@
1
- ---
2
- license: mit
3
- library_name: transformers
4
- pipeline_tag: text-classification
5
- datasets:
6
- - KRISHNAPURI/q-trust-datasets
7
- base_model: huggingface/CodeBERTa-small-v1
8
- tags:
9
- - code
10
- - cryptography
11
- - post-quantum
12
- - static-analysis
13
- widget:
14
- - text: "cipher = Cipher.getInstance(\"AES/ECB/PKCS5Padding\"); // usage under review"
15
- - text: "kem = OQS_KEM_ml_kem_768_new(); OQS_KEM_ml_kem_768_keypair(kem, pk, sk);"
16
- ---
17
-
18
- # Q-Trust CodeBERT — crypto-usage discovery classifier
19
-
20
- Binary code classifier that answers **"does this code use cryptography, and which
21
- primitive?"** — the discovery layer of the Q-Trust post-quantum migration
22
- project (`humoge7502/q-trust` on GitHub). Fine-tuned from
23
- `huggingface/CodeBERTa-small-v1` on 12,462 real files (6,636 crypto-labeled,
24
- 34 repos, deterministic seed-42 split, repo-disjoint held-out set).
25
-
26
- ## Measured results (never estimated)
27
-
28
- | Metric | Value |
29
- |---|---|
30
- | Precision / Recall / F1 | 0.952 / 0.953 / **0.9525** (n=2,415) |
31
- | Training | 4 epochs, CUDA, `scripts/train_qtrust_all.py --real --hf-epochs 3` |
32
- | Leakage audit | Split reproduced bit-identically; 0.4% cross-repo dupes, bounded below the +0.11 F1 gain |
33
-
34
- Try it in the widget above, or in code:
35
-
36
- ```python
37
- from transformers import pipeline
38
- clf = pipeline("text-classification", model="KRISHNAPURI/q-trust-codebert")
39
- clf("EVP_PKEY_assign_RSA(pkey, rsa);")
40
- # [{'label': 'LABEL_1', 'score': 0.99}] # LABEL_1 = crypto usage
41
- ```
42
-
43
- ```python
44
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
45
- tok = AutoTokenizer.from_pretrained("KRISHNAPURI/q-trust-codebert")
46
- model = AutoModelForSequenceClassification.from_pretrained("KRISHNAPURI/q-trust-codebert")
47
- ```
48
-
49
- Training data: [`KRISHNAPURI/q-trust-datasets`](https://huggingface.co/datasets/KRISHNAPURI/q-trust-datasets)
50
- (`qtrust_ai/artifacts/real_datasets/code_corpus.json`). Full lineage
51
- (config + seed + metrics): `reports/training_report_real.json` in
52
- [`KRISHNAPURI/q-trust-codebert`](https://huggingface.co/KRISHNAPURI/q-trust-codebert)
53
- sibling files, and `qtrust_ai/artifacts/benchmark_comparison.json` in the
54
- GitHub repo.
55
-
56
- ## Scope and limits
57
-
58
- This model finds crypto **usage** (recall 0.877 on CryptoAPI-Bench files); it is
59
- not a misuse detector and makes no SOTA claim. Sibling artifacts in this repo:
60
- GNN ranker (honest tie with the heuristic, τ-b 0.7168 vs 0.7210), RL agent
61
- (tie), side-channel detector (54 real trace sets). See `REPORTS` and the
62
- per-artifact notes in the repo card below.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: transformers
4
+ pipeline_tag: text-classification
5
+ datasets:
6
+ - KRISHNAPURI/q-trust-datasets
7
+ base_model: huggingface/CodeBERTa-small-v1
8
+ tags:
9
+ - code
10
+ - cryptography
11
+ - post-quantum
12
+ - static-analysis
13
+ widget:
14
+ - text: "cipher = Cipher.getInstance(\"AES/ECB/PKCS5Padding\"); // usage under review"
15
+ - text: "kem = OQS_KEM_ml_kem_768_new(); OQS_KEM_ml_kem_768_keypair(kem, pk, sk);"
16
+ ---
17
+
18
+ # Q-Trust CodeBERT — crypto-usage discovery classifier
19
+
20
+ Binary code classifier that answers **"does this code use cryptography, and which
21
+ primitive?"** — the discovery layer of the Q-Trust post-quantum migration
22
+ project (`humoge7502/q-trust` on GitHub). Fine-tuned from
23
+ `huggingface/CodeBERTa-small-v1` on 12,462 real files (6,636 crypto-labeled,
24
+ 34 repos, deterministic seed-42 split, repo-disjoint held-out set).
25
+
26
+ ## Measured results (never estimated)
27
+
28
+ | Metric | Value |
29
+ |---|---|
30
+ | Precision / Recall / F1 | 0.9279 / 0.9514 / **0.9395** (n=2,415, corrected) |
31
+ | Training | 4 epochs, CUDA, `scripts/train_qtrust_all.py --real --hf-epochs 4` |
32
+ | Leakage audit | Split reproduced bit-identically; 0.4% cross-repo dupes, bounded well below the claimed gain |
33
+ | Calibration | Temperature T=1.2142, ECE 0.1557 → 0.1387 cross-fitted (`artifacts/calibration.json` in the GitHub repo) |
34
+
35
+ > **Metric correction (2026-10-23):** the originally published 0.9525 was never
36
+ > reproducible — no threshold on these weights reaches it (best operating point
37
+ > 0.9434 at τ = 0.67). The corrected held-out F1 is **0.9395**; the same
38
+ > correction is applied across the GitHub repo's docs and is enforced there by
39
+ > a CI metric-consistency gate. This card keeps the checkpoint unchanged — it
40
+ > is the canonical v1 model.
41
+
42
+ > **Successor:** [`KRISHNAPURI/q-trust-crypto-detector`](https://huggingface.co/KRISHNAPURI/q-trust-crypto-detector)
43
+ > (v4: larger corpus, dedup-corrected held-out F1 0.9039 with a leakage-audited
44
+ > repo-disjoint digest split) — with the honest caveat that no clean cross-model
45
+ > v1-vs-v4 comparison exists (v1 trained on v4's eval files); see the GitHub
46
+ > repo's EXPERIMENTS.md E-13/E-14/E-15 for the full program, including the
47
+ > recorded negatives.
48
+
49
+ Try it in the widget above, or in code:
50
+
51
+ ```python
52
+ from transformers import pipeline
53
+ clf = pipeline("text-classification", model="KRISHNAPURI/q-trust-codebert")
54
+ clf("EVP_PKEY_assign_RSA(pkey, rsa);")
55
+ # [{'label': 'LABEL_1', 'score': 0.99}] # LABEL_1 = crypto usage
56
+ ```
57
+
58
+ ```python
59
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
60
+ tok = AutoTokenizer.from_pretrained("KRISHNAPURI/q-trust-codebert")
61
+ model = AutoModelForSequenceClassification.from_pretrained("KRISHNAPURI/q-trust-codebert")
62
+ ```
63
+
64
+ Training data: [`KRISHNAPURI/q-trust-datasets`](https://huggingface.co/datasets/KRISHNAPURI/q-trust-datasets)
65
+ (`qtrust_ai/artifacts/real_datasets/code_corpus.json`). Full lineage
66
+ (config + seed + metrics): `reports/training_report_real.json` in
67
+ [`KRISHNAPURI/q-trust-codebert`](https://huggingface.co/KRISHNAPURI/q-trust-codebert)
68
+ sibling files, and `qtrust_ai/artifacts/benchmark_comparison.json` in the
69
+ GitHub repo.
70
+
71
+ ## Scope and limits
72
+
73
+ This model finds crypto **usage** (recall 0.877 on CryptoAPI-Bench files); it is
74
+ not a misuse detector and makes no SOTA claim. Sibling artifacts in this repo:
75
+ GNN ranker (honest tie with the heuristic, τ-b 0.7168 vs 0.7210), RL agent
76
+ (tie), side-channel detector (54 real trace sets). See `REPORTS` and the
77
+ per-artifact notes in the repo card below.