A 32M-parameter classifier that reads one line of code, config, log or prose and scores whether the line holds a literal credential: a password, API key, access token, private-key header, connection string with a password, or an Authorization header value. It runs on a laptop CPU in about 4 ms per line, so you can score every line of a trace, log or diff before you share it.
Use it next to a rule-based scanner, not in place of one. On 1,264 human-written lines it finds about 4 in 5 credentials and is right about 9 times in 10 when it flags a line. It also misses about 1 credential in 5, so it must never be the only check before you publish a file.
pip install onnxruntime tokenizers numpy
python predict_onnx.py path/to/file.env # prints lines at or above the threshold
python predict_onnx.py path/to/file.env --all # prints every line with its score
predict_onnx.py applies the temperature (2.10) and threshold (0.74) in policy.json. Both were
fitted on human-written validation lines only. If you load the weights with transformers, apply
the same two numbers yourself; the raw softmax at 0.5 is not the calibrated decision.
import json, torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
repo = "zaindanaharper/credential-line-32m"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForSequenceClassification.from_pretrained(repo).eval()
policy = {"temperature": 2.0954, "threshold": 0.74}
enc = tok(['stripe.api_key = "sk_live_51Hx9QeLkdT3pZr8XyWvA0bc"'], return_tensors="pt", truncation=True, max_length=128)
p = torch.softmax(model(**enc).logits / policy["temperature"], -1)[0, 1].item()
print(p, p >= policy["threshold"])
Human-written holdout: 1,264 lines, 472 credentials, 159 source groups. Lines from 75 open-source repositories in the CredData benchmark (reviewed real code, with credential values scrambled) and from the Nosey Parker rule examples. No line, repository or rule file in this set was used for training or tuning. Intervals are 95% bootstrap intervals that resample whole repositories or rule files.
| System | Precision | Recall | F1 |
|---|---|---|---|
| credential-line-32m v2 | 0.916 [0.866, 0.958] | 0.807 [0.723, 0.884] | 0.858 [0.802, 0.907] |
| credential-line-32m v1 | 0.848 [0.782, 0.908] | 0.731 [0.650, 0.807] | 0.785 [0.728, 0.842] |
| Char n-gram logistic regression, same training data | 0.761 [0.686, 0.828] | 0.761 [0.679, 0.836] | 0.761 [0.704, 0.812] |
| Zero-shot Qwen2.5-Coder-14B | 0.593 [0.542, 0.648] | 0.998 [0.993, 1.000] | 0.744 [0.703, 0.786] |
| Rule catalog (Flywheel trace redaction, credential rules) | 0.656 [0.595, 0.723] | 0.593 [0.539, 0.656] | 0.623 [0.576, 0.678] |
| detect-secrets 1.5.0, default plugins | 0.704 [0.647, 0.756] | 0.398 [0.342, 0.451] | 0.509 [0.453, 0.554] |
| Rule catalog OR this model | 0.707 [0.653, 0.765] | 0.888 [0.852, 0.924] | 0.787 [0.745, 0.832] |
| Rule catalog AND this model | 0.968 [0.942, 0.992] | 0.513 [0.439, 0.592] | 0.670 [0.603, 0.738] |
Synthetic regression set (6,207 lines, from v1). F1 0.994 [0.991, 0.997]: 372 of 379 credentials in formats never generated for training, 775 of 782 in trained formats, 0 of 409 hard negatives flagged, 0 of 4,637 natural code lines flagged. This set is synthetic and was already inspected during v1, so read it as a regression check, not a measure of real-world accuracy.
Speed. ONNX fp32 on an Intel desktop CPU, 4 threads, tokenization included, on the holdout lines: 4.1 ms median and 7.5 ms 95th percentile per line at batch size 1 (500 lines); 219 lines per second at batch size 32. ONNX matches PyTorch within 2.5e-6 on all 1,264 holdout lines, with identical decisions at the threshold. The rule catalog takes 0.04 ms per line.
Calibration. Expected calibration error 0.037 and Brier score 0.072 on the holdout, after temperature scaling fitted on validation lines. v1 scored 0.140 and 0.142 on the same lines.
"thisismypassword", super$ecret, devpass), passwords inside
long connection strings, and keys whose only clue is the next line.$6$..., $2y$...), idempotency tokens, and random-looking host
names.training_code/v2/LABELING-v2.md). The file was hashed before
labeling and again before any system was scored. Raw agreement was 978 of 1,264, Cohen's kappa
0.55. All 286 disagreements, plus 23 lines where both labelers disagreed with the CredData
reviewers' own label, were adjudicated against the rule with a written reason per line.ABCDEFG,
0000, EXAMPLE) found 10 agreed labels that break the written rule; they were changed from
credential to clean (eval/post_scoring_label_corrections.tsv). The scan reads no model score.
The tables above use the corrected labels. On the labels frozen before scoring, the model scored
F1 0.855 [0.801, 0.905]; every system moved by 0.011 or less (eval/holdout_results_frozen_labels.json).87,707 training lines, 18,641 credentials. No real credential appears in the training data: every value CredData marks as a credential was replaced by a random string of the same shape, and every long random-looking token in every human-written line was replaced the same way.
eval/creddata_source_licenses.json; 306 of 337 repositories qualified). Reviewer labels were
mapped to this rule; 1,082 UUID lines and 58 salt or nonce lines the reviewers marked true were
relabeled clean, and 67 UUIDs in secret fields kept as credentials.training_code/v1).credentialsId; UUIDs as API key values;
private-key headers; public keys and END lines; CSRF tokens, nonces and salts; filler values.Base model: jhu-clsp/ettin-encoder-32m, MIT,
revision 1b8ba06455dd44f80fc9c1ca9e22806157a57379. Fine-tuned for 2 epochs (2,742 steps, batch
64, learning rate 5e-5, max length 128 tokens, seed 1729) in 57 seconds on one RTX 4090. A control
run with shuffled training labels scored F1 0.565 on the holdout, the score of flagging nearly
every line, so the evaluation does not reward a model that learned nothing.
MIT for the fine-tuned weights, predict_onnx.py and the training code (LICENSE). The base
encoder is MIT-licensed by the Johns Hopkins University Center for Language and Speech
Processing; its notice is in NOTICE.
training_code/v2 holds the data builders, labeling, training, calibration and evaluation
scripts; training_code/v1 holds the v1 pipeline they extend. Paths are relative to a working
directory that holds ext/ (the cloned sources at the commits in eval/data_hashes.txt and the
scripts), v1/ and v2/. The rule-catalog baseline and the holdout lines are not redistributed,
so a rebuild reproduces the method rather than the exact bytes.
| File | What it is |
|---|---|
model.safetensors, config.json |
Fine-tuned weights, 32,031,746 parameters |
tokenizer.json, tokenizer_config.json |
Tokenizer from the base model |
onnx/model.onnx |
fp32 ONNX export |
policy.json |
Temperature and threshold, fitted on human-written validation lines |
predict_onnx.py |
Command-line scorer, ONNX Runtime only |
eval/holdout_results.json |
Every holdout number in this card, per slice, with intervals |
eval/label_agreement.json |
Labeler agreement and kappa |
eval/onnx_parity_latency.json |
Parity and timing |
LICENSE, NOTICE |
MIT license and the base model's notice |
onnx/model.onnx 128 MBmodel.safetensors 128 MBjhu-clsp/ettin-encoder-32m