ScienceSoft PII encoder — small

A fast, multilingual token-classification model for personal data without a fixed format: names of people and organisations, locations, addresses and dates. It is a 6-layer, 384-wide student of ScienceSoft/scnsoft-pii-encoder. The file is 107.6 MB, and inference runs on CPU. In Python ONNX Runtime 1.24.2, on one idle aarch64 Linux host at one thread and batch size 1 (not the production engine), it takes 0.19 of the full model's time per 450-character window.

This revision adds a second output. The same int8 graph now also returns doc_logits, a score for each of 17 document types. The document types decide nothing in this release: every type is in mode rules in doc_labels.json, so a product that reads that file lets its rule-based classifier decide and treats the model's document scores as information only.

It is still less accurate than the model it was distilled from. Before the first small model was trained, a bar was set for releasing one: an average PII Bench F1 of at least 0.72, with no language more than 0.08 below the full model. This revision reads 0.7037, and it does not meet that bar; Arabic and German are also more than 0.08 below the full model. It is a large step from the previous revision of this repository, which reads 0.5672 on the same harness and the same entity map. It is published with these results stated.

  • Name-origin bias line missed. The int8 graph, which is the file published here, reads 0.0938 on the name-origin bias probe against a line of 0.05 (the fp32 weights read 0.0469). The previous revision read 0.125 in int8 and 0.1406 in fp32. The line is judged on int8.
  • The document output is not validated on a sealed held-out set, and its scores differ between CPU types (below).
  • The previous revision, 13bfb0e2c605335a93657bfae278907d22946cbd, stays in this repository and can still be downloaded by that revision id.

What changed in this revision

  • New weights. The model was retrained from the same starting point with three objectives at once (see Training): the PII objective of the previous revision; a document-type objective, taught by the windows' document labels and by ScienceSoft's document-type head; and a second PII objective, in which the full model's token predictions on real public documents, which carry no PII labels, teach this model.
  • One graph, two outputs. onnx/model_quantized.onnx returns logits (PII) and doc_logits (document types). The PII output is byte-identical to this model's own PII-only int8 export (below), so adding the document output changes no PII result.
  • New files: doc_labels.json (the document labels and their modes) and MANIFEST.sha256.
  • Unchanged files: tokenizer.json, config.json, tokenizer_config.json and special_tokens_map.json are byte-identical to the previous revision's.

Files

file what it is
README.md This model card.
onnx/model_quantized.onnx The int8 graph. Outputs logits [batch, tokens, 11] and doc_logits [batch, 17]. 107,578,075 bytes, sha256 d2c8898684513795920ae65642ae7d66bc374fc24f8ef27639bbca66f467ddf1.
doc_labels.json Version 2. The 17 document labels in doc_logits column order and, per label, its mode (rules for all), t_add and t_confirm (both null) and the informational keys bar_t and bar_t_windows_at_or_above (below). 7,187 bytes, sha256 b4f576a14adb43764214709b75342afe47926ebe98eba1dea4274b5affc366bc.
tokenizer.json XLM-R's tokenizer, truncating at 256 tokens. 17,082,987 bytes, sha256 a514807cffabd8abaf028cfaffe7ff0c4f60b97ea2db80c41f14172ae6b018ca.
config.json The model configuration, with the 11 PII labels. sha256 bcea7395c172d87f7c1c0d0b5965703ccbb072df94d56190a15050d40c97aeb4.
tokenizer_config.json Tokenizer settings. sha256 20763d0eaffb567c10bc03dba5b3b7efc2ea1f6b0efec9c4c460d93a3b100b9a.
special_tokens_map.json The special-token map. sha256 8c785abebea9ae3257b61681b4e6fd8365ceafde980c21970d001e834cf10835.
THIRD_PARTY_NOTICES.md Notices and attributions for the base model, the tokenizer and the training sources.
MANIFEST.sha256 The sha256 of every file above.

