Text Classification
Transformers
ONNX
Safetensors
roberta
code
cryptography
post-quantum
static-analysis
legacy
text-embeddings-inference
Instructions to use KRISHNAPURI/q-trust-codebert with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use KRISHNAPURI/q-trust-codebert with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="KRISHNAPURI/q-trust-codebert")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("KRISHNAPURI/q-trust-codebert") model = AutoModelForSequenceClassification.from_pretrained("KRISHNAPURI/q-trust-codebert", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Correct headline metrics to reproducible 0.9395 + successor pointer to v4 detector
Browse files
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.
|
| 31 |
-
| Training | 4 epochs, CUDA, `scripts/train_qtrust_all.py --real --hf-epochs
|
| 32 |
-
| Leakage audit | Split reproduced bit-identically; 0.4% cross-repo dupes, bounded below the
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|