Japan Open Data Lab の「日本語AIモデル部品シリーズ」の1つです。シリーズ一覧は サイトのモデルページ と プロフィール にあります。
A small (111M parameters) encoder model that detects 18 types of personally identifiable information (PII) in Japanese text and returns exact character spans. CPU-friendly, ONNX included, Apache 2.0. No real personal data was used for training or evaluation — all data is synthetic.
日本語の文章から18種類の個人情報を文字位置つきで検出する小規模モデルです。 学習と評価に実在の個人情報は使っていません(すべて合成データ)。
Given Japanese text, the model returns character spans for these labels:
PERSON, ORGANIZATION, ADDRESS, POSTAL_CODE, PHONE, EMAIL, DATE_OF_BIRTH, MY_NUMBER, BANK_ACCOUNT, CREDIT_CARD, DRIVER_LICENSE, PASSPORT, HEALTH_INSURANCE, EMPLOYEE_ID, IP_ADDRESS, URL_PERSONAL, USERNAME, SECRET
The model only detects. Masking/replacement is up to you — see redact.py
in this repository for a ready-made helper.
With transformers:
from transformers import pipeline
ner = pipeline("token-classification",
model="japan-opendata/ja-pii-ner-v1",
aggregation_strategy="simple")
print(ner("担当は山田太郎(電話 090-1234-5678)です。"))
For production use (span merging, long-document chunking, masking), use the
bundled single-file helper — no external calls, only transformers + torch:
from redact import redact
redact("連絡先は taro.yamada@example.com です")
# -> '連絡先は <EMAIL> です'
With ONNX Runtime only (no PyTorch), see examples/onnx_example.py.
For Microsoft Presidio, see presidio_recognizer.py: a custom recognizer
that returns character offsets directly from the model, avoiding the
spaCy-tokenization alignment problems of the stock TransformersNlpEngine
for Japanese.
Test set: the full test split of nvidia/Nemotron-PII-Japan converted to character spans (10,001 documents, 43,064 gold spans), plus a separately generated no-PII set of 2,068 documents. Threshold-free BIO argmax decoding; no tuning was done against the test set.
Overall:
| Metric | Value |
|---|---|
| Precision (micro) | 0.9965 |
| Recall (micro) | 0.9582 |
| F1 (micro) | 0.9770 |
| False-positive rate on no-PII documents | 0.0000 (0 / 2,068 documents) |
Per label (Precision / Recall / F1):
| Label | P | R | F1 |
|---|---|---|---|
| PERSON | 0.9987 | 0.9577 | 0.9778 |
| ORGANIZATION | 0.9918 | 0.8790 | 0.9320 |
| ADDRESS | 0.9919 | 0.9610 | 0.9762 |
| POSTAL_CODE | 1.0000 | 1.0000 | 1.0000 |
| PHONE | 0.9951 | 0.9562 | 0.9753 |
| 1.0000 | 1.0000 | 1.0000 | |
| DATE_OF_BIRTH | 1.0000 | 1.0000 | 1.0000 |
| MY_NUMBER | 1.0000 | 1.0000 | 1.0000 |
| BANK_ACCOUNT | 1.0000 | 1.0000 | 1.0000 |
| CREDIT_CARD | 1.0000 | 1.0000 | 1.0000 |
| HEALTH_INSURANCE | 1.0000 | 1.0000 | 1.0000 |
| EMPLOYEE_ID | 0.9992 | 0.9990 | 0.9991 |
| IP_ADDRESS | 0.9984 | 0.9984 | 0.9984 |
| URL_PERSONAL | 1.0000 | 1.0000 | 1.0000 |
| USERNAME | 0.9989 | 0.9978 | 0.9984 |
| SECRET | 0.9620 | 0.8000 | 0.8736 |
DRIVER_LICENSE and PASSPORT have no gold spans in this test set (the source dataset does not contain them; they are supplied only by our synthetic data), so they are not evaluated by the numbers above.
CPU speed (Intel i7-11700F, 200 documents, mean per document):
| Runtime | ms/doc | docs/sec |
|---|---|---|
| PyTorch (fp32) | 813.96 | 1.23 |
| ONNX (fp32) | 224.16 | 4.46 |
The ONNX fp32 export reproduces the PyTorch model exactly on the full test set (identical TP/FP/FN on every label).
INT8 note: dynamic INT8 quantization was measured (188 MB, 122 ms/doc) but is not shipped in v1 — micro F1 dropped to 0.8988, with large recall losses on numeric/symbol pattern labels (IP_ADDRESS, URL_PERSONAL, SECRET, BANK_ACCOUNT). Static INT8 quantization degraded the model entirely. fp32 is the supported configuration.
az225/privacy-masker-ja-pii-ner-30m was evaluated on the identical test set. Only 3 of its labels map 1-to-1 to ours (PERSON, ORGANIZATION, ADDRESS; 24,149 gold spans), so the comparison is restricted to those:
| Model | P | R | F1 (3 labels) |
|---|---|---|---|
| ja-pii-ner-v1 | 0.9947 | 0.9325 | 0.9626 |
| az225/privacy-masker-ja-pii-ner-30m | 0.6343 | 0.6809 | 0.6568 |
Read this with care: the label definitions differ. az225 splits place names into a separate LOCATION label; counting LOCATION as ADDRESS raises its ADDRESS recall to 0.9821. Its PERSON recall (0.9961) is higher than ours (0.9577). The gap above is partly a definitions gap, not only a quality gap.
Base model: tohoku-nlp/bert-base-japanese-v3. Trained for 3 epochs on 104,998 documents.
redact.py for long documents.Apache 2.0. The training data licenses are listed above; the base model is distributed under its own terms by its authors.
onnx/model.onnx 443 MBmodel.safetensors 443 MB