In doc_labels.json, encoder_onnx_sha256 is e0edf9c3f8ba9f4e298fc21ca124ad8377b410211b5f62e81329d22ba1682c4e: this model's own PII-only int8 export (107,164,341 bytes). That file is not in this repository. It is named because the PII results below were read on it, and because the published graph's logits are byte-identical to it. encoder_revision says that the encoder is the graph in this revision, since this model has no separately published base encoder. pii_only_graph is null: one graph serves both outputs.

Labels

PII output (logits): PERSON ORGANIZATION LOCATION ADDRESS DATE_TIME (BIO tagging, 11 classes), the same set and order as the full model.

Identifiers with a fixed format (email addresses, telephone, payment-card, IBAN and passport numbers) are not labels; a regular expression recognises them exactly. The model is trained to leave them unmarked; see touch rate below.

Document output (doc_logits), in column order: legal.nda, legal.master_agreement, legal.sow, legal.contract_other, sales.rfp, sales.proposal, sales.pricing, tech.source_code, tech.design, tech.security, finance.report, finance.billing, finance.personal, hr.personnel, corporate.strategy, public.published, health.patient_record. A window's score for a type is sigmoid(doc_logits).

Speed

Measured on 100 windows of 450 characters (116 tokens on average) from an internal development set:

  • int8 ONNX Runtime 1.24.2 in Python, CPU, one thread, batch size 1;
  • all graphs interleaved, seven rounds;
  • one aarch64 Linux host (NVIDIA GB10), idle: a 1-minute load average of 0.10 before the run.

Absolute milliseconds depend on the host; the ratio is the informative part.

graph size median ms per window 95th percentile time against the full model
scnsoft-pii-encoder 278 MB 40.8 62.4 1.00
this revision, both outputs 107.6 MB 7.69 12.18 0.19
this revision, logits only 107.6 MB 7.71 12.17 0.19
previous revision 107.2 MB 7.63 12.06 0.19

The document output costs about 1 % over the previous revision's time. The previous card's "3.9× faster" was a different measurement (PII Bench rows, on a loaded Apple M4 Max) and is not comparable with this one. Speed on Windows and on x64 CPUs was not measured.

Evaluation on PII Bench

PII Bench (piibench) scores detection of the five entity types above in text serialised the way outbound traffic carries it (JSON, XML, SQL, CSV, key=value, log lines, Markdown tables, OCR output) as well as prose.

  • It comprises 3,500 rows, 500 from each of seven third-party datasets.
  • Precision, recall and F1 are computed over characters and are label-agnostic.
  • Scores are micro-averaged within each dataset and then averaged across the seven.
  • Leaderboard: ScienceSoft/piibench-leaderboard.

How these numbers were produced. Every model in the tables below is scored by the production Rust inference engine, before its post-filters, with its own entity map: the mapping from the model's labels to the product's PII types. This model's map does not map LOCATION, so a location it marks is not counted as a detection. The intervals are 95 % percentile bootstrap intervals over rows, resampled within each dataset (1,000 resamples). This revision was read on its PII-only export, whose logits are byte-identical to the published graph's: first with the tokenizer saved beside the training weights (which truncates at 512 tokens), then again with the tokenizer.json (256 tokens, same vocabulary) and config.json published here. The two reads give identical numbers.

The previous card's 0.5965 was the previous revision read with the full model's entity map, in which LOCATION counts. With its own map, the one the product uses for it, the previous revision reads 0.5672 on the same harness. All numbers on this page are own-map reads.

Conflict of interest. PII Bench is built and published by ScienceSoft, the developer of this model. Four of its seven datasets (TAB, FactRuEval, MEDDOCAN, IAHLT) informed changes to the synthetic training corpus this model shares with the full model.

