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 v1 card: leakage audit, retired metric, v4 successor
Browse files
README.md
CHANGED
|
@@ -10,46 +10,56 @@ tags:
|
|
| 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 β
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|---|---|
|
| 30 |
-
|
|
| 31 |
-
|
|
| 32 |
-
|
|
| 33 |
-
|
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 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
|
|
@@ -57,21 +67,30 @@ clf("EVP_PKEY_assign_RSA(pkey, rsa);")
|
|
| 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 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
- cryptography
|
| 11 |
- post-quantum
|
| 12 |
- static-analysis
|
| 13 |
+
- legacy
|
| 14 |
widget:
|
| 15 |
- text: "cipher = Cipher.getInstance(\"AES/ECB/PKCS5Padding\"); // usage under review"
|
| 16 |
- text: "kem = OQS_KEM_ml_kem_768_new(); OQS_KEM_ml_kem_768_keypair(kem, pk, sk);"
|
| 17 |
---
|
| 18 |
|
| 19 |
+
# Q-Trust CodeBERT (v1 β legacy checkpoint)
|
| 20 |
|
| 21 |
+
> **Superseded.** This is the first Q-Trust crypto-usage classifier, kept for lineage and for
|
| 22 |
+
> reproducing earlier experiments. Its published held-out score came from a split that was later
|
| 23 |
+
> found to leak: the 2026-10-23 audit measured **87.6 % of its evaluation paths inside its own
|
| 24 |
+
> training data**. The weights are unchanged, but its F1 is **not a clean generalization estimate**
|
| 25 |
+
> and should not be quoted as one.
|
| 26 |
+
>
|
| 27 |
+
> Current model: [`KRISHNAPURI/q-trust-crypto-detector`](https://huggingface.co/KRISHNAPURI/q-trust-crypto-detector) β
|
| 28 |
+
> clean held-out **F1 0.9205** de-duplicated / **0.9235** native at the 0.50 gate, **0 % train/eval
|
| 29 |
+
> path overlap**. See [`EXPERIMENTS.md`](https://github.com/humoge7502/q-trust/blob/main/EXPERIMENTS.md)
|
| 30 |
+
> E-13 β E-17c for the audit, the retraining and the recorded negatives.
|
| 31 |
|
| 32 |
+
Binary code classifier that answers **"does this code use cryptography?"** β the discovery layer of
|
| 33 |
+
the Q-Trust post-quantum migration pipeline (`humoge7502/q-trust` on GitHub).
|
| 34 |
|
| 35 |
+
## What this checkpoint is
|
| 36 |
+
|
| 37 |
+
| | |
|
| 38 |
+
|---|---|
|
| 39 |
+
| Base | `huggingface/CodeBERTa-small-v1`, 2-label sequence classification |
|
| 40 |
+
| Training data | 12,462 real files (6,636 crypto-labelled) from 34 repositories |
|
| 41 |
+
| Input | source code, truncated to 256 tokens |
|
| 42 |
+
| Output | `LABEL_1` = crypto usage, `LABEL_0` = no crypto usage |
|
| 43 |
+
| Retained for | v1-vs-v4 head-to-head, GNN ranker and RL experiments that reference these exact weights |
|
| 44 |
+
|
| 45 |
+
## Corrected evaluation status
|
| 46 |
+
|
| 47 |
+
| | |
|
| 48 |
|---|---|
|
| 49 |
+
| Pre-audit held-out F1 | 0.9395 (leak-inflated: 87.6 % eval-path overlap) |
|
| 50 |
+
| Leakage audit | [`eval_leakage_audit`](https://github.com/humoge7502/q-trust/blob/main/EXPERIMENTS.md) β 2026-10-23 |
|
| 51 |
+
| Clean estimate for this checkpoint | none established β do not cite |
|
| 52 |
+
| Recommended successor | v4 detector, F1 0.9205 de-duplicated / 0.9235 native at gate 0.50, 0 % overlap |
|
| 53 |
+
|
| 54 |
+
The correction is enforced in the GitHub repository by `scripts/verify_metric_consistency.py`, so
|
| 55 |
+
the retired figure cannot drift back into current-facing documentation. This card keeps the
|
| 56 |
+
checkpoint unchanged: it is the canonical v1 artifact, not the current recommendation.
|
| 57 |
+
|
| 58 |
+
## Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
```python
|
| 61 |
from transformers import pipeline
|
| 62 |
+
|
| 63 |
clf = pipeline("text-classification", model="KRISHNAPURI/q-trust-codebert")
|
| 64 |
clf("EVP_PKEY_assign_RSA(pkey, rsa);")
|
| 65 |
# [{'label': 'LABEL_1', 'score': 0.99}] # LABEL_1 = crypto usage
|
|
|
|
| 67 |
|
| 68 |
```python
|
| 69 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 70 |
+
|
| 71 |
tok = AutoTokenizer.from_pretrained("KRISHNAPURI/q-trust-codebert")
|
| 72 |
model = AutoModelForSequenceClassification.from_pretrained("KRISHNAPURI/q-trust-codebert")
|
| 73 |
```
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
## Scope and limits
|
| 76 |
|
| 77 |
+
This model finds crypto **usage** (recall 0.877 on CryptoAPI-Bench files); it is not a misuse
|
| 78 |
+
detector and makes no SOTA claim. Labels are regex-derived weak labels, so the attainable score is
|
| 79 |
+
bounded by the labeler's error. It is not a vulnerability scanner and not a substitute for human
|
| 80 |
+
review.
|
| 81 |
+
|
| 82 |
+
Sibling artifacts in this repository, all reported at their measured values:
|
| 83 |
+
|
| 84 |
+
- **GNN ranker** β Ο-b 0.7168 vs 0.7210 for the doctrine heuristic: a tie.
|
| 85 |
+
- **RL migration agent** β likewise a tie with the heuristic.
|
| 86 |
+
- **Side-channel detector** β evaluated on 54 real trace sets.
|
| 87 |
+
|
| 88 |
+
`onnx/model_quantized.onnx` is the original int8 export used by the first browser demo. The current
|
| 89 |
+
[in-browser scanner](https://huggingface.co/spaces/KRISHNAPURI/q-trust-scanner) loads the v4 detector
|
| 90 |
+
instead.
|
| 91 |
+
|
| 92 |
+
## Provenance
|
| 93 |
+
|
| 94 |
+
- Training corpus: [`KRISHNAPURI/q-trust-datasets`](https://huggingface.co/datasets/KRISHNAPURI/q-trust-datasets)
|
| 95 |
+
- Metrics and audit trail: `reports/` in this repository and
|
| 96 |
+
[`humoge7502/q-trust`](https://github.com/humoge7502/q-trust)
|