Instructions to use Tamarillo/pii-secrets-guard-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Tamarillo/pii-secrets-guard-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="Tamarillo/pii-secrets-guard-base")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("Tamarillo/pii-secrets-guard-base") model = AutoModelForTokenClassification.from_pretrained("Tamarillo/pii-secrets-guard-base", device_map="auto") - Transformers.js
How to use Tamarillo/pii-secrets-guard-base with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('token-classification', 'Tamarillo/pii-secrets-guard-base'); - Notebooks
- Google Colab
- Kaggle
Tamarillo/pii-secrets-guard-base (v2)
v2 Flagship Multilingual & Ultra-Low-FPR Tier (308M, 22+ Languages, 8K) — Apache-2.0, zero-trust_remote_code, long-context (8,192 tokens) token classifier for AI agent runtime DLP, detecting 21 canonical PII, PHI, and developer/agent secret classes in a single forward pass.
What's new in v2:
- Massive Strictly-OOD Generalization Leap: Lifts Strictly OOD 3-Suite Mean F1 from
0.636(v1) ->0.762(v2) (ood_agent_pii_2026:0.701 -> 0.902,ood_btx24_tr:0.489 -> 0.594,ood_yalen_bias:0.719 -> 0.789), powered by true Partial-Label Marginalized NER Loss (eliminating cross-dataset false-negative label conflicts) and our new open Apache-2.0 exact-span corpusTamarillo/agent-pii-secrets-2026. - Stronger Agent Secret Detection & Clean Hard-Negative Precision: Lifts 21-class
agent_secretsF1 from0.937->0.957while holding clean-code/UUID/Git-SHA hard-negative doc FPR to0.2%(0.7%on strictly OOD Phi-4-mini benign traces) and99.3%needle recall at 5,000 tokens. - Interactive Browser Demos: Try locally via WebAssembly ONNX in
Tamarillo/pii-secrets-guard-demoandTamarillo/agent-guardrails-suite.
Quickstart (< 30 Seconds)
Requires pip install "transformers>=4.48" torch (standard AutoModelForTokenClassification, zero trust_remote_code; attn_implementation="eager" ensures exact numerical parity with our ONNX exports, while default SDPA/FlashAttention can be used on GPUs for higher throughput):
from transformers import AutoModelForTokenClassification, AutoTokenizer, pipeline
model_id = "Tamarillo/pii-secrets-guard-base"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForTokenClassification.from_pretrained(
model_id, attn_implementation="eager"
)
ner = pipeline("token-classification", model=model, tokenizer=tokenizer, aggregation_strategy="simple")
text = (
"Patient Elena Vargas (born March 14, 1984, MRN-402-88129) triggered alert with "
"OPENAI_API_KEY=sk-proj-AbCdEf1234567890GhIjKlMnOpQrStUvWxYz0123456789"
)
for ent in ner(text):
print(f"{ent['entity_group']:14s} | {ent['score']:.3f} | {ent['word']}")
ONNX Runtime (Zero-PyTorch CPU), Transformers.js (Browser WASM) & Microsoft Presidio Drop-In
ONNX Runtime (Python CPU/Edge)
import numpy as np
import onnxruntime as ort
from huggingface_hub import hf_hub_download
from transformers import AutoConfig, AutoTokenizer
model_id = "Tamarillo/pii-secrets-guard-base"
tokenizer = AutoTokenizer.from_pretrained(model_id)
id2label = AutoConfig.from_pretrained(model_id).id2label
onnx_path = hf_hub_download(model_id, "onnx/model_quantized.onnx")
session = ort.InferenceSession(onnx_path, providers=["CPUExecutionProvider"])
text = "Contact Elena Vargas at elena.vargas@acme-fin.io (key sk-proj-AbCdEf1234567890GhIjKlMnOpQrStUvWxYz0123456789)"
enc = tokenizer(text, return_offsets_mapping=True, truncation=True, max_length=2048, return_tensors="np")
logits = session.run(
["logits"],
{"input_ids": enc["input_ids"].astype(np.int64), "attention_mask": enc["attention_mask"].astype(np.int64)},
)[0][0]
preds = logits.argmax(axis=-1)
for pid, (s, e) in zip(preds, enc["offset_mapping"][0]):
lbl = id2label[int(pid)]
if lbl != "O" and e > s:
print(lbl, "->", repr(text[int(s):int(e)]))
Transformers.js (Browser / Node.js, @huggingface/transformers>=3.5.1)
(For lightweight browser WASM deployments, we recommend Tamarillo/pii-secrets-guard-tiny-en at 61.3 MB FP16; base is ideal for Node.js, Edge, or server-side ONNX Runtime.)
import { pipeline } from "@huggingface/transformers";
const pii = await pipeline("token-classification", "Tamarillo/pii-secrets-guard-base", { dtype: "q8" });
const hits = await pii("Contact Elena Vargas at elena.vargas@acme-fin.io", { ignore_labels: ["O"] });
console.log(hits);
Microsoft Presidio Entity Mapping
Supported 21 canonical classes: PERSON, EMAIL_ADDRESS, PHONE_NUMBER, STREET_ADDRESS, POSTAL_CODE, DATE_OF_BIRTH, SSN, GOVERNMENT_ID, PASSPORT, DRIVER_LICENSE, CREDIT_CARD, IBAN_CODE, BANK_ACCOUNT, MEDICAL_ID, USERNAME, IP_ADDRESS, PASSWORD, API_KEY, AUTH_TOKEN, DATABASE_URI, PRIVATE_KEY.
PRESIDIO_ENTITY_MAPPING = {
"PERSON": "PERSON",
"EMAIL_ADDRESS": "EMAIL_ADDRESS",
"PHONE_NUMBER": "PHONE_NUMBER",
"STREET_ADDRESS": "LOCATION",
"POSTAL_CODE": "LOCATION",
"DATE_OF_BIRTH": "DATE_TIME",
"SSN": "US_SSN",
"GOVERNMENT_ID": "ID",
"PASSPORT": "US_PASSPORT",
"DRIVER_LICENSE": "US_DRIVER_LICENSE",
"CREDIT_CARD": "CREDIT_CARD",
"IBAN_CODE": "IBAN_CODE",
"BANK_ACCOUNT": "US_BANK_NUMBER",
"MEDICAL_ID": "MEDICAL_LICENSE",
"USERNAME": "USERNAME",
"IP_ADDRESS": "IP_ADDRESS",
"PASSWORD": "PASSWORD",
"API_KEY": "API_KEY",
"AUTH_TOKEN": "AUTH_TOKEN",
"DATABASE_URI": "DATABASE_URI",
"PRIVATE_KEY": "PRIVATE_KEY"
}
(Full drop-in Presidio EntityRecognizer & LiteLLM CustomGuardrail adapters: github.com/duoi-bt/tamarillo-guardrails.)
Family Ladder (v2)
| Model | Backbone | Params | OOD-3 Mean F1 | OOD Agent-PII 2026 | Agent Secrets F1 | Hard-Neg FPR (Tmpl / OOD) ↓ | FP16 ONNX | Gather-INT8 ONNX (CPU @ 64 tok) |
|---|---|---|---|---|---|---|---|---|
Tamarillo/pii-secrets-guard-tiny-en |
jhu-clsp/ettin-encoder-32m |
32.0M | 0.527 | 0.764 | 0.957 | 2.0% / 0.7% | 61.3 MB | withheld |
Tamarillo/pii-secrets-guard-small |
jhu-clsp/mmBERT-small |
140.7M | 0.750 | 0.914 | 0.983 | 2.0% / 0.7% | 268.7 MB | 256.0 MB (24.9 ms) |
Tamarillo/pii-secrets-guard-base |
jhu-clsp/mmBERT-base |
307.6M | 0.762 | 0.902 | 0.957 | 0.2% / 0.7% | 587.1 MB | 611.5 MB (50.9 ms) |
Strictly OOD Pareto Frontier
Head-to-Head Evaluation (11 Models, Same NVIDIA A100-SXM4-40GB)
All 11 models (Tamarillo v2, Tamarillo v1, and 5 public open-weight baselines) were evaluated head-to-head on the exact same GPU and splits (limit=500 docs/suite, IoU >=0.50 typed span F1). Each baseline is scored fairly on its supported entity intersection (fair_shared_entities) so baselines are never penalized for entity classes they were not trained to detect. ModernBERT/mmBERT models ran with attn_implementation="eager".
Table 1: Strictly OOD Benchmarks, Hard-Negative False Positives & 5K-Token Needle Recall
(Zero rows from any Table 1 suite appear in Tamarillo v2 training or validation. Bold cells highlight this card's model tier.)
| Model | Params | Max Ctx | OOD Agent-PII 2026 (Phi-4, n=330) |
OOD YalenLabs Bias (n=500) |
OOD BTX24 Turkish (n=500) |
OOD-3 Mean F1 | Hard-Neg Doc FPR ↓ (n=500) |
OOD Phi-4 HN FPR ↓ (n=137) |
Long-Ctx Needle Recall (800 / 3.2K / 5K) |
|---|---|---|---|---|---|---|---|---|---|
| Tamarillo tiny-en v2 (EN) | 32.0M | 7,999 | 0.764 | 0.543 | 0.274 | 0.527 | 2.0% | 0.7% | 0.99 / 0.99 / 0.99 |
| Tamarillo small v2 | 140.7M | 8,192 | 0.914 | 0.732 | 0.605 | 0.750 | 2.0% | 0.7% | 0.99 / 0.99 / 0.99 |
| Tamarillo base v2 | 307.6M | 8,192 | 0.902 | 0.789 | 0.594 | 0.762 | 0.2% | 0.7% | 0.99 / 0.99 / 0.99 |
| Tamarillo tiny-en v1 (EN) | 32.0M | 7,999 | 0.631 | 0.590 | 0.171 | 0.464 | 1.8% | 0.7% | 0.97 / 0.97 / 0.97 |
| Tamarillo small v1 | 140.7M | 8,192 | 0.683 | 0.712 | 0.516 | 0.637 | 6.0% | 1.5% | 0.99 / 0.98 / 0.98 |
| Tamarillo base v1 | 307.6M | 8,192 | 0.701 | 0.719 | 0.489 | 0.636 | 0.2% | 0.7% | 0.99 / 0.99 / 0.99 |
iiiorg/piiranha-v1-detect-personal-information |
278.2M | 256 | 0.611 | 0.713 | 0.397 | 0.574 | 0.0% | 2.9% | 0.00 / 0.00 / 0.00 |
Isotonic/deberta-v3-base_finetuned_ai4privacy_v2 |
183.9M | 512 | 0.427 | 0.757 | 0.157 | 0.447 | 34.4% | 32.1% | 0.00 / 0.00 / 0.00 |
Wismut/nym-pii-multilingual* |
307.6M | 2,048 | 0.417 | 0.824 | 0.474 | 0.572 | 56.0% | 7.3% | 0.78 / 0.00 / 0.00 |
vllm-sr/mmbert32k-pii-detector-merged |
307.6M | 8,192 | 0.145 | 0.595 | 0.214 | 0.318 | 68.4% | 69.3% | 0.69 / 0.61 / 0.56 |
kalyan-ks/ettin-68m-nemotron-pii† |
68.5M | 2,048 | 0.164 | 0.501 | 0.050 | 0.238 | 54.6% | 0.7% | 0.50 / 0.00 / 0.00 |
Dataset-overlap & scope disclosures:
OOD Agent-PII 2026(Tamarillo/agent-pii-secrets-2026,phi4_ood_test): Cross-generator OOD benchmark (330multi-entity MCP/clinical/DevOps/multilingual traces +137benign hard negatives) generated with strictly disjoint MITmicrosoft/Phi-4-mini-instruct(0% overlap withQwen/Qwen3-8Btrain split or value pools) under Tamarillo's 21-class schema;OOD YalenLabs BiasandOOD BTX24 Turkishare fully independent third-party OOD benchmarks.- *
Wismut/nym-pii-multilingualis trained onWismut/nym-pii-multilingual-data(0.999ID in Table 2). - †
kalyan-ks/ettin-68m-nemotron-piiis trained onnvidia/Nemotron-PII; its lower0.291score under our unified strict IoU>=0.50canonical mapping reflects sensitivity to differing BIO boundary and fine-grained Nemotron label conventions. tiny-en(EN) is evaluated on the exact same multilingual Table 1 suites (including TurkishBTX24and DE/FR/TR slices ofOOD Agent-PII 2026) despite being English-only; usesmallorbasefor non-English workloads.
Table 2: Held-Out In-Distribution Benchmarks & A100 Latency (eager / native)
(Reported separately from Table 1; never mixed into the Strictly OOD Pareto chart. Note: Gretel Multi and Wismut Multi are multilingual and omitted from English-only tiny-en training.)
| Model | Params | Agent Secrets (n=500) |
Nemotron-PII EN (n=500) |
Gretel EN (n=500) |
Gretel Multi (n=500) |
Wismut Multi (n=500) |
A100 Latency (64 / 512 tok) |
|---|---|---|---|---|---|---|---|
| Tamarillo tiny-en v2 (EN) | 32.0M | 0.957 | 0.986 | 0.972 | 0.589 | 0.537 | 12.5 / 12.7 ms |
| Tamarillo small v2 | 140.7M | 0.983 | 0.973 | 0.949 | 0.800 | 0.988 | 26.6 / 26.7 ms |
| Tamarillo base v2 | 307.6M | 0.957 | 0.971 | 0.945 | 0.751 | 0.994 | 25.3 / 25.1 ms |
| Tamarillo tiny-en v1 (EN) | 32.0M | 0.886 | 0.972 | 0.973 | 0.625 | 0.504 | 11.8 / 12.3 ms |
| Tamarillo small v1 | 140.7M | 0.889 | 0.977 | 0.973 | 0.803 | 0.990 | 25.9 / 26.5 ms |
| Tamarillo base v1 | 307.6M | 0.937 | 0.984 | 0.974 | 0.828 | 0.991 | 25.4 / 25.8 ms |
iiiorg/piiranha-v1-detect-personal-information |
278.2M | 0.398 | 0.665 | 0.572 | 0.409 | 0.639 | 22.0 / 21.5 ms |
Isotonic/deberta-v3-base_finetuned_ai4privacy_v2 |
183.9M | 0.409 | 0.485 | 0.440 | 0.299 | 0.410 | 21.8 / 21.3 ms |
Wismut/nym-pii-multilingual* |
307.6M | 0.171 | 0.616 | 0.679 | 0.403 | 0.999 | 26.5 / 26.5 ms |
vllm-sr/mmbert32k-pii-detector-merged |
307.6M | 0.059 | 0.192 | 0.198 | 0.126 | 0.257 | 25.8 / 25.7 ms |
kalyan-ks/ettin-68m-nemotron-pii† |
68.5M | 0.082 | 0.291 | 0.173 | 0.332 | 0.181 | 22.9 / 23.6 ms |
Candid summary of wins & losses:
- Where Tamarillo v2 wins decisively:
- Strictly OOD Generalization:
basev2 (0.762) and distilledsmallv2 (0.750) beat Tamarillo v1 by+11.3to+12.6OOD-3 Mean F1 points and outperformpiiranha-v1(0.574) andwismut-nym-base(0.572) by+17.6to+19.0points. Even 32M English-onlytiny-env2 (0.527) outperforms 5.7× largerisotonic-deberta-v3(0.447) and 9.6× largervllm-sr-mmbert32k-pii(0.318). - Real-World Agent Secrets & 5K-Token Context:
smallv2 hits0.983F1 onagent_secrets(+9.4over v1small) and0.914F1 on strictly unseenPhi-4-miniagent traces (+23.1over v1small); all 3 v2 tiers achieve99% / 99% / 99%long-context needle recall at800 / 3,200 / 5,000tokens (wherepiiranha,isotonic,wismut, andkalyancollapse to0%at>=3.2K). - Clean Production False-Positive Rates:
basev2 holds0.2%template hard-negative FPR and0.7%OODPhi-4-minihard-negative FPR (andsmallv2 cuts template hard-neg FPR 3× from6.0% -> 2.0%), whereasisotonic(34.4%),kalyan(54.6%),wismut(56.0%), andvllm-sr(68.4%) trigger heavy false alarms on benign logs/UUIDs/SHAs.
- Strictly OOD Generalization:
- Where baselines or v1 win (reported candidly):
- On
OOD YalenLabs Bias,wismut-nym-base(0.824) scores higher raw F1 thanbasev2 (0.789) andsmallv2 (0.732), though at the cost of a56.0%hard-negative doc FPR (vs.0.2%–2.0%for Tamarillo v2); on English-onlytiny-en,ood_yalen_biasdipped-4.7pts vs. v1 (0.590 -> 0.543) whileood_agent_pii_2026(+13.3) andagent_secrets(+7.1) jumped substantially. - On in-distribution
Gretel EN&Gretel Multi, v2 trades-2.4to-7.7pts vs. v1 because true partial-label training allows the model to predict entities (such asAUTH_TOKEN,GOVERNMENT_ID, orMEDICAL_ID) that Gretel's schema leaves unannotated — hurting strict Gretel-gold F1 while driving+11–13point OOD gains. - On hard-negative template precision alone,
piiranha-v1achieves0.0%template FPR (vs.0.2%basev2 /2.0%small/tiny-en), though on strictly OODPhi-4-minihard negatives all 3 Tamarillo v2 tiers (0.7%) beatpiiranha-v1(2.9%).
- On
Parity-Verified ONNX Exports & Latency
Exported with onnx / onnxruntime and verified on both short (n=16) and 2,048-token (n=8) probes against PyTorch eager FP32. FP32, FP16, and Gather-only QUInt8 all passed our strict >=0.995 token-agreement and <=0.05 max probability-delta gate. Note: Gather-only QUInt8 quantizes only the large multilingual embedding table (256K vocab) while keeping transformer projection weights in FP32 for exact mmBERT logit fidelity, delivering 1.0000 agreement and fastest CPU latency.
| Artifact | File | Size | Short Parity (Token Agree / Max Δp) | 2,048-Tok Parity (Token Agree / Max Δp) | CPU 64 tok (p50) | CPU 512 tok (p50) | CPU 1,024 tok (p50) | CPU 2,048 tok (p50) |
|---|---|---|---|---|---|---|---|---|
| FP32 ONNX | onnx/model.onnx |
1173.8 MB | 1.0000 / 0.00001 (n=16) | 1.0000 / 0.00001 (n=8) | 53.5 ms | 403.3 ms | 1087.3 ms | 3305.7 ms |
| FP16 ONNX | onnx/model_fp16.onnx |
587.1 MB | 1.0000 / 0.00411 (n=16) | 1.0000 / 0.00885 (n=8) | 60.5 ms | 443.3 ms | 1304.0 ms | 4150.5 ms |
| Gather-INT8 ONNX | onnx/model_quantized.onnx |
611.5 MB | 1.0000 / 0.01852 (n=16) | 1.0000 / 0.00820 (n=8) | 50.9 ms | 401.6 ms | 1087.9 ms | 3317.1 ms |
Hardware disclosure: CPU latency measured with onnxruntime (4 intra-op threads, batch size 1) on GCP a2-highgpu-1g (Intel Xeon Cascade Lake @ 2.20 GHz). GPU latency measured on NVIDIA A100-SXM4-40GB (attn_implementation="eager", batch size 1): 25.3 ms @ 64 tok, 25.1 ms @ 512 tok.
Training Summary & Data Provenance
- Canonical Backbone:
jhu-clsp/mmBERT-base(307.6Mparameters,Apache-2.0). - Training Corpus (
174,869documents,181,921tokenized windows; 100% commercially permissive Apache-2.0 / MIT / CC-BY-4.0 — strictly excludes allai4privacydatasets):Tamarillo/agent-pii-secrets-2026(Apache-2.0,qwen3_trainsplit viaQwen/Qwen3-8Bexact-span placeholder injection;phi4_ood_test100% held out).nvidia/Nemotron-PII(CC-BY-4.0) andgretelai/gretel-pii-masking-en-v1(Apache-2.0).- Multilingual corpora:
nvidia/Nemotron-PII-Japan(CC-BY-4.0),gretelai/synthetic_pii_finance_multilingual(Apache-2.0), andWismut/nym-pii-multilingual-data(MIT). - Deterministic split-isolated agent secrets, adversarial hard negatives, and span-preserving long-context concatenations (
1K–4Ktokens).
- Objective & Selection: Trained with true Partial-Label Marginalized NER Loss (
logsumexpover{O} U unannotated_entitiesper source schema), hard-negative precision weighting (hn_weight=1.65), B-tag boundary weighting (1.15), and EMA (0.996). Checkpoints selected strictly on validation composite (0.60 * micro_f1 + 0.35 * macro_f1 - 0.10 * hardneg_doc_fpr). Reproducible scripts:github.com/duoi-bt/tamarillo-guardrails.
Limitations & Responsible Use
- Defense-in-depth, not a standalone compliance guarantee: Token classifiers are probabilistic and can miss novel credential formats, obfuscated PII, or heavily fragmented spans. Always combine neural DLP with deterministic checksum/regex validators (e.g., Luhn, IBAN mod-97, high-entropy secret scanners) and secret rotation policies.
- Tier selection guide: Choose
basev2 when ultra-low0.2%template hard-negative FPR and highest narrative bias F1 (0.789) matter most; choosesmallv2 for2×faster CPU inference (24.9 ms) and topagent_secrets(0.983) / Turkish OOD (0.605) F1; choosetiny-env2 for61.3 MBbrowser WASM or ultra-low-latency (9.1 ms) English/code edge filtering. - Synthetic-data distribution: Training corpora and
agent-pii-secrets-2026are synthetic (to guarantee zero real-human PII leakage under permissive licensing); validate recall and precision on a small domain-specific sample of your real production traces before enforcing hard blocks. - Language scope: Multilingual accuracy is strongest on high-resource Latin, Cyrillic, and CJK scripts represented in training and may degrade on underrepresented scripts. No per-language OOD breakdown is reported beyond English and Turkish (
BTX24); evaluate non-Latin scripts on your target domain before production rollout. - Non-PII exclusions: Generic dates (non-DOB), company names, countries, and generic URLs are intentionally excluded from the 21 canonical classes to prevent production over-redaction.
- Boundary & token-limit behavior: Inputs exceeding
8,192 tokensmust be chunked with stride overlap (e.g.,stride=128) before aggregation.
- Downloads last month
- 78
Model tree for Tamarillo/pii-secrets-guard-base
Base model
jhu-clsp/mmBERT-baseDatasets used to train Tamarillo/pii-secrets-guard-base
gretelai/gretel-pii-masking-en-v1
gretelai/synthetic_pii_finance_multilingual
Spaces using Tamarillo/pii-secrets-guard-base 2
Collection including Tamarillo/pii-secrets-guard-base
Evaluation results
- Typed Span F1 on Tamarillo/agent-pii-secrets-2026 (phi4_ood_test, OOD)self-reported0.902
- Typed Span F1 on YalenLabs/yalen-pii-ner-bias-audit (OOD)self-reported0.789
- Typed Span F1 on BTX24/turkish-privacy-pii-ner (OOD)self-reported0.594
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('token-classification', 'Tamarillo/pii-secrets-guard-base');