this revision previous revision scnsoft-pii-encoder bar set before training
F1 0.7037 [0.6953, 0.7112] 0.5672 [0.5574, 0.5758] 0.7758 [0.7683, 0.7828] ≥ 0.72
precision 0.6533 0.4693 0.7028
recall 0.7712 0.7328 0.8861
touch rate (lower is better) 0.0364 0.2168 0.0217
language this revision previous revision bar (full model − 0.08)
ar 0.5665 0.4666 0.601 below
de 0.5072 0.3803 0.577 below
en 0.7730 0.6364 0.724 meets
es 0.8068 0.6601 0.764 meets
ru 0.6831 0.5546 0.674 meets

The per-language bars are the full model's per-language F1 from the published leaderboard row (0.7725 average) minus 0.08, as on the previous card.

Per dataset, this revision: TAB 0.7344, GermEval 0.5072, FactRuEval 0.6831, MEDDOCAN 0.8068, IAHLT 0.5665, Gretel 0.8666, Nemotron 0.7612.

  • Precision rose most (0.4693 to 0.6533), and the touch rate fell from 0.2168 to 0.0364: the previous revision's main weakness, marking far too much of real text, is much reduced. Recall rose too (0.7328 to 0.7712), but stays below the full model's.
  • Touch rate is the share of characters belonging to format-fixed identifiers that a model marks anyway.
  • One seed. Three training seeds were trained; the one published (seed 7001) was chosen on the document development metric before any PII Bench read, and only it was read on PII Bench.

Synthetic evaluation. On the 5,300-row evaluation split drawn from the training generator, the int8 graph scores F1 0.9839 (fp32 0.9864); the previous revision's int8 graph scores 0.9811.

Name-origin bias

The probe holds the sentence fixed and changes only the name: seven name origins, 64 sentences each, and the recall of the name per origin. The figure is the largest difference in recall between two origins; the line is 0.05. The line is judged on the int8 graph, the file published here.

int8 (published) fp32 weights worst origin
this revision 0.0938 0.0469 East Asian names (int8 recall 0.906; African names 0.953; the other five 1.0)
previous revision 0.125 0.1406 East Asian names (int8 recall 0.875)

This revision does not meet the line in int8. It is closer to it than the previous revision, and it meets it in fp32, which is not what is shipped.

Document types

  • Teacher. The document output was taught by the windows' document labels and by ScienceSoft's document-type head ScienceSoft/scnsoft-pii-encoder-doc-type-head (V3a, seed 7001), on the same 450-character windows.
  • Internal development metric: 0.952. For seven types, the recall on development documents of the type at the score where an internal pool of 1,940 benign development documents gives 2 false records, then the mean over the seven: legal.nda 0.985, legal.master_agreement 0.974, legal.contract_other 0.948, tech.design 0.993, tech.security 0.826, tech.source_code 1.0, finance.personal 0.938. It is an internal development number, read on the int8 graph from the same data that chose the published seed, not a validation. On the same metric this model reads above its own teacher (0.914), which is unusual and is one more reason not to rely on it. The three seeds read 0.926, 0.940 and 0.952.
  • Not validated on a sealed held-out set. That read has not been made.
  • Every type is in mode rules. t_add and t_confirm are null, because the reporting thresholds were not computed for this model. A product that follows doc_labels.json lets its rule-based classifier decide and uses the model's scores for information only, until a later release.
  • bar_t (per type, with bar_t_windows_at_or_above) is a score computed on 380,151 windows of United Nations documents, used as documents of none of the types: the count says how many of those windows reach it (3 to 6). It is information only; the engine ignores both keys.
  • Scores differ between CPU types. On the same 6,825 rows, doc_logits computed on an aarch64 Linux host and on an Apple Mac (both ONNX Runtime 1.24.2) differ by up to 0.89 in logit, 0.128 in score. Thread count makes no difference on either host. A window near a threshold may reach it on one machine and not on another.
  • Scoring. Score one 450-character window per call (batch size 1), as the engine does.

LOCATION

