Instructions to use sairaamv1/small-lm-data-element with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sairaamv1/small-lm-data-element with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="sairaamv1/small-lm-data-element", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("sairaamv1/small-lm-data-element", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
small-lm-data-element
A 22.8M-parameter shared encoder (nreimers/MiniLM-L6-H384-uncased) fine-tuned with
two heads: a binary gate that decides whether a short column-name or abbreviation string
(e.g. fst_nm, dob, created_at) is personal data at all, and a 258-way head that picks its
canonical Data Element label (e.g. First Name, Date of Birth) -- but only when the gate
says it's PII. Not-PII inputs (timestamps, surrogate keys, auth/session internals, storage
metadata, ...) never have to be forced into one of the 258 classes, which is what a single-head
classifier with no reject option does, and does badly: an audit of an earlier single-head version
of this model found it confidently mapping claims to "Claim History", nonce to "Dietary
Preferences", and is_sso_user to "SSN (Social Security Number) (US)" at 95%+ confidence, because
it had no way to say "this isn't PII" at all. A confidence threshold doesn't fix that either: right
and wrong predictions have overlapping confidence distributions, so no cutoff cleanly separates them.
Benchmarks
- End-to-end accuracy (gate right, and type right if PII): 93.90% (4440 held-out examples)
- PII gate: accuracy 99.10%, precision 99.20%, recall 99.61%, F1 99.40%
- Type accuracy given true PII: 92.70% (3343 PII rows)
- CPU inference latency: 2.12 ms/example (single thread, batch size 1)
- Best epoch: 90, validation end-to-end accuracy 94.27%
Lowest-accuracy categories on the test set (PII rows only):
| Category | Accuracy |
|---|---|
| Health & Biometric Data | 38.5% |
| Transaction Data | 87.7% |
| Authentication Data | 88.1% |
| Cookies & Tracking | 88.5% |
| Communication & Behavioral Data | 88.5% |
Out-of-distribution benchmark
The test set above is drawn from the same spreadsheet + synthetic-augmentation pipeline as
training, so it doesn't show how the model handles real column names it's never seen a naming
pattern for. Checked against four independent sources: real dataset column names from
trl-lab/contextual-sensitive-data,
both mapped onto this label set and kept as not-PII negatives (128 rows), real
field names from public API/schema vocabularies (Salesforce, Schema.org, Stripe, Shopify,
FHIR/OpenMRS) hand-labeled against these 258 Data Elements (64 rows), a
fresh PII batch (26 rows) from systems (Workday, Okta, Twilio, PayPal,
HubSpot, GitHub, DMV) added only after the training data below was finalized, and a fresh
not-PII batch (24 rows) of system/infra field names (AWS, Kafka,
Datadog, Segment) added the same way, to get an uncontaminated read on the gate.
Combined: 91.3% (84.4% / 100.0% / 96.2% / 100.0% on the four sources). Take the first two with a grain of salt β some of their miss-words ended up in this model's training vocabulary, so part of that score is memorization. The two fresh sources are the honest numbers: real generalization to column names and naming styles never targeted during training. Known limitation β don't rely on this for unseen real schemas without more representative training data.
Training data
Trained on a dataset of data-element names and their abbreviations/case-variants (e.g.
first_name -> fname, f_nm, firstName, ...), expanded with synthetically generated
naming-style and abbreviation-pattern variants, plus a separate not-PII set of system/technical
column names generated the same way and real negatives from trl-lab/contextual-sensitive-data
(see the fieldmap repo for the generation scripts).
Usage
This is a custom dual-head architecture (modeling_dual_head.py, shipped in this repo), not a
standard AutoModelForSequenceClassification -- loading it needs trust_remote_code=True:
from transformers import AutoTokenizer, AutoModel
import torch
tok = AutoTokenizer.from_pretrained("sairaamv1/small-lm-data-element")
model = AutoModel.from_pretrained("sairaamv1/small-lm-data-element", trust_remote_code=True)
type_labels = model.config.id2type_label
inputs = tok("fst_nm", return_tensors="pt")
out = model(**inputs)
if out.pii_logits.argmax(-1).item() == 1:
print(type_labels[str(out.type_logits.argmax(-1).item())])
else:
print("not PII")
- Downloads last month
- 85