PII detector for Chinese, Japanese, Korean & English (small)

A small (≈140M params), Apache-2.0 model that finds and labels personal data in 中文 / 日本語 / 한국어 / English text — names, phone numbers, national ID numbers (身份证), bank cards, emails, addresses, dates and 20 entity types in total. Fast enough for CPU, ships ONNX (fp32 + int8) for Optimum / ONNX Runtime / transformers.js (browser, Node).

开源小模型:检测并脱敏中、日、韩、英文本中的个人信息(姓名、手机号、身份证号、银行卡号、邮箱、地址、日期等 20 类)。 约 1.4 亿参数,CPU 即可运行,提供 ONNX(可在浏览器中运行)。适用于大模型数据清洗、日志脱敏、客服对话脱敏、《个人信息保护法》(PIPL) 合规等场景。

👉 Try it (runs 100% in your browser, text never leaves the page): live demo

Why this model

  • CJK-first. Most open PII models are English/European. Existing Chinese PII models are 278M–600M params; this one is ~140M with a tokenizer that splits Chinese finely, so 张伟 → 张 SURNAME + 伟 GIVENNAME works.
  • Real Chinese formats. Public multilingual PII data uses foreign-style identifiers even in Chinese text. We add a reproducible generator of mainland-format PII (18-digit 身份证 with valid checksum, 1[3-9] mobiles, landlines, UnionPay cards with Luhn checksum, 统一社会信用代码, 省/市/区/路/号 addresses, 护照号) and evaluate on held-out sentence templates.
  • Permissive. Apache-2.0 weights; trained only on CC-BY-4.0 and self-generated synthetic data (no real personal data).

Quick start

from transformers import pipeline

pii = pipeline("token-classification", model="CheezOne/pii-detector-cjk-small", aggregation_strategy="simple")
text = "收件人:王小明,手机:13812345678,地址:上海市浦东新区世纪大道100号,身份证号110101199003071234。"
for e in pii(text):
    print(e["entity_group"], text[e["start"]:e["end"]], round(e["score"], 3))

Redact:

def redact(text, min_score=0.5):
    out, last = [], 0
    for e in sorted(pii(text), key=lambda e: e["start"]):
        if e["score"] < min_score: continue
        out += [text[last:e["start"]], f"[{e['entity_group']}]"]; last = e["end"]
    return "".join(out + [text[last:]])

print(redact("您好,李女士,您的银行卡6222021234567890128已绑定。"))
# 您好,[SURNAME][TITLE],您的银行卡[CREDITCARDNUMBER]已绑定。

ONNX Runtime via Optimum:

from optimum.onnxruntime import ORTModelForTokenClassification
from transformers import AutoTokenizer, pipeline
model = ORTModelForTokenClassification.from_pretrained("CheezOne/pii-detector-cjk-small", subfolder="onnx", file_name="model_quantized.onnx")
pii = pipeline("token-classification", model=model, tokenizer=AutoTokenizer.from_pretrained("CheezOne/pii-detector-cjk-small"), aggregation_strategy="simple")

transformers.js (browser / Node, int8 ONNX, ~230 MB download, cached):

import { pipeline } from "@huggingface/transformers";
const pii = await pipeline("token-classification", "CheezOne/pii-detector-cjk-small", { dtype: "q8" });
console.log(await pii("山田太郎様の電話番号は090-1234-5678です。"));  // per-token BIO labels

transformers.js' pipeline returns per-token labels without character offsets. For entity spans and redaction, use pii.js from the demo Space (~70 lines: token→char alignment, BIO grouping, email regex backstop, redact()).

Reality check: documents written in other styles

The F1 scores in the label table below come from test sets built with the same templates/generators as the training data, so they are optimistic. We also ran the standard pipeline (aggregation_strategy="simple", exactly the Quick-start code) on 703 Chinese/Japanese/Korean/English documents written by an LLM in other styles (invitations, chats, forms, tickets…), with PII slots filled programmatically so the gold spans are exact. This is closer to what you will see on your own data. Overall exact-span recall is 58.4% and precision is 62.4%.

