Tamarillo PII & Secrets Guard — Small (140M, Multilingual 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.

Built by Tamarillo as a commercially clean drop-in alternative to non-commercial (CC-BY-NC-*) or 512-token-capped PII models. Trained exclusively on commercially permissive datasets (zero ai4privacy data) with explicit hard-negative calibration and long-context windowing.

Model Summary

Property Value
Base Model jhu-clsp/mmBERT-small
Architecture ModernBertForTokenClassification (no trust_remote_code)
Parameters 140M
Max Context Length 8,192 tokens
Languages Multilingual (22+ languages across 6 scripts) + Code / Logs
Entity Classes 21 canonical classes (43 standard BIO labels)
CPU ONNX Latency 21.5 ms p50 (INT8 ONNX) / 27.2 ms (FP32 ONNX, CPU, batch=1, ~55-tok input)
License Apache-2.0 (100% commercially permissive training lineage)

Supported Entity Classes (21)

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

Generic non-PII attributes (date, time, country, gender, occupation, language, generic url) are intentionally excluded to avoid production over-redaction.

Available Runtime Artifacts

  • model.safetensors — native PyTorch (transformers >= 4.48.0)
  • onnx/model.onnx — FP32 (537.07 MB, CPU p50 27.15 ms, 2,048-tok token agreement vs. PyTorch: 1.0)
  • onnx/model_fp16.onnx — FP16 (268.95 MB, CPU p50 24.61 ms, 2,048-tok token agreement vs. PyTorch: 1.0)
  • onnx/model_quantized.onnx — Per-channel dynamic INT8 (417.16 MB, CPU p50 21.5 ms, 2,048-tok token agreement vs. PyTorch: 1.0)
  • onnx/parity_report.json — verified PyTorch-vs-ONNX logit diff and token-agreement report
  • scripts/eval_suite.py, scripts/taxonomy.py, scripts/synth_secrets.py, scripts/data_builder.py, scripts/train.py — reproducible data, training & evaluation scripts

Quick Start (transformers)

pip install "transformers>=4.48.0" torch safetensors
from transformers import pipeline

scanner = pipeline(
    "token-classification",
    model="Tamarillo/pii-secrets-guard-small",
    aggregation_strategy="simple",
)

text = (
    "Patient Elena Vargas (elena.vargas@acme-fin.io, DOB 1988-04-12). "
    "OPENAI_API_KEY=sk-proj-AbCdEf1234567890GhIjKlMnOpQrStUvWxYz0123456789"
)
for ent in scanner(text):
    print(ent["entity_group"], repr(ent["word"]), round(ent["score"], 3))
# Expected output:
# PERSON ' Elena Vargas' 0.99...
# EMAIL_ADDRESS ' elena.vargas@acme-fin.io' 0.99...
# DATE_OF_BIRTH ' 1988-04-12' 0.99...
# API_KEY 'sk-proj-AbCdEf1234567890GhIjKlMnOpQrStUvWxYz0123456789' 0.99...

Drop-In Integration: Microsoft Presidio

Verified live with presidio-analyzer >= 2.2.354 and en_core_web_sm:

pip install "transformers>=4.48.0" presidio-analyzer spacy
python -m spacy download en_core_web_sm
from presidio_analyzer import AnalyzerEngine
from presidio_analyzer.nlp_engine import NlpEngineProvider

nlp_config = {
    "nlp_engine_name": "transformers",
    "models": [
        {
            "lang_code": "en",
            "model_name": {"spacy": "en_core_web_sm", "transformers": "Tamarillo/pii-secrets-guard-small"},
        }
    ],
    "ner_model_configuration": {
        "model_to_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"
        },
        "low_confidence_score_multiplier": 0.4,
        "low_score_entity_names": [],
        "labels_to_ignore": ["O"],
    },
}
analyzer = AnalyzerEngine(nlp_engine=NlpEngineProvider(nlp_configuration=nlp_config).create_engine())
results = analyzer.analyze(text="Contact Elena Vargas at elena@acme-fin.io", language="en")

Drop-In Integration: ONNX Runtime (with Label Decoding)

pip install "transformers>=4.48.0" onnxruntime huggingface_hub numpy
import json
import numpy as np
import onnxruntime as ort
from huggingface_hub import hf_hub_download
from transformers import AutoTokenizer

repo_id = "Tamarillo/pii-secrets-guard-small"
tok = AutoTokenizer.from_pretrained(repo_id)
cfg = json.loads(open(hf_hub_download(repo_id, filename="config.json")).read())
id2label = {int(k): v for k, v in cfg["id2label"].items()}

