Upload folder using huggingface_hub
Browse files- README.md +86 -105
- onnx/model_quantized.onnx +1 -1
- tokenizer.json +1 -1
README.md
CHANGED
|
@@ -1,126 +1,107 @@
|
|
| 1 |
---
|
| 2 |
-
license:
|
| 3 |
-
license_name: proprietary-sciencesoft
|
| 4 |
-
base_model: FacebookAI/xlm-roberta-base
|
| 5 |
language: [en, de, fr, it, es, ru, ar]
|
| 6 |
pipeline_tag: token-classification
|
| 7 |
-
tags: [pii,
|
| 8 |
-
library_name:
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
-
# ScienceSoft PII
|
| 12 |
|
| 13 |
-
Multilingual
|
| 14 |
-
|
| 15 |
-
|
| 16 |
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|---|---|
|
| 23 |
-
| `PERSON` | no format; transliteration and dialect spelling |
|
| 24 |
-
| `ORGANIZATION` | no format |
|
| 25 |
-
| `LOCATION` | place names |
|
| 26 |
-
| `ADDRESS` | free-form street addresses |
|
| 27 |
-
| `DATE_TIME` | dates written as prose |
|
| 28 |
|
| 29 |
-
|
| 30 |
-
passports or tax IDs. Those have a format and usually a checksum, so a regex
|
| 31 |
-
decides them deterministically, in every language, at no inference cost. An
|
| 32 |
-
encoder adds only a second, weaker opinion there.
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
##
|
| 38 |
|
| 39 |
-
|
| 40 |
-
Modern Standard, Gulf, Levantine, Egyptian, and **Arabizi** (Arabic in Latin
|
| 41 |
-
script with digits: `3arabi`, `7abibi`).
|
| 42 |
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
##
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
| ru | 0.947 | | ar-gulf | 0.769 |
|
| 54 |
-
| de | 0.940 | | ar-levantine | 0.751 |
|
| 55 |
-
| it | 0.930 | | ar-egyptian | 0.741 |
|
| 56 |
-
| fr | 0.929 | | | |
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
- Not a compliance guarantee. One layer of a DLP system, not the system.
|
| 103 |
-
|
| 104 |
-
## Artifact
|
| 105 |
-
|
| 106 |
-
`onnx/model_quantized.onnx` — 278 MB, int8 dynamic, opset 17, IR 8.
|
| 107 |
-
Runs on ONNX Runtime ≥ 1.24. CPU latency, 4 threads: **28 ms @128 tokens,
|
| 108 |
-
166 ms @512**.
|
| 109 |
-
|
| 110 |
-
Quantization is not a loss here — int8 scores **above** fp32 (0.8704 vs 0.8492).
|
| 111 |
-
|
| 112 |
-
## Training
|
| 113 |
-
|
| 114 |
-
XLM-RoBERTa-base fine-tuned for token classification, 3 epochs, 280k generated
|
| 115 |
-
examples across seven languages and five Arabic registers, 30% label-preserving
|
| 116 |
-
augmentation.
|
| 117 |
-
|
| 118 |
-
Training data is generated by ScienceSoft's own generators — no third-party
|
| 119 |
-
corpus is used, so the model carries no upstream corpus licence. WikiANN is used
|
| 120 |
-
for **evaluation only** and never for training.
|
| 121 |
-
|
| 122 |
-
## Licence and attribution
|
| 123 |
-
|
| 124 |
-
Proprietary to ScienceSoft. Derived from
|
| 125 |
-
[`FacebookAI/xlm-roberta-base`](https://huggingface.co/FacebookAI/xlm-roberta-base)
|
| 126 |
-
(MIT), whose licence and copyright notice are retained.
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
|
|
|
|
|
|
| 3 |
language: [en, de, fr, it, es, ru, ar]
|
| 4 |
pipeline_tag: token-classification
|
| 5 |
+
tags: [pii, ner, privacy, dlp, onnx, xlm-roberta]
|
| 6 |
+
library_name: onnxruntime
|
| 7 |
+
base_model: FacebookAI/xlm-roberta-base
|
| 8 |
---
|
| 9 |
|
| 10 |
+
# ScienceSoft PII encoder
|
| 11 |
|
| 12 |
+
Multilingual NER for the personal data **regex cannot find** — names,
|
| 13 |
+
organisations, locations, addresses and date expressions — in seven languages
|
| 14 |
+
plus four Arabic registers and Arabizi.
|
| 15 |
|
| 16 |
+
It is the NER half of a data-loss-prevention agent that inspects outbound
|
| 17 |
+
AI-assistant traffic on a device and redacts personal data before it leaves.
|
| 18 |
|
| 19 |
+
`xlm-roberta-base`, fine-tuned on a fully synthetic corpus
|
| 20 |
+
(`vadimbelsky/scnsoft-pii-synthetic-corpus`), exported to ONNX and int8
|
| 21 |
+
quantized. **278 MB**, CPU inference.
|
| 22 |
|
| 23 |
+
## Labels
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
`PERSON` `ORGANIZATION` `LOCATION` `ADDRESS` `DATE_TIME` (BIO, 11 classes)
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
**Email, phone, card, IBAN and passport numbers are deliberately absent.** Those
|
| 28 |
+
have a shape and usually a checksum, so a regex decides them exactly and a
|
| 29 |
+
classifier only produces a second, weaker opinion that then competes with the
|
| 30 |
+
layer that was right. This model is built to leave them alone — and measurably
|
| 31 |
+
does (see `touch_rate` below).
|
| 32 |
|
| 33 |
+
## Verified results
|
| 34 |
|
| 35 |
+
Gate run 2026-08-30. Every figure measured, none estimated.
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
| | this model | model it replaces |
|
| 38 |
+
|---|---|---|
|
| 39 |
+
| **regex-owned identifiers wrongly touched** (real ru text) | **0.1%** (1/770) | 53.6% (413/770) |
|
| 40 |
+
| **known-defect suite** | **18/18** | 7/18 |
|
| 41 |
+
| hivetrace ru PII — F1 / P / R | 0.5888 / 0.4375 / **0.9000** | 0.2754 / 0.1610 / 0.9500 |
|
| 42 |
+
| Wojood ar NER — F1 | 0.4888 | 0.4136 |
|
| 43 |
+
| int8 F1 (held-out synthetic) | 0.8906 | 0.8704 |
|
| 44 |
+
| int8 vs fp32 F1 cost | 0.0081 | — |
|
| 45 |
+
| latency p95 @512 tok (CPU, 4 thread) | 190.9 ms | 190.8 ms |
|
| 46 |
+
| name-origin bias delta | 0.0312 | not validly measured |
|
| 47 |
|
| 48 |
+
Head-to-head vs the previously shipped multilingual PII model, ours ahead in
|
| 49 |
+
every language: it +0.58 · es +0.55 · fr +0.52 · en +0.52 · de +0.48 ·
|
| 50 |
+
ar +0.45 · **ru +0.07**.
|
| 51 |
|
| 52 |
+
## Read this before using it
|
| 53 |
|
| 54 |
+
**Recall was traded for precision.** Recall on real Russian PII fell 0.95 → 0.90
|
| 55 |
+
while precision rose 0.16 → 0.44. False positives dropped roughly 500×, which is
|
| 56 |
+
the right trade for a tool that rewrites user text — but if your application
|
| 57 |
+
prefers over-flagging to under-flagging, the model it replaces had higher recall.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
+
**Russian is the weak language.** +0.07 head-to-head where every other language
|
| 60 |
+
is +0.45 or better, and hivetrace F1 0.59 is the lowest real-text score we have.
|
| 61 |
|
| 62 |
+
**Organisation boundaries are imperfect.** On
|
| 63 |
+
`вадим бельский из клиники «Здоровье»` it returns `клиники` (the common noun
|
| 64 |
+
"clinic") rather than the quoted name `«Здоровье»`. It finds an organisation is
|
| 65 |
+
present; it does not always choose the right span.
|
| 66 |
|
| 67 |
+
**Trained only on synthetic data.** Entity pools are finite, so scores on
|
| 68 |
+
generated text overstate real-world ability — the same model scores 0.95 on
|
| 69 |
+
held-out synthetic and 0.59 on real Russian. Judge it on the external
|
| 70 |
+
benchmarks above, not the synthetic figure.
|
| 71 |
|
| 72 |
+
**Arabizi is a reconstruction.** No corpus contains it; its conventions
|
| 73 |
+
(3=ain, 7=haa, 2=hamza) are our model of how people type, not observed data.
|
| 74 |
+
|
| 75 |
+
## Use
|
| 76 |
+
|
| 77 |
+
Three files: `config.json`, `tokenizer.json`, `onnx/model_quantized.onnx`.
|
| 78 |
+
|
| 79 |
+
```python
|
| 80 |
+
import json, onnxruntime as ort
|
| 81 |
+
from transformers import AutoTokenizer
|
| 82 |
+
|
| 83 |
+
tok = AutoTokenizer.from_pretrained("ScienceSoft/scnsoft-pii-encoder")
|
| 84 |
+
cfg = json.load(open("config.json"))
|
| 85 |
+
id2label = {int(k): v for k, v in cfg["id2label"].items()}
|
| 86 |
+
sess = ort.InferenceSession("onnx/model_quantized.onnx",
|
| 87 |
+
providers=["CPUExecutionProvider"])
|
| 88 |
+
|
| 89 |
+
enc = tok(text, return_offsets_mapping=True, return_tensors="np",
|
| 90 |
+
truncation=True, max_length=256)
|
| 91 |
+
offsets = enc.pop("offset_mapping")[0]
|
| 92 |
+
logits = sess.run(None, {i.name: enc[i.name] for i in sess.get_inputs()})[0]
|
| 93 |
+
# argmax -> id2label -> merge BIO spans using `offsets` for character positions
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
Pair it with a regex/checksum layer for the structured identifiers it
|
| 97 |
+
deliberately ignores.
|
| 98 |
+
|
| 99 |
+
## Training data
|
| 100 |
+
|
| 101 |
+
`vadimbelsky/scnsoft-pii-synthetic-corpus` — 486,947 rows, fully synthetic, no
|
| 102 |
+
real person's data. Roughly 13% of rows contain no entity at all; those
|
| 103 |
+
entity-free negatives are what took `touch_rate` from 53.6% to 0.1%.
|
| 104 |
+
|
| 105 |
+
## Licence
|
| 106 |
+
|
| 107 |
+
Apache-2.0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onnx/model_quantized.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 278234412
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bc5329911105c3d4a0cb95c0c18823c6e2575866b085633decc51523327a2f3b
|
| 3 |
size 278234412
|
tokenizer.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 17082987
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a514807cffabd8abaf028cfaffe7ff0c4f60b97ea2db80c41f14172ae6b018ca
|
| 3 |
size 17082987
|