entity n exact recall % exact precision %
SURNAME 575 64.3 83.0
GIVENNAME 526 62.9 57.8
TITLE 465 9.0 51.9
DATE 251 63.7 68.1
CITY 183 63.4 52.5
BUILDINGNUM 165 55.2 38.4
STREET 162 73.5 58.9
TELEPHONENUM 157 95.5 80.2
EMAIL 130 91.5 89.5
ZIPCODE 93 81.7 69.7
TIME 73 68.5 63.3
IDCARDNUM 47 46.8 95.7
SEX 38 42.1 80.0
CREDITCARDNUMBER 37 75.7 58.3
SOCIALNUM 29 65.5 33.9
PASSPORTNUM 28 71.4 58.8
AGE 27 96.3 44.1
DRIVERLICENSENUM 24 50.0 22.6
TAXNUM 20 10.0 6.7

Known issues on this set:

  • Emails at example.com-style domains lose the domain part. Other domains are fine.
  • Surnames are often missed when the name is not followed by a title.
  • TITLE boundaries (e.g. whether 先生 / 様 is tagged) do not match this set's convention, which explains part of the low score.
  • Do not use aggregation_strategy="first" or "max": they rely on word boundaries and merge or drop CJK spans. Use "simple".

For redaction, structured IDs work well (phone 95.5%, email 91.5% exact). Names and addresses need a review step. Data: eval/pii_pipeline_exact.json; script: scripts/pii_pipeline_eval.py.

Labels (BIO, 20 entity types)

Label Meaning F1 openpii F1 zh-realistic
GIVENNAME given name / 名 94.4 98.3
SURNAME surname / 姓 93.4 98.8
TITLE title, honorific (先生, 様, Mr.) 99.1 –
DATE date 99.9 80.0
TIME time 97.5 90.5
AGE age 97.4 100.0
SEX sex 93.9 100.0
GENDER gender identity 93.7 –
EMAIL email 99.1 100.0
TELEPHONENUM phone number 97.3 100.0
CITY city / district 94.9 100.0
STREET street 93.6 100.0
BUILDINGNUM building / house / room number 98.9 97.5
ZIPCODE postal code 99.8 –
IDCARDNUM national ID (e.g. 身份证) 83.3 100.0
PASSPORTNUM passport no. 99.0 100.0
DRIVERLICENSENUM driver licence no. 83.3 –
TAXNUM tax ID / 统一社会信用代码 98.9 –
SOCIALNUM social security no. 98.8 100.0
CREDITCARDNUMBER bank / credit card no. 99.0 100.0

Evaluation

Entity F1 = exact character-span + label match. Redaction recall = share of PII characters that get masked by any label (what matters when you just want PII removed).

Language Test set Precision Recall F1 Redaction recall Entities
English openpii (synthetic, mixed formats) 93.5 95.1 94.3 99.9 7493
Japanese 日本語 openpii (synthetic, mixed formats) 96.1 96.6 96.4 99.8 7704
Korean 한국어 openpii (synthetic, mixed formats) 97.2 97.7 97.4 99.7 7160
Chinese 中文 openpii (synthetic, mixed formats) 96.2 96.9 96.5 99.8 6995
Chinese 中文 realistic mainland formats, held-out templates 98.1 97.6 97.8 99.6 8555

Comparison with other open PII models (label-agnostic)

Same test sets, each model run through the stock pipeline(..., aggregation_strategy="simple"); character-level redaction recall/precision so different label sets are comparable (script). Numbers are % (higher is better).

