How to use from the
Use from the
Transformers.js library
// npm i @huggingface/transformers
import { pipeline } from '@huggingface/transformers';

// Allocate pipeline
const pipe = await pipeline('token-classification', 'Tamarillo/pii-secrets-guard-tiny-en');

Tamarillo/pii-secrets-guard-tiny-en (v2)

v2 Ultra-Fast Edge & Browser Tier (32M, EN + Code/Logs) — Apache-2.0, zero-trust_remote_code, long-context (7,999 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.464 (v1) -> 0.527 (v2) (ood_agent_pii_2026: 0.631 -> 0.764, ood_btx24_tr: 0.171 -> 0.274, ood_yalen_bias: 0.590 -> 0.543), powered by true Partial-Label Marginalized NER Loss (eliminating cross-dataset false-negative label conflicts) and our new open Apache-2.0 exact-span corpus Tamarillo/agent-pii-secrets-2026.
  • Stronger Agent Secret Detection & Clean Hard-Negative Precision: Lifts 21-class agent_secrets F1 from 0.886 -> 0.957 while holding clean-code/UUID/Git-SHA hard-negative doc FPR to 2.0% (0.7% on strictly OOD Phi-4-mini benign traces) and 98.6% needle recall at 5,000 tokens.
  • Interactive Browser Demos: Try locally via WebAssembly ONNX in Tamarillo/pii-secrets-guard-demo and Tamarillo/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-tiny-en"
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-tiny-en"
tokenizer = AutoTokenizer.from_pretrained(model_id)
id2label = AutoConfig.from_pretrained(model_id).id2label
onnx_path = hf_hub_download(model_id, "onnx/model_fp16.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)

(Recommended browser WASM tier: 61.3 MB FP16 ONNX with 1.0000 token agreement.)

import { pipeline } from "@huggingface/transformers";

const pii = await pipeline("token-classification", "Tamarillo/pii-secrets-guard-tiny-en", { dtype: "fp16" });
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

Strictly OOD 3-Suite & Hard-Negative 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 (330 multi-entity MCP/clinical/DevOps/multilingual traces + 137 benign hard negatives) generated with strictly disjoint MIT microsoft/Phi-4-mini-instruct (0% overlap with Qwen/Qwen3-8B train split or value pools) under Tamarillo's 21-class schema; OOD YalenLabs Bias and OOD BTX24 Turkish are fully independent third-party OOD benchmarks.
  • *Wismut/nym-pii-multilingual is trained on Wismut/nym-pii-multilingual-data (0.999 ID in Table 2).
  • †kalyan-ks/ettin-68m-nemotron-pii is trained on nvidia/Nemotron-PII; its lower 0.291 score under our unified strict IoU >=0.50 canonical 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 Turkish BTX24 and DE/FR/TR slices of OOD Agent-PII 2026) despite being English-only; use small or base for 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: base v2 (0.762) and distilled small v2 (0.750) beat Tamarillo v1 by +11.3 to +12.6 OOD-3 Mean F1 points and outperform piiranha-v1 (0.574) and wismut-nym-base (0.572) by +17.6 to +19.0 points. Even 32M English-only tiny-en v2 (0.527) outperforms 5.7× larger isotonic-deberta-v3 (0.447) and 9.6× larger vllm-sr-mmbert32k-pii (0.318).
    • Real-World Agent Secrets & 5K-Token Context: small v2 hits 0.983 F1 on agent_secrets (+9.4 over v1 small) and 0.914 F1 on strictly unseen Phi-4-mini agent traces (+23.1 over v1 small); all 3 v2 tiers achieve 99% / 99% / 99% long-context needle recall at 800 / 3,200 / 5,000 tokens (where piiranha, isotonic, wismut, and kalyan collapse to 0% at >=3.2K).
    • Clean Production False-Positive Rates: base v2 holds 0.2% template hard-negative FPR and 0.7% OOD Phi-4-mini hard-negative FPR (and small v2 cuts template hard-neg FPR 3× from 6.0% -> 2.0%), whereas isotonic (34.4%), kalyan (54.6%), wismut (56.0%), and vllm-sr (68.4%) trigger heavy false alarms on benign logs/UUIDs/SHAs.
  • Where baselines or v1 win (reported candidly):
    • On OOD YalenLabs Bias, wismut-nym-base (0.824) scores higher raw F1 than base v2 (0.789) and small v2 (0.732), though at the cost of a 56.0% hard-negative doc FPR (vs. 0.2%–2.0% for Tamarillo v2); on English-only tiny-en, ood_yalen_bias dipped -4.7 pts vs. v1 (0.590 -> 0.543) while ood_agent_pii_2026 (+13.3) and agent_secrets (+7.1) jumped substantially.
    • On in-distribution Gretel EN & Gretel Multi, v2 trades -2.4 to -7.7 pts vs. v1 because true partial-label training allows the model to predict entities (such as AUTH_TOKEN, GOVERNMENT_ID, or MEDICAL_ID) that Gretel's schema leaves unannotated — hurting strict Gretel-gold F1 while driving +11–13 point OOD gains.
    • On hard-negative template precision alone, piiranha-v1 achieves 0.0% template FPR (vs. 0.2% base v2 / 2.0% small/tiny-en), though on strictly OOD Phi-4-mini hard negatives all 3 Tamarillo v2 tiers (0.7%) beat piiranha-v1 (2.9%).

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. Gather-only INT8 quantization scored 0.9947 short token agreement (below our strict >=0.995 parity gate) and was intentionally withheld — only parity-verified FP32 (122.5 MB) and FP16 (61.3 MB, smaller than INT8!) graphs are shipped.

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 122.5 MB 1.0000 / 0.00001 (n=16) 1.0000 / 0.00000 (n=8) 9.1 ms 71.8 ms 216.1 ms 718.2 ms
FP16 ONNX onnx/model_fp16.onnx 61.3 MB 1.0000 / 0.00572 (n=16) 1.0000 / 0.00201 (n=8) 11.0 ms 81.2 ms 264.0 ms 915.8 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): 12.5 ms @ 64 tok, 12.7 ms @ 512 tok.