onnx_path = hf_hub_download(repo_id, filename="onnx/model.onnx")
sess = ort.InferenceSession(onnx_path, providers=["CPUExecutionProvider"])

text = "DB=postgresql://svc:MyPass123!@db.internal:5432/prod"
enc = tok(text, return_tensors="np", return_offsets_mapping=True)
logits = sess.run(
    ["logits"],
    {
        "input_ids": enc["input_ids"].astype(np.int64),
        "attention_mask": enc["attention_mask"].astype(np.int64),
    },
)[0][0]

pred_ids = np.argmax(logits, axis=-1)
for (start, end), pid in zip(enc["offset_mapping"][0], pred_ids):
    lbl = id2label[int(pid)]
    if end > start and lbl != "O":
        print(lbl, repr(text[int(start):int(end)]))

Evaluation Results

All checkpoints were selected strictly by validation metrics; evaluation was run with the bundled reproducible harness (scripts/eval_suite.py) using fair shared-entity typed F1 (IoU >= 0.50), identical canonical label normalization, and symmetric adjacent-span merging (first_name + last_name -> PERSON, building_number + street -> STREET_ADDRESS) for every baseline so no baseline is penalized for entity types it was not trained to predict.

Table 1 — Core Benchmark Test Splits (n=600 per split)

Splits: nvidia/Nemotron-PII (test), gretelai/gretel-pii-masking-en-v1 (test), gretelai/synthetic_pii_finance_multilingual (test; multilingual — out-of-scope for EN-only tiny-en), Wismut/nym-pii-multilingual-data (test; 23 languages — out-of-scope for EN-only tiny-en), and Agent-Secrets (split-disjoint templates generated by scripts/synth_secrets.py, n=600).

Model (HF Repo ID) Params Max Len Nemotron-EN Gretel-EN Gretel-Multi Wismut-Multi Agent-Secrets
Tamarillo/pii-secrets-guard-tiny-en 32.05M 7999 0.984 0.971 0.622 0.508 0.888
Tamarillo/pii-secrets-guard-small 140.66M 8192 0.986 0.978 0.837 0.990 0.886
Tamarillo/pii-secrets-guard-base 307.56M 8192 0.985 0.976 0.844 0.990 0.937
iiiorg/piiranha-v1-detect-personal-information 278.23M 256 0.680 0.551 0.401 0.637 0.402
Isotonic/deberta-v3-base_finetuned_ai4privacy_v2 183.92M 512 0.481 0.434 0.318 0.406 0.404
vllm-sr/mmbert32k-pii-detector-merged 307.56M 8192 0.193 0.209 0.147 0.257 0.059
Wismut/nym-pii-multilingual 307.59M 2048 0.622 0.688 0.444 0.999 0.172
kalyan-ks/ettin-68m-nemotron-pii 68.46M 2048 0.291 0.173 0.357 0.187 0.080

Table 2 — Zero-Shot Out-of-Distribution, Hard-Negative FP, Long-Context Needle & Latency

  • Zero-Shot OOD (never seen in training): YalenLabs/yalen-pii-ner-bias-audit (benchmark/train, EN+FR, n=600) and BTX24/turkish-privacy-pii-ner (test, Turkish, n=600).
  • Hard-Negative FP (HN FP, lower is better): % of n=500 clean developer/prose documents (git SHAs, SHA-256 digests, UUIDs, placeholder keys, env lookups) triggering >=1 false alarm (scripts/synth_secrets.py, split-disjoint test templates).
  • Long-Context Needle Recall (LC @ 800 / 3.2K / 5K): Recall (n=60 docs per token depth) for PII & secrets buried past 800 / 3,200 / 5,000 tokens in a single forward pass. Note that 0.000 for <=2,048-token baselines reflects single-pass native context truncation without sliding-window chunking.
  • GPU & CPU Latency: GPU p50 latency uses PyTorch FP32 via transformers.pipeline on NVIDIA L4 (24 GB), batch_size=1, 40-token input (n=15 runs after 3 warmups). At batch_size=1 on short inputs, 22-layer small (140M) and base (307M) are kernel-launch-bound (26–28 ms). CPU ONNX p50 latencies in Available Runtime Artifacts were measured on an 8-vCPU x86_64 GCP host (CPUExecutionProvider, default ORT thread pool, batch_size=1, median over 4 short ~45–55-token inputs), where tiny-en (8.85 ms FP32), small (21.5 ms INT8), and base (34.2 ms INT8) scale cleanly with parameter count.