Model zh-realistic recall zh-realistic precision openpii zh recall ja recall ko recall en recall
CheezOne/pii-detector-cjk-small (this model, ~140M) 99.6 100.0 100.0 100.0 99.9 99.9
OpenMed/OpenMed-PII-Chinese-BigMed-Large-278M-v1 94.7 96.2 75.2 74.6 75.3 76.2
Wismut/nym-pii-multilingual 95.3 99.4 91.5 92.1 91.3 91.2
iiiorg/piiranha-v1-detect-personal-information 57.9 99.5 69.8 68.7 74.6 76.8

Caveat: the openpii test split comes from the same distribution as our training data, which favours this model; the zh-realistic set uses templates never seen in training but was written by us. Please evaluate on your own data.

ONNX

File Size F1 (zh-realistic subset) Redaction recall CPU latency (bs=1, 4 vCPU)
onnx/model.onnx (fp32) 563 MB 97.8 99.6 44 ms
onnx/model_quantized.onnx (int8 emb+attention) 230 MB 97.9 99.6 41 ms

int8 recipe: per-channel dynamic quantization of embeddings + attention only; MLPs and head stay fp32 (full int8 cost ~8 F1 points on this architecture — see scripts/quant_sweep.py).

Use cases

  • LLM / agent privacy guard: replace PII with placeholders locally before text goes to a cloud LLM, then restore them in the reply; scrub agent memory, tool outputs and logs.
  • Training-data cleaning: remove PII from pre-training / fine-tuning corpora.
  • Logs & customer-service transcripts, data sharing with vendors/annotators, PIPL / APPI / PIPA de-identification.
  • In-browser checks (ONNX + transformers.js): warn users before they paste ID numbers into a chatbot — nothing leaves the device.

The model detects; you decide what to mask. Labels are fine-grained on purpose: e.g. keep SEX/AGE for medical statistics but mask names and IDs, or mask everything (including quasi-identifiers like sex + birth date + ZIP) before publishing data.

Languages

Supported (trained & evaluated): Chinese, Japanese, Korean, English. The base model is massively multilingual, and on openpii's other 26 languages (bg cs da de el es et fi fr hr hu id it lt lv ms nl pl pt ro sk sl sr sv tl vi) the model works well zero-shot — but this is measured on data from the same generator as our training set, so treat other languages as unofficial and validate on your own data.

30-language benchmark (openpii validation, 150 examples/language, char-level redaction %)

Model zh ja ko en 26 other languages (avg recall / precision) ms/example (4 vCPU)
this model (140M) 99.9 99.9 99.9 99.9 97.9 / 99.3 93
nym-pii-multilingual (308M) 92.6 94.5 93.0 90.6 93.5 / 98.2 215
OpenMed-PII-Chinese (278M) 76.2 76.0 72.2 72.5 71.9 / 80.3 132
piiranha-v1 (278M) 69.8 69.6 77.4 75.3 77.2 / 98.8 279

Caveat: openpii is in-distribution for this model (we trained on its zh/ja/ko/en train split), which inflates our margin. On hand-written sentences (below), this model and nym-pii-multilingual are roughly on par; both are far ahead of the other two.

Side-by-side examples (hand-written, not from any dataset)

Stock pipeline(..., aggregation_strategy="simple"), score ≥ 0.5. Full outputs for 25 sentences: eval/case_study.json, eval/case_study_multilingual.json.

[zh] 老王,我新换的号码是 15921876543,以后打这个。我身份证是 320102198811052418,帮我订一下周六去杭州的高铁票。

Model Output
pii-detector-cjk-small (this model) 老王,我新换的号码是 [TELEPHONENUM],以后打这个。我身份证是 [IDCARDNUM],帮我订一下周六去杭州的高铁票。
OpenMed-PII-Chinese-BigMed-Large-278M-v1 [LASTNAME][LASTNAME],我新换的号码是 15921876543,以后打这个。我身份证是 320102198811052418,帮我订一下周六去杭州的高铁票。
nym-pii-multilingual 老王,我新换的号码是 [PHONE],以后打这个。我身份证是 [SSN],帮我订一下周六去杭州的高铁票。
piiranha-v1-detect-personal-information 老王,我新换的号码是 15921876543,以后打这个。我身份证是 320102198811052418,帮我订一下周六去[CITY]的高铁票。

