Token Classification
Transformers
ONNX
Safetensors
Transformers.js
modernbert
pii
pii-detection
ner
privacy
anonymization
redaction
de-identification
chinese
japanese
korean
cjk
mmbert
个人信息
脱敏
Eval Results (legacy)
Instructions to use CheezOne/pii-detector-cjk-small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CheezOne/pii-detector-cjk-small with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="CheezOne/pii-detector-cjk-small")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("CheezOne/pii-detector-cjk-small") model = AutoModelForTokenClassification.from_pretrained("CheezOne/pii-detector-cjk-small", device_map="auto") - Transformers.js
How to use CheezOne/pii-detector-cjk-small with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('token-classification', 'CheezOne/pii-detector-cjk-small'); - Notebooks
- Google Colab
- Kaggle
Download scripts/card_extra.py from CheezOne/pii-detector-cjk-small: direct link, hf CLI and curl.
- Browser
- Download file 3.57 kB
-
https://huggingface.co/CheezOne/pii-detector-cjk-small/resolve/main/scripts/card_extra.py
- Command line
-
hf download hf://CheezOne/pii-detector-cjk-small/scripts/card_extra.py
-
curl -L -o card_extra.py https://huggingface.co/CheezOne/pii-detector-cjk-small/resolve/main/scripts/card_extra.py
3.57 kB
| """Render extra model-card sections (30-language benchmark + side-by-side cases) from eval JSONs. | |
| Usage: python card_extra.py <out.md>""" | |
| import json, sys | |
| NAMES = [("CheezOne_pii-detector-zh-ja-ko-en", "**this model** (140M)"), ("Wismut_nym-pii-multilingual", "nym-pii-multilingual (308M)"), | |
| ("OpenMed_OpenMed-PII-Chinese-BigMed-Large-278M-v1", "OpenMed-PII-Chinese (278M)"), ("iiiorg_piiranha-v1-detect-personal-information", "piiranha-v1 (278M)")] | |
| R = {n: json.load(open(f"eval/ml30_{k}.json"))["multilingual_test.jsonl"] for k, n in NAMES} | |
| core = ["zh", "ja", "ko", "en"]; other = sorted(l for l in R[NAMES[0][1]] if l not in core + ["all"]) | |
| avg = lambda r, ls, k: 100 * sum(r[l][k] for l in ls) / len(ls) | |
| o = ["## 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) |", "|---|---|---|---|---|---|---|"] | |
| for _, n in NAMES: | |
| r = R[n] | |
| o.append(f"| {n} | " + " | ".join(f"{100*r[l]['redact_recall']:.1f}" for l in core) + | |
| f" | {avg(r, other, 'redact_recall'):.1f} / {avg(r, other, 'redact_precision'):.1f} | {r['all']['ms_per_example']:.0f} |") | |
| o += ["", "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`.", ""] | |
| cs = [("eval/case_study.json", [0, 2, 4]), ("eval/case_study_multilingual.json", [1, 3, 7, 9])] | |
| for path, idx in cs: | |
| d = json.load(open(path)); models = list(d["models"]) | |
| for i in idx: | |
| c = d["cases"][i] | |
| o += [f"**[{c['lang']}] {c['text']}**", "", "| Model | Output |", "|---|---|"] | |
| for m in models: | |
| o.append(f"| {m.split('/')[-1]} | {d['models'][m][i]['redacted'].replace('|', '/')} |") | |
| o.append("") | |
| open(sys.argv[1], "w").write("\n".join(o) + "\n") | |