
Model Card for egemma-pii-secrets
A small model that finds secrets and personal data in text so they can be redacted, built to export agent transcripts safely for post-training. It's a fine-tune of the text half of google/embeddinggemma-2, runs locally (CPU, CUDA, Apple Metal), and is meant to be used together with its regex rules and a preview step before anything is shared.
Model Details
Model Description
egemma-pii-secrets is a token classifier: for every token it predicts one of 27 tags, either O (nothing) or the beginning B- or inside I- of 13 labels: PERSON, EMAIL, PHONE, ADDRESS, GOV_ID, FINANCIAL, DATE_OF_BIRTH, IP_ADDRESS, SENSITIVE, SECRET_TOKEN, SECRET_PASSWORD, SECRET_CONNECTION, and SECRET_PRIVATE_KEY.
Around the model, trace_rules.py adds regex rules for IPs, usernames in paths, credential fields, connection strings and database URLs, private keys and known key prefixes, a base64 decoder that checks encoded text for secrets, and a veto that never redacts provably public shapes (data URIs, public keys, digests).
- Base Model:
google/embeddinggemma-2by Google, Apache-2.0. Only the text half is used without the vision tower - Developed By: Ana (@okami.mom on bluesky) and my agent, bunny (Claude Opus 5.5 mainly)
- Model type: Token classification (span tagging) for redaction
- Language: English, with some French, German, Spanish, Italian, Dutch, and Swedish in the training data
- License: Apache-2.0
Training procedure (summary):
Fine-tuned from the base encoder in bf16 with AdamW (head learning rate 10× the encoder's), in three stages: a 0.6-epoch run from the base model (learning rate 1e-4, batch 32); a 0.4-epoch run (learning rate 2e-5) that adds a knowledge-distillation term, KL(teacher ‖ student), against the stage-one model so newly added data doesn't erase what it already learned; and a final 0.4-epoch run the same way with LLM-written look-alikes (secret-shaped strings that aren't secrets), the stage-two model as teacher.
Uses
Direct Use
Tagging personal data and secrets in text so they can be redacted before the text is shared, such as agent transcripts, tool outputs, logs, configs, support tickets, and chat. The model proposes spans so they will need further approval from either a person or a reviewer LLM. This model is meant to run locally and is small enough to run on a laptop CPU or GPU, or on Apple silicon with Metal.
Downstream Use
The tagging layer in albedo’s planned /trace export, which runs: rules → this model → an exact match on secrets the harness already knows → post-processing by a ZDR LLM or local model owned by the user → a preview the user approves. A planned screenshot redactor would run it over OCR text and re-render or box the flagged words.
Out-of-Scope Use
- An unattended guarantee: it misses some secrets and some PII (see Limitations). Don't publish its output without review.
- Compliance certification (GDPR, HIPAA, PCI). It can help a process; it is not one.
- Images, audio, or binary/encrypted/compressed data directly. Opaque base64 blobs are listed for review by the rules, not decoded by the model.
- Mostly non-English text.
- Searching other people's data for credentials to use. It's a detector for protecting your own data before you share it.
Bias, Risks, and Limitations
- Misses happen. Hardest cases: passwords written as ordinary words or phrases, very short test values (
"k"), secrets in unusual contexts, and sometimes half a name (in "Jane Doe" only "Jane" is tagged). A miss can be partial: only part of a token covered. Secret spans are widened to the whole token to limit this. - Over-redaction. It still flags some strings that only look secret: on the CredDetX test set, the model with the rules' veto wrongly flags 16% of labelled look-alikes (20% with the full rules, partly by design: placeholders in credential fields and database URLs are redacted by policy).
- Confidence scores aren't reliable for thresholding. Probabilities are bimodal and confidently wrong in both directions (CredDetX dev: 123 of 803 real secrets scored below 0.1, and 167 of 1,648 look-alikes at 0.99 or above; requiring 0.9 drops fully covered secrets from 630 to 552 while cutting flagged look-alikes from 503 to 305). Raising a threshold loses real secrets about as fast as it removes false flags.
- Long documents and forms are the weakest case. On RedactionBench (real forms, logs, files) the model alone fully covers 69% of mandatory spans. Most misses are 1–5 character fragments (IP octets and date parts, which the rules handle in practice), but names in unusual casing and short location details (state codes, apartment numbers) inside forms are real misses.
- Mostly synthetic training data. Much of the data is generated or LLM-written; real text can look different. Real-world performance should be checked on your own data.
- Language. English-centered; some French, German, Spanish, Italian, Dutch and Swedish.
- Policy choices are baked in. Placeholders in credential fields (
password: changeme) are treated as secrets; dates, ages, URLs without credentials, and customer/employee/device ids are not tagged; organizations are not tagged. - The rules are not in the weights. IP addresses, usernames in paths, the base64 decode step and the veto live in
trace_rules.py. Using the weights alone gives different (lower) results.
Recommendations
Use the model together with trace_rules.py, add exact-match redaction for any secrets your system already knows, and always show the user what will be shared before it is. Treat flagged spans as proposals.
How to Get Started with the Model
Use the code below to get started with the model.
# files: redact.py, trace_rules.py, labels.json, tokenizer/, encoder/, head.safetensors, onnx/tagger.int8.onnx
from redact import Redactor
r = Redactor() # picks CUDA/ROCm, then Apple Metal, then int8 ONNX on CPU; or Redactor(backend="onnx")
clean, spans = r.redact('export OPENAI_API_KEY="sk-proj-..." # ask Priya Natarajan (priya@corp.example)')
print(clean) # export OPENAI_API_KEY="[secret_token]" # ask [person] ([email])
for s in spans:
print(s["start"], s["end"], s["label"])
Show people the redacted text before it's shared; treat the spans as proposals.
Training Details
Training Data
No private data or user transcripts are in the released weights.
| source | license | what it contributed |
|---|---|---|
| nvidia/Nemotron-PII | CC-BY-4.0 | PII spans in many document types |
| gretelai/gretel-pii-masking-en-v1 | Apache-2.0 | PII (offsets recovered by exact match) |
| gretelai/synthetic_pii_finance_multilingual | Apache-2.0 | PII in long financial documents, several languages |
| urchade/synthetic-pii-ner-mistral-v1 | Apache-2.0 | PII in short texts |
| ildpil/text-anonymization-benchmark (TAB) | MIT | direct identifiers in ECHR rulings (names, codes); other mentions ignored |
| beki/privy | MIT | PII inside JSON, SQL, HTML and XML payloads |
| apartejs/aparte-secrets-data | ODC-BY | secrets in chat, configs, HTTP and JSON; secret labels only |
| nyuuzyou/gliner2.5-PII-code-en-data (training splits) | CC0 / CC-BY | PII and secrets in code |
| gitleaks rule set | MIT | provider token formats used to generate realistic keys (183 providers; 28 held back for testing) |
| our generators (Ana & bunny), in nekomimi-llc/egemma-pii-secrets-synthetic | CC0-1.0 | connection strings, national IDs, IBANs, phones in CSV/JSON/logs, placeholder names, look-alikes (hashes, ids, data URIs, public keys) |
| LLM-written examples (Ana & bunny), in nekomimi-llc/egemma-pii-secrets-synthetic | CC0-1.0 | Claude Haiku: secrets hidden in casual context; Claude Haiku + GPT-6-luna: look-alikes written from shape descriptions, checked by Claude Sonnet |
Changes to the training data
We mapped every source's labels to our 13 labels (some fine labels dropped by policy: dates, ages, URLs, customer/employee/device ids, organizations), recovered character offsets by exact match where a source gave only strings, sampled subsets, and removed any text that also appears in a test set. Nothing was re-published from these sources; please get them from their authors.
Benchmarks and evaluation data
Thanks to the authors of the sets we evaluated and selected checkpoints on. None of the splits listed here was trained on (for gretel, gretel finance, privy and gliner, we trained only on their separate training splits, listed above).
| set | license | how we used it |
|---|---|---|
| CobuildX-AI/CredDetX | CC-BY-4.0 | test split: frozen secrets test, run once; dev split: development |
| apartejs/aparte-secrets-gold | ODC-BY | chat-fresh and gold: frozen secrets tests |
| nyuuzyou/gliner2.5-PII-code-en-data | CC0 / CC-BY | code benchmark split: frozen test |
| RedactionBench/RedactionBench | CC-BY-4.0 | frozen PII test |
| nutrientdocs/DocPII-redaction-benchmark | MIT | frozen PII test (offsets recovered by exact match) |
| ildpil/text-anonymization-benchmark | MIT | TAB test + dev splits: frozen PII test |
| gretelai/gretel-pii-masking-en-v1, gretelai/synthetic_pii_finance_multilingual, beki/privy | Apache-2.0 / Apache-2.0 / MIT | their test splits: in-distribution PII tests |
| sinceaihq/safeprompt-bench | CC-BY-4.0 | checkpoint selection (one half) and reporting (other half) during development |
Training Procedure
Preprocessing
Every source is mapped to the 13 labels. Fine labels we chose not to tag (dates, ages, URLs, customer/employee/device ids) become "nothing". Sources that only label secrets (aparte, LLM-written rows) don't teach "not PII" on their untagged tokens: those tokens are only taught "not a secret", so names in them aren't learned as harmless. Everything is deduplicated by text hash against every test set.
Training Hyperparameters
- Training regime: bf16 mixed precision
- AdamW (fused), weight decay 0.01, encoder learning rate 1e-4 (stage 1) / 2e-5 (later stages), head 10× the encoder's
- 5% linear warmup, then linear decay; gradient clipping at 1.0
- Batch 32 windows of 512 tokens (stride 128); token-embedding table frozen
- Later stages add KL(teacher ‖ student) with weight 1.0, the previous stage as teacher
Speeds, Sizes, Times
About 230 windows/s on one RTX PRO 6000 Blackwell (~15 minutes per stage). Encoder ~1.1 GB in fp32, ~520 MB in fp16. On an Apple M4 (Mac mini), with the rules: ~9.0 KB of text per second with Metal fp16, ~6.2 KB/s on CPU in fp32 PyTorch, ~5.6 KB/s with the int8 ONNX model on CPU. Metal fp16 gives exactly the fp32 spans; int8 matches fp32 on 96.8% of test rows (1 of 149 held-out secrets lost). int8 ONNX is 273 MB and needs no PyTorch; on an M4 it is not faster than PyTorch on CPU.
Evaluation
Results (frozen tests, each run once)
None of these sets was used for training, checkpoint selection or tuning. Test texts were removed from training by hash. "Fully covered" means every character of a gold span is redacted; a partial hit counts as a miss.
Secrets
| test set | n secrets | model + veto | model + rules + veto | look-alikes wrongly flagged (model+veto / +rules) |
|---|---|---|---|---|
| CredDetX test (7,176 labelled look-alikes) | 3,213 | 87.8% | 97.8% | 16.2% / 20.4% |
| aparte chat-fresh (written after the set's own cutoff) | 396 | 98.2% | 98.2% | not labelled |
| aparte gold | 756 | 98.3% | 98.4% | not labelled |
| gliner code benchmark | 462 | 100% | 100% | not labelled |
Part of the flags on CredDetX are deliberate: placeholders and obviously-fake keys in credential fields, and database URLs without passwords, are redacted by policy but labelled as look-alikes there.
PII (model alone, gold spans fully covered)
| test set | n spans | fully covered |
|---|---|---|
| gretel-pii-masking test | 17,190 | 99.1% |
| privy test | 2,271 | 99.5% |
| TAB (ECHR rulings) test | 2,752 | 97.3% |
| gretel finance multilingual test | 15,410 | 91.1% |
| DocPII | 8,693 | 80.1% |
| RedactionBench, mandatory spans | 16,993 | 68.5% |
| RedactionBench, contextual spans | 36,293 | 32.8% |
gretel, privy, TAB and gfin test splits come from the same sources as training data (in-distribution). RedactionBench and DocPII are out-of-distribution; RedactionBench (real forms with fine-grained spans) is the weakest and the best guide to unfamiliar documents. These PII numbers are the model alone; IPs and usernames in /trace come from rules.
Environmental Impact
- Hardware Type: NVIDIA RTX 5070 (local), NVIDIA RTX PRO 6000 Blackwell (Google Colab G4)
- Hours used: RTX 5070: ~13 h of training (from the training logs) plus an estimated ~4 h of evaluation; RTX PRO 6000: ~2.6 h
- Cloud Provider: Google Colab for the RTX PRO 6000; the RTX 5070 is a home machine on Dominion Energy's grid (Virginia)
- Compute Region: Colab runtimes in US East, the Netherlands and Singapore; local in Virginia, USA
- Carbon Emitted: about 1.3–1.9 kg CO₂e in total, roughly a 3–5 mile drive in a gasoline car. Local: ~4–6 kWh × 0.27 kg CO₂e/kWh (EPA eGRID 2023, SERC Virginia/Carolina) ≈ 1–1.6 kg. Colab: ≈ 0.33 kg (ML CO₂ Impact calculator, scaled to hours and measured power). Emissions only; provider offsets not subtracted.
Technical Specifications
Model Architecture and Objective
- Encoder: the text encoder of
google/embeddinggemma-2, 24 transformer layers (sliding-window and full attention), ~271M parameters, hidden size 512 projected to 768. The 134M-parameter token-embedding table is kept frozen in training; the vision tower isn't used. - Head: one linear layer (768→27) applied to every token's output vector; the highest of the 27 scores is the token's tag (
O, orB-/I-of 13 labels). ConsecutiveB-andI-tags are joined into character spans, and secret spans are widened to the whole token around them. - Input handling: text is split into chunks of 512 tokens that overlap by 128 tokens, so a span on a window edge is seen whole by the next window.
- Objective: per-token cross-entropy over the 27 tags. For sources that only label secrets, untagged tokens are trained only toward "not a secret" (a marginal loss over all non-secret tags) rather than toward
O. Later stages add KL(teacher ‖ student) with weight 1.0, the previous stage as teacher.
Compute Infrastructure
Main training stages on Google Colab (one NVIDIA RTX PRO 6000 Blackwell, 96 GB, ~15 minutes per stage). Earlier experimental runs, the stages that used private data, and all evaluation on a home machine with an NVIDIA RTX 5070 (12 GB) and RTX 4060 (8 GB).
Hardware
For inference: about 1.1 GB of weights in fp32, ~540 MB in fp16, and a 273 MB int8 ONNX file for CPU. Runs on a laptop CPU (int8 ONNX), NVIDIA GPUs (CUDA), AMD GPUs (PyTorch ROCm builds, untested) and Apple silicon (Metal). Speeds are under Speeds, Sizes, Times.
Software
- Training: PyTorch 2.11 (CUDA 12.8) locally and 2.14 (CUDA 13.0) on Colab, Hugging Face Transformers 5.20.1, safetensors.
- Inference: Transformers with EmbeddingGemma 2 support (5.20.1 or newer) and PyTorch, or onnxruntime for the int8 CPU model;
redact.pypicks CUDA/ROCm, then Metal, then int8 ONNX on CPU. - Rules:
trace_rules.pyuses only the Python standard library.
Contact
Ana — ana@nekomimi.pet