[zh] 陈总您好,新同事刘一鸣(男,29岁)将于2026年12月1日入职,工资卡为招商银行 6225 8812 3456 7890,邮箱 liuyiming@foxmail.com。

Model Output
pii-detector-cjk-small (this model) 陈总您好,新同事[SURNAME][GIVENNAME]([SEX],[AGE]岁)将于[DATE]入职,工资卡为招商银行 [CREDITCARDNUMBER],邮箱 [EMAIL]。
OpenMed-PII-Chinese-BigMed-Large-278M-v1 [LASTNAME][LASTNAME]您好,新同事[LASTNAME][FIRSTNAME]鸣(男,[AGE])将于[DATE]入职,工资卡为招商银行 6225 8812 3456 7890,邮箱 liuyiming@foxmail.com。
nym-pii-multilingual 陈总您好,新同事[SURNAME][GIVEN_NAME]([GENDER],[AGE]岁)将于2026年12月1日入职,工资卡为[COMPANY_NAME][CREDIT_DEBIT_CARD],邮箱 [EMAIL]。
piiranha-v1-detect-personal-information 陈总您好,新同事[GIVENNAME](男,29岁)将于2026年12月1日入职,工资卡为招商银行 [CREDITCARDNUMBER],邮箱 [EMAIL]。

[zh] 原告孙建国,男,1972年3月8日出生,汉族,住成都市武侯区人民南路四段27号,公民身份号码510107197203081234。

Model Output
pii-detector-cjk-small (this model) 原告[SURNAME][GIVENNAME],[SEX],[DATE]出生,汉族,住[CITY][STREET][BUILDINGNUM][BUILDINGNUM],公民身份号码[IDCARDNUM]。
OpenMed-PII-Chinese-BigMed-Large-278M-v1 原告[LASTNAME][FIRSTNAME][FIRSTNAME],男,1972年3月8日出生,汉族,住[STREET],公民身份号码510107197203081234。
nym-pii-multilingual 原告[SURNAME][GIVEN_NAME],[GENDER],[DATE_OF_BIRTH]出生,[COUNTRY],住[CITY][STREET_NAME][CITY][STREET_NAME][STREET_ADDRESS][BUILDING_NUMBER],公民身份号码[SSN]。
piiranha-v1-detect-personal-information 原告[GIVENNAME],男,[DATEOFBIRTH]出生,汉族,住[CITY][BUILDINGNUM]号,公民身份号码510107197203081234。

[ja] お届け先:〒530-0001 大阪府大阪市北区梅田3-1-1、高橋健太様、電話 06-6345-7788

Model Output
pii-detector-cjk-small (this model) お届け先:〒[ZIPCODE] 大阪府[CITY][STREET][BUILDINGNUM]、[SURNAME][GIVENNAME]様、電話 [TELEPHONENUM]
nym-pii-multilingual お届け先:〒[ZIP_CODE] [CITY][CITY][STREET_NAME][BUILDING_NUMBER]、[SURNAME][GIVEN_NAME]様、電話 [PHONE]
OpenMed-PII-Chinese-BigMed-Large-278M-v1 お届け先:〒530-0001 大阪府大阪市北区梅田3-1[BUILDINGNUMBER]、[LASTNAME][LASTNAME]健[FIRSTNAME]様、電話 [PHONE]
piiranha-v1-detect-personal-information お届け先:〒[ZIPCODE]-0001 [CITY][BUILDINGNUM]、[SURNAME]様、電話 06-6345-7788

[ko] 환자 정민호(남, 52세), 주민등록번호 720315-1234567, 연락처 010-3344-5566.