Evidence only, not a registered evaluation. On two long texts of shipping and region wording that contain no place that is personal data, this revision marks 0 false locations at a 0.8 confidence cut, where the previous revision marks 79 and 22. On 100 short stress sentences it marks 12, against the previous revision's 24; its marks are region phrases such as "Asia Pacific" and "the east coast". Both of the true city names in the probe are lost at cuts of 0.999 and above. In the product, this model's LOCATION output is not mapped to a PII type, as before.

Not verified

  • The document output on a sealed held-out set.
  • The reporting thresholds for the document types (hence every type in mode rules).
  • Windows, and x64 CPUs: loading in the production engine, the identity of the PII output, and speed were checked only on aarch64 Linux and on an Apple Mac (arm64).
  • Agreement between CPU types for doc_logits: they differ by up to 0.128 in score (above).
  • PII Bench for the seeds not published, the fp32 graph, and batch sizes above 1.

Training

  • Architecture and start. microsoft/Multilingual-MiniLM-L12-H384, reduced to 6 of its 12 layers (layers 1, 3, 5, 7, 9 and 11), with a new 11-class token head and XLM-R's tokenizer; the same start as the previous revision, not its trained weights.
  • Document head. The masked mean of the final hidden state (the input of the token classifier) over the window's tokens, without <s> and </s>, then 384 → 256 → 17 with dropout 0.1.
  • PII objective, as before. On the full model's synthetic corpus (155,141 training rows): 0.5 × cross-entropy on the gold labels plus 0.5 × T² × KL(teacher ‖ student) on scnsoft-pii-encoder's token distributions at temperature T = 2.
  • Document objective. On 391,448 training windows of 450 characters (50 characters of overlap): 0.5 × class-weighted binary cross-entropy on each window's document-type labels plus 0.5 × T² × KL on the document-type head's scores at T = 2, with weight 1.0 against the PII objective. Before training, 250 windows that shared text with PII Bench were removed.
  • PII teaching on real text. On 363,575 of those windows, from the 25 sources registered for this use, scnsoft-pii-encoder's token distributions as the only target (KL at T = 2, weight 0.5 × T²). These windows carry no gold PII labels. 27,873 windows from six sources not registered for this use were excluded from this objective; they still train the document output.
  • Schedule: 9,698 steps (two epochs of the PII corpus), batches of 32 PII rows and 64 windows, linear warm-up over 10 %, then linear decay; 51 minutes on one GPU. Each of three seeds was trained twice, with equal weight hashes.
  • Stack: transformers==4.57.1, torch==2.10.0a0 (NVIDIA container 25.11), onnxruntime==1.24.2.
  • Export. The PII graph is exported and quantised to int8; the document head is then added to that int8 graph by inserting nodes, without changing any existing node. On all 6,825 rows of ScienceSoft's PII release check, the published graph's logits are byte-identical to the PII-only export's, at batch size 1 and at 1 and 4 threads, on aarch64 Linux and on an Apple Mac (ONNX Runtime 1.24.2, in Python and in the production engine's runtime).

Limitations

  • Below the release bar (above), and below it in Arabic and German. Where accuracy matters more than latency, use scnsoft-pii-encoder.
  • Name-origin bias line missed in int8 (above).
  • The document output is unvalidated and differs between CPU types; in this release it decides nothing.
  • The PII labels are still synthetic. The real documents in training carry no PII labels; they only carry the full model's predictions. Scores on generated text overstate real-world ability.
  • The limitations of the full model apply too. Arabic is its weakest language; Arabizi is a reconstruction; DATE_TIME is kept by the product only next to a birth-date cue.

Use

Required files for PII: config.json, tokenizer.json, onnx/model_quantized.onnx. For the document output, also doc_labels.json.

import json, numpy as np, onnxruntime as ort
from transformers import AutoTokenizer

tok = AutoTokenizer.from_pretrained("ScienceSoft/scnsoft-pii-encoder-small")
cfg = json.load(open("config.json"))
id2label = {int(k): v for k, v in cfg["id2label"].items()}
doc_labels = json.load(open("doc_labels.json"))["labels"]
sess = ort.InferenceSession("onnx/model_quantized.onnx",
                            providers=["CPUExecutionProvider"])