Model (HF Repo ID) Params OOD Yalen OOD BTX24-TR HN FP (↓) LC Recall @ 800 / 3.2K / 5K GPU p50 (L4, b=1)
Tamarillo/pii-secrets-guard-tiny-en 32.05M 0.594 0.163 0.018 0.968 / 0.973 / 0.963 14.3 ms
Tamarillo/pii-secrets-guard-small 140.66M 0.725 0.536 0.060 0.979 / 0.973 / 0.979 27.6 ms
Tamarillo/pii-secrets-guard-base 307.56M 0.711 0.526 0.002 0.995 / 0.989 / 0.984 26.1 ms
iiiorg/piiranha-v1-detect-personal-information 278.23M 0.715 0.379 0.000 0.000 / 0.000 / 0.000 25.8 ms
Isotonic/deberta-v3-base_finetuned_ai4privacy_v2 183.92M 0.746 0.141 0.344 0.000 / 0.000 / 0.000 26.4 ms
vllm-sr/mmbert32k-pii-detector-merged 307.56M 0.606 0.196 0.684 0.779 / 0.647 / 0.559 27.8 ms
Wismut/nym-pii-multilingual 307.59M 0.825 0.496 0.560 0.647 / 0.000 / 0.000 26.9 ms
kalyan-ks/ettin-68m-nemotron-pii 68.46M 0.523 0.053 0.546 0.371 / 0.000 / 0.000 25.6 ms

Honest Comparison Notes (Including Where We Lose)

  • Zero-Shot OOD Yalen & Wismut-Multi: Wismut/nym-pii-multilingual (0.825 on OOD Yalen, 0.999 on its own Wismut-Multi split) and Isotonic/deberta-v3-base_finetuned_ai4privacy_v2 (0.746 on OOD Yalen) outperform this model (0.725 on OOD Yalen, 0.990 on Wismut-Multi); on OOD Yalen, iiiorg/piiranha-v1-detect-personal-information (0.715) and Tamarillo/pii-secrets-guard-small (0.725) also score equal to or above base/tiny-en. However, wismut-nym-base and isotonic-deberta-v3 carry much higher developer hard-negative false-positive rates (0.560 and 0.344 vs. 0.060), miss agent secrets (0.172 and 0.404 vs. 0.886), and truncate single-pass inputs at 2,048 / 512 tokens (while Isotonic is non-commercial CC-BY-NC-4.0).
  • Hard-Negative FP vs. piiranha-v1: iiiorg/piiranha-v1-detect-personal-information achieves 0.000 FP on developer/code hard negatives largely because it does not detect developer secrets (API_KEY, AUTH_TOKEN, DATABASE_URI, PRIVATE_KEY) and scores 0.402 on Agent-Secrets. This model trades a small non-zero FP rate (0.060) to achieve 0.886 F1 on agent secrets.
  • English-only scope of tiny-en: Tamarillo/pii-secrets-guard-tiny-en (32M) is trained strictly on English prose and developer logs; on multilingual splits (Gretel-Multi, Wismut-Multi, OOD BTX24-TR) it underperforms multilingual models.
  • OOD generalization ceiling: Zero-shot scores on OOD Yalen (0.725) and OOD BTX24-TR (0.536) are substantially lower than in-distribution synthetic splits; benchmark on your own production traffic before deployment.

Training & Data Provenance

Trained with exact BIO token classification cross-entropy (group_by_length=True, cosine schedule, bf16, max_length=2048 with sliding-window overflow) on commercially permissive datasets only (zero ai4privacy data):

Best validation checkpoint (epoch 3.0): micro-F1 0.9250, macro-F1 0.9364, precision 0.9081, recall 0.9425.

Limitations & Honest Caveats

  • Long-context validation range: While the backbone natively supports up to 8,192 tokens, our empirical long-context needle evaluation validated recall up to ~5,000 tokens (LC@5K recall 0.979); inputs between 5,000 and 8,192 tokens were not separately benchmarked.
  • Synthetic training provenance: Because public PII corpora are synthetic (to avoid distributing real personal data), domain-specific abbreviations, noisy OCR, or unusual internal ID formats may require confidence-threshold tuning or lightweight domain fine-tuning.
  • Not a replacement for architectural controls: Use alongside deterministic validators (Luhn checks, provider key scanners, least-privilege sandboxing) in defense-in-depth agent pipelines.
  • Scope: Multilingual performance is strongest on high-resource Latin, Cyrillic, and CJK scripts covered in training and may degrade on low-resource scripts.
  • Dependencies: Requires transformers >= 4.48.0 (native ModernBERT support).
Downloads last month
26
Safetensors
Model size
0.1B 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-small

Quantized
(336)
this model

Datasets used to train Tamarillo/pii-secrets-guard-small

Spaces using Tamarillo/pii-secrets-guard-small 2

Collection including Tamarillo/pii-secrets-guard-small