Model Output
pii-detector-cjk-small (this model) 환자 [SURNAME][GIVENNAME]([SEX], [AGE]세), 주민등록번호 [TAXNUM], 연락처 [TELEPHONENUM].
nym-pii-multilingual 환자 [GIVEN_NAME]([GENDER], [AGE]세), 주민등록번호 [SSN], 연락처 [PHONE].
OpenMed-PII-Chinese-BigMed-Large-278M-v1 환자 [LASTNAME][FIRSTNAME]호(남, 52세), 주민등록번호 720315-1234567, 연락처 [PHONE]10-3344-5566.
piiranha-v1-detect-personal-information 환자 [GIVENNAME](남, 52세), 주민등록번호 [TAXNUM], 연락처 [TELEPHONENUM]

[en] Ship to: Robert Kim, 1600 Amphitheatre Pkwy, Mountain View, CA 94043. Passport no. X12345678.

Model Output
pii-detector-cjk-small (this model) Ship to: [GIVENNAME] [SURNAME], [BUILDINGNUM] [STREET], [CITY], CA [ZIPCODE]. Passport no. [PASSPORTNUM].
nym-pii-multilingual Ship to: [GIVEN_NAME] [SURNAME], [STREET_ADDRESS], [CITY], [STATE] [ZIP_CODE]. Passport no. [PASSPORT].
OpenMed-PII-Chinese-BigMed-Large-278M-v1 Ship to: Robert Kim, 1600 Amphitheatre Pkwy, Mountain View, CA 94043. Passport no. X12345678.
piiranha-v1-detect-personal-information Ship to: Robert Kim, [BUILDINGNUM] [STREET], [CITY], CA [ZIPCODE]. Passport no. X12345678.

[de] Herr Lukas Schneider, geboren am 03.07.1985, wohnhaft in der Hauptstraße 12, 10115 Berlin, Tel. 030 1234567.

Model Output
pii-detector-cjk-small (this model) [TITLE] [GIVENNAME] [SURNAME], geboren am [DATE], wohnhaft in der [STREET] [BUILDINGNUM], [ZIPCODE] [CITY], Tel. [TELEPHONENUM].
nym-pii-multilingual Herr [GIVEN_NAME] [SURNAME], geboren am [DATE_OF_BIRTH], wohnhaft in der [STREET_NAME] [BUILDING_NUMBER], [ZIP_CODE] [CITY], Tel. [PHONE].
OpenMed-PII-Chinese-BigMed-Large-278M-v1 [LASTNAME] Lukas Schneider, geboren am 03.07.1985, wohnhaft in der Hauptstraße 12, 10115 Berlin, [PHONE]. [PHONE]30 1234567.
piiranha-v1-detect-personal-information Herr Lukas Schneider, geboren am [DATEOFBIRTH], wohnhaft in der [STREET] [BUILDINGNUM] [ZIPCODE] Berlin, Tel. 030 1234567.

Training

  • Base: jhu-clsp/mmBERT-small (ModernBERT architecture, 1800+ languages). Chosen because its tokenizer splits Chinese finely: only 0.01% of entity boundaries fall inside a token on realistic Chinese text, vs 6.2% for multilingual-e5-small.
  • Data (142,941 examples): ai4privacy/pii-masking-openpii-1.5m zh 20,962 / ja 20,754 / ko 21,225 / en 40,000 (subsample), plus 40,000 generated realistic-Chinese examples (gen_zh_realistic.py --seed 2 --templates train_v11).
  • 1 epoch, batch 32, lr 8e-5 linear decay (6% warmup), max length 256, embeddings frozen, bf16 autocast, on a 64-core CPU runner (~1 h). No GPU was used.

What mattered: context diversity in the Chinese data (v1 → v1.1)

Version Chinese synthetic data openpii F1 zh-realistic (held-out templates) F1 zh redaction recall
v1 20k, 11 fixed templates 0.963 0.747 94.9%
v1.1 (this release) 40k, + randomized key-value forms (varied field names/order/separators) and mixed-ID narratives 0.961 0.978 99.6%