Training Summary & Data Provenance

  • Canonical Backbone: jhu-clsp/ettin-encoder-32m (32.0M parameters, MIT).
  • Training Corpus (128,116 documents, 133,119 tokenized windows; 100% commercially permissive Apache-2.0 / MIT / CC-BY-4.0 — strictly excludes all ai4privacy datasets):
    • Tamarillo/agent-pii-secrets-2026 (Apache-2.0, qwen3_train split via Qwen/Qwen3-8B exact-span placeholder injection; phi4_ood_test 100% held out).
    • nvidia/Nemotron-PII (CC-BY-4.0) and gretelai/gretel-pii-masking-en-v1 (Apache-2.0).
    • Deterministic split-isolated agent secrets, adversarial hard negatives, and span-preserving long-context concatenations (1K–4K tokens).
  • Objective & Selection: Trained with true Partial-Label Marginalized NER Loss (logsumexp over {O} U unannotated_entities per 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 base v2 when ultra-low 0.2% template hard-negative FPR and highest narrative bias F1 (0.789) matter most; choose small v2 for 2× faster CPU inference (24.9 ms) and top agent_secrets (0.983) / Turkish OOD (0.605) F1; choose tiny-en v2 for 61.3 MB browser WASM or ultra-low-latency (9.1 ms) English/code edge filtering.
  • Synthetic-data distribution: Training corpora and agent-pii-secrets-2026 are 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: tiny-en v2 is trained strictly for English text and developer code/logs (21 PII/PHI + secret classes); use Tamarillo/pii-secrets-guard-small or Tamarillo/pii-secrets-guard-base for non-English languages. 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 7,999 tokens must be chunked with stride overlap (e.g., stride=128) before aggregation.
Downloads last month
116
Safetensors
Model size
32M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Tamarillo/pii-secrets-guard-tiny-en

Quantized
(34)
this model

Datasets used to train Tamarillo/pii-secrets-guard-tiny-en

Spaces using Tamarillo/pii-secrets-guard-tiny-en 2

Collections including Tamarillo/pii-secrets-guard-tiny-en

Evaluation results

  • Typed Span F1 on Tamarillo/agent-pii-secrets-2026 (phi4_ood_test, OOD)
    self-reported
    0.764
  • Typed Span F1 on YalenLabs/yalen-pii-ner-bias-audit (OOD)
    self-reported
    0.543
  • Typed Span F1 on BTX24/turkish-privacy-pii-ner (OOD)
    self-reported
    0.274