enc = tok(text, return_offsets_mapping=True, return_tensors="np",
          truncation=True, max_length=256)
offsets = enc.pop("offset_mapping")[0]
feeds = {i.name: enc[i.name] for i in sess.get_inputs()}
logits, doc_logits = sess.run(["logits", "doc_logits"], feeds)
# PII: argmax -> id2label -> merge BIO spans using `offsets` for character positions
# Document types, for a 450-character window at batch size 1:
scores = dict(zip(doc_labels, 1 / (1 + np.exp(-doc_logits[0]))))

The ONNX graph takes input_ids and attention_mask only. Encode with the special tokens <s> and </s>, as the model was trained; AutoTokenizer.__call__ adds them by default. Request ["logits"] alone for PII only.

Training data and provenance

The training data is not published. No production traffic is used for training.

  • PII corpus: synthetic text produced by ScienceSoft's own generator, as for the full model. Entity values come from project-written lists and from Faker (person, company and city names), libpostal (address vocabulary) and GeoNames (Arabic-script city names).
  • Document windows: the document corpus of the document-type head. Real public documents under open licences or in the public domain: agreements from CUAD, ContractNLI, the KL3M collection of EDGAR agreements, Common Paper and Bonterms (CC BY 4.0), SEC EDGAR filings, official legislation (EU, French and Italian texts), United Nations documents, European Union and UK government pages (the GOV.UK pages as examples of documents that are none of the types, under the Open Government Licence v3.0), software and security documentation and advisories, Python Enhancement Proposals, US drug labels, payslip examples, and Wikinews. Machine translations of registered training documents, made with OPUS-MT (CC BY 4.0). Generated text, written by an open-weight language model released under a permissive open licence from prompts written for each type, and documents based on templates written by ScienceSoft.

Text was cut into 450-character windows and used only to train this model; no source text is redistributed with it. Attributions that the sources ask for are in THIRD_PARTY_NOTICES.md.

Licence

Proprietary to ScienceSoft. The weights are published so that the results on this page can be evaluated and reproduced; no licence to use them in production, to modify them or to redistribute them is granted. For licensing, contact ScienceSoft (https://www.scnsoft.com).

Basis for these terms.

  • Initialised from microsoft/Multilingual-MiniLM-L12-H384 (MIT licence).
  • Uses the tokenizer of FacebookAI/xlm-roberta-base (MIT licence).
  • Distilled from ScienceSoft's own scnsoft-pii-encoder and its document-type head.
  • PII training corpus includes entity values from Faker (MIT), libpostal (MIT) and GeoNames (CC BY 4.0).
  • Document windows come from the sources listed in THIRD_PARTY_NOTICES.md and described above. The licences recorded for them when the document-type head was released (CC BY 4.0, the Open Government Licence v3.0, the Licence Ouverte 2.0, the European Commission's reuse policy for EUR-Lex, the United Nations corpus terms, and public-domain and permissive software and documentation licences) permit a derivative work to be distributed under proprietary terms, provided notices are retained and attribution is given. The SEC EDGAR filings come through a dataset whose card says only that EDGAR data is publicly available; no licence statement for them beyond that has been confirmed.

None of these licences is share-alike, and none restricts commercial use. The notices and the attributions are in THIRD_PARTY_NOTICES.md.

Downloads last month
73
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for ScienceSoft/scnsoft-pii-encoder-small

Finetuned
(42)
this model

Evaluation results

  • F1, character-level, label-agnostic, averaged over 7 datasets (production engine, before post-filters, this model's own entity map) on PII Bench (piibench)
    self-reported
    0.704
  • Precision on PII Bench (piibench)
    self-reported
    0.653
  • Recall on PII Bench (piibench)
    self-reported
    0.771