With few templates the model overfit openpii's foreign-style identifier conventions and fragmented 18-digit 身份证 numbers (mmBERT tokenizes digits one by one) into ID/tax/card pieces. Varying the contexts fixed this.

Full reproduction:

python scripts/prep_openpii.py <openpii_dir> data/prepared
python scripts/gen_zh_realistic.py data/prepared/zh_real_train_v11.jsonl --n 40000 --seed 2 --templates train_v11
python scripts/gen_zh_realistic.py data/prepared/zh_real_test.jsonl --n 1000 --seed 999 --templates heldout
python scripts/train.py --base jhu-clsp/mmBERT-small --train data/prepared/openpii_train.jsonl data/prepared/zh_real_train_v11.jsonl   --eval data/prepared/openpii_test.jsonl data/prepared/zh_real_test.jsonl --out runs/v11 --epochs 1 --bs 32 --lr 8e-5 --freeze-emb
python scripts/export_onnx.py runs/v11 --test data/prepared/zh_real_test.jsonl
python scripts/bench_redaction.py runs/v11 data/prepared/zh_real_test.jsonl data/prepared/openpii_test.jsonl

Limitations

  • Trained on synthetic text. Real documents (OCR output, chat slang, mixed scripts) will be harder; always measure on your own data and keep a human in the loop for compliance-critical use.
  • Not covered: organisation names, IP/URLs, usernames/passwords, bank account names, medical data. Combine with regexes for strictly formatted IDs if you need guaranteed recall.
  • SEX vs GENDER and SOCIALNUM vs IDCARDNUM are often confused (they look alike); merge them if your use case allows.
  • Japanese and Korean identifiers follow openpii's synthetic formats; realistic-format generators for ja/ko are planned.
  • Max 512 tokens per call (split long documents).
  • With aggregation_strategy="simple", English/Korean entities may include a leading space (strip text[start:end]); emails with unusual TLDs are occasionally cut short.

License & attribution

Model: Apache-2.0. Training data includes OpenPII 1.5M by Ai4Privacy / Ai Suisse SA (CC-BY-4.0) — https://huggingface.co/datasets/ai4privacy/pii-masking-openpii-1.5m. Base model mmBERT-small (MIT).

Citation

@misc{cheezone_pii_cjk_2026,
  title  = {PII detector for Chinese, Japanese, Korean and English (small)},
  author = {CheezOne},
  year   = {2026},
  url    = {https://huggingface.co/CheezOne/pii-detector-cjk-small}
}

Use it in your project

  • Model id (paste as-is): CheezOne/pii-detector-cjk-small
  • License: Apache-2.0 (see LICENSE). You may depend on it, redistribute it and fine-tune it, including commercially. Please keep the attribution.
  • If this model helps your project, a mention of the model id in your README lets other people find it.
@misc{cheezone_pii_detector_chinese_japanese_korean_eng,
  title  = {Small PII detector for Chinese, Japanese, Korean and English},
  author = {CheezOne},
  year   = {2026},
  howpublished = {\url{https://huggingface.co/CheezOne/pii-detector-cjk-small}}
}

More from CheezOne

Small open models for Chinese / Japanese / Korean / English apps. All of them run on CPU, and most in the browser.

Downloads last month
-
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 CheezOne/pii-detector-cjk-small

Quantized
(336)
this model

Datasets used to train CheezOne/pii-detector-cjk-small

Space using CheezOne/pii-detector-cjk-small 1

Collections including CheezOne/pii-detector-cjk-small

Evaluation results

  • entity F1 (exact span) on openpii-1.5m validation (zh/ja/ko/en
    self-reported
    0.961
  • entity F1 (exact span) on realistic Chinese PII (held-out templates)
    self-reported
    0.978