language: ko license: other license_name: schift-2.0 license_link: LICENSE library_name: transformers pipeline_tag: token-classification tags:
- pii
- korean
- ner
- privacy
- token-classification datasets:
- custom
schift-ko-pii
Korean PII detector. The model finds person names and addresses; phone, e-mail, resident/account numbers, URLs and secrets come from deterministic rules.
0.7.0 switches the default checkpoint to
schift-io/schift-ko-pii-ax-v1:
skt/A.X-Encoder-base (ModernBERT, 149M parameters)
fine-tuned as one BIOES tagger for private_person and private_address. Its repo declares
"layout": "joint" in schift_heads.json, which this release can read. The previous 40M hydra
checkpoint still loads with set_model_id("schift-io/schift-ko-pii-v7"), and gives the same results
as 0.6.0.
private_organization and general private_date are still not detected (see Labels below).
The base install does not install ko-pii; install the extended extra only
when those additional deterministic categories are needed.
Release status
This source tree prepares schift-ko-pii 0.7.1. The previously published
release was 0.7.0 (same checkpoint; 0.7.1 adds escaped-JSON input and masked
phone numbers, see CHANGELOG). The
Cloud Run ONNX service under services/pii is a separate deployment lane;
this package does not bundle its ONNX artifacts.
Quick start
pip install schift-ko-pii
Mask every detection with mask():
from schift_ko_pii import mask
print(mask("피고 김민수의 주소는 서울특별시 강남구 테헤란로 521이고 연락처는 010-1234-5678이다.")["masked"])
# 피고 [사람1]의 주소는 [주소1]이고 연락처는 [전화번호1]이다.
JSON works as a string, with or without ensure_ascii. Since 0.7.1 JSON-style
\uXXXX escapes are decoded for detection and the spans point back at the
escaped text, so the masked output is still valid JSON:
import json
record = {"name": "김민수", "phone": "010-1234-5678", "address": "서울특별시 강남구 테헤란로 521"}
print(mask(json.dumps(record, ensure_ascii=False))["masked"])
# {"name": "[사람1]", "phone": "[전화번호1]", "address": "[주소1]"}
print(mask(json.dumps(record))["masked"]) # escaped Korean, same result
# {"name": "[사람1]", "phone": "[전화번호1]", "address": "[주소1]"}
For positions only, use detect():
from schift_ko_pii import detect
for span in detect("피고 김민수의 주소는 서울특별시 강남구 테헤란로 521이고 연락처는 010-1234-5678이다."):
print(span["label"], span["start"], span["end"], span["text"])
# private_person 3 6 김민수
# private_address 12 30 서울특별시 강남구 테헤란로 521
# private_phone 38 51 010-1234-5678
Partly masked phone numbers (010-****-1234, 02-***-1234) are detected as
private_phone since 0.7.1.
analyze_text() below masks by risk policy, not every detection: in its default
mode (STRICT) a name on its own is not masked. Use mask() when every
detected span must be replaced.
For a typed operational result, use the selective-adoption flow:
from schift_ko_pii import AnalysisConfig, ProcessingMode, analyze_text
result = analyze_text(
"피고 김민수의 전화번호는 010-1234-5678이다.",
config=AnalysisConfig(mode=ProcessingMode.PERMISSIVE),
)
# The result contains typed detections, policy actions, BLOCK-only masking,
# counts, and a metadata-only review queue. It has no separate source-text
# field; its policy text can still preserve REVIEW/ALLOW spans for operators.
print(result.summary)
print(result.masking.masked_text)
print(result.review_items())
Selective-adoption flow
The public workflow is deliberately ordered:
detect -> assess -> BLOCK-only masking -> review queue
analyze_text() or analyze() runs detection, sends non-sensitive detection
metadata to assess(), and masks only spans whose action is Action.BLOCK.
Action.REVIEW detections remain unmasked and are represented by
ReviewItem values in PiiResult.review_queue; callers can create a typed
FeedbackPatch with propose_feedback_patch() without persisting raw PII.
Action.ALLOW detections are retained in the typed result but are not masked.
The resulting masking.masked_text is therefore a policy output, not a safe
untrusted-egress string: use a caller-owned all-span redaction step before
sending it to logs, external APIs, or other untrusted surfaces.
Detector confidence and operational risk are separate. ProcessingMode sets
the action thresholds:
| Mode | BLOCK threshold | REVIEW threshold |
|---|---|---|
AUDIT |
never blocks | all detections are allowed for audit output |
PERMISSIVE |
CRITICAL risk at score >= 0.95 |
HIGH risk at score >= 0.70 |
STRICT |
MEDIUM risk at score >= 0.70 |
LOW risk at score >= 0.50 |
BALANCED |
HIGH risk at score >= 0.80 |
MEDIUM risk at score >= 0.60 |
PARANOID |
LOW risk at score >= 0.50 |
all lower-risk detections |
PERMISSIVE is an action-policy choice, not a change to the v6 detector's
score_threshold. Use AnalysisConfig.score_threshold separately when
configuring detection.
Extended profiles (opt-in)
pip install "schift-ko-pii[extended]"
The optional adapter is enabled per request:
from schift_ko_pii import AnalysisConfig, analyze_text
result = analyze_text(
"사업자등록번호 104-81-49532, 직책 팀장",
config=AnalysisConfig(extended=True, extended_profile="contextual"),
)
extended_profile="structured" adopts deterministic identifier and anchor
categories such as business/corporate registration numbers, medical
insurance and prescription identifiers, PNU, postal code, fax, employee,
document, petition, and drug IDs. extended_profile="contextual" includes
that structured set plus contextual attributes such as nationality, birth
date, education, major, position, age, height, and weight.
The taxonomy registry is exposed through LABELS,
STRUCTURED_UPSTREAM_LABELS, CONTEXTUAL_UPSTREAM_LABELS,
EXCLUDED_UPSTREAM_LABELS, lookup_label(), label_for_upstream(), and
upstream_labels_for_profile(). The adapter excludes categories already
owned by the v6 detector or current Schift postprocessing, including person,
address, phone, email, existing structured identifiers, URLs, IPs, and legal
case references. Existing v6 spans win overlaps, except a generic
account_number span may be refined by a more specific extended label.
Masking boundaries
Masking is request-local and occurs only after policy assessment. Select a
MaskingStrategy in AnalysisConfig or call mask_text() directly with
typed MaskSpan values:
TOKEN: replace with a stable label token such as[PII_PHONE_1].REDACT: replace with[REDACTED].PARTIAL: retain a small leading/trailing portion for recognition.HASHED: replace with a deterministic local SHA-256 digest.
These strategies are output transformations, not custody. No strategy stores a reverse map, restores source values, or talks to Vault. Central Vault custody, retention, tenant isolation, KMS, and audit requirements remain a separate caller-side project.
Documents and the document-helper boundary
Document APIs accept already extracted text and provenance, not files:
from schift_ko_pii import (
ExtractedPageInput,
analyze,
from_pages,
)
document = from_pages(
(
ExtractedPageInput(page_num=1, text="첫 페이지", source="helper"),
ExtractedPageInput(page_num=2, text="둘째 페이지", source="helper"),
),
source_id="doc-123",
)
result = analyze(document)
from_text(), from_pages(), and from_document_helper() build the typed
text-only envelope. DocumentInput preserves the concatenated text and page
boundaries; SourceSpan and PageSpan preserve character offsets and page
provenance. scan_document() is the convenience scan over that envelope.
The package does not parse HWP/HWPX, DOCX, XLSX, PDF, or other file formats. Use the document-helper service (or another caller-owned parser) to produce a text-only envelope, then pass it to this package. Do not treat the envelope as file storage or a Vault integration.
Postprocessing and legacy API
Postprocessing is enabled by default for detect(). It applies Korean-specific
structured-ID validation, checksum checks where applicable, context-aware span
merging, and false-positive suppression for legal case numbers and statute
references. The legacy detect() path preserves original input text by
default; pass normalize=True when you want NFKC-normalized model input and
source-offset remapping. The typed analyze()/analyze_text() flow enables
that normalization by default. Pass postprocess=False for encoder heads
only (person, address, and organization).
Existing root exports remain available: detect, mask, apply, assess,
detect_extended, detect_extended_entities, Action, ProcessingMode,
RiskLevel, and ExtendedDependencyError.
For compatibility, AnonymizationResult is an alias of PiiResult, and both
anonymize_text and anonymize are aliases of analyze_text. They do not
introduce a second execution path.
API (free)
For production use without managing model files:
from schift import Schift
client = Schift(api_key="...") # free at schift.io
result = client.pii.redact("김민수의 전화번호는 010-1234-5678입니다.")
Labels
The stable local taxonomy is available as immutable TaxonomyEntry values in
LABELS. Common labels include:
| Label | Description | Examples |
|---|---|---|
private_person |
Person names | 김민수, 황보영희, Lee Jenny |
private_phone |
Phone numbers | 010-1234-5678, 02-1234-5678 |
private_email |
Email addresses | user@example.com |
private_address |
Street/postal addresses | 서울특별시 강남구 테헤란로 521 |
private_url |
URLs and IP addresses | instagram.com/user, 192.168.1.1 |
account_number |
Structured account/identity surfaces | 850205-1234567, M12345678 |
secret |
Secrets, API keys, passwords |
private_date and private_organization are declared in the taxonomy but
have no detector path in v7 (no regex rule, no model head) — see Release
status above.
Benchmark
The benchmark suite is included under benchmark/.
python benchmark/run_benchmark.py
python benchmark/run_benchmark.py --postprocess
python benchmark/run_benchmark.py --hf-model LiquidAI/LFM2.5-Encoder-350M-PII-Detector
Switching checkpoints
Which checkpoint this package loads is injected, not hardcoded — the model's
own schift_heads.json manifest declares its towers/labels, so this same pip
version can load any compatible checkpoint:
export SCHIFT_KO_PII_MODEL_ID="schift-io/schift-ko-pii-v6" # before first use
import schift_ko_pii
schift_ko_pii.set_model_id("schift-io/schift-ko-pii-v6") # switches at runtime
set_model_id() forces a reload on the next call. The environment variable
takes effect at import time; the function takes effect immediately.
Model details
- Checkpoint:
schift-io/schift-ko-pii-ax-v1(default since 0.7.0) - Architecture:
skt/A.X-Encoder-basebackbone (ModernBERT, 149M) + oneLinear(768, 9)head overOandB/I/E/S× {private_person,private_address} - Decode: complete BIOES sequences only; span score = lowest token probability.
Spans below the manifest's
min_score(0.475, calibrated at precision 0.95) are dropped. Adjacent spans are not merged (김진솔(김훈규)stays two names). - Training data:
schift-pii-bench-v4train split, synthetic forms and dialogue, and Korean government gazette OCR text labeled with written rules (masked names such as홍○동and lot-number cells count). See the model card for evaluation and known limitations. - Max length: 512 tokens per window (longer input is windowed with 64-token overlap)
Release benchmarks (postprocess on, CPU)
| Benchmark | Rows | ax-v1 F1 | v7 F1 |
|---|---|---|---|
benchmark_v1 |
93 | 0.931 | 0.872 |
benchmark_v1, rows not in ax-v1 training text |
37 | 0.894 | 0.829 |
benchmark_v3 |
473 | 0.871 | 0.812 |
benchmark_v3, rows not in ax-v1 training text |
220 | 0.855 | 0.794 |
56 of 93 benchmark_v1 rows and 253 of 473 benchmark_v3 rows also appear in ax-v1's training text, because schift-pii-bench-v4
contains them; the "not in training" rows are the fair comparison. Organization gold spans (182 in
benchmark_v3) are missed by both checkpoints.
License
Schift License v2.0 — Apache 2.0 base with a revenue threshold. Free for everyone under $10M annual revenue. Research, education, and non-profit use always permitted. Companies above the threshold: contact hello@schift.io.
Citation
@software{schift_ko_pii_2026,
author = {Schift Inc.},
title = {schift-ko-pii: Korean PII Detection Model},
year = {2026},
url = {https://huggingface.co/schift-io/schift-ko-pii-ax-v1},
}
Metadata
Release files for schift-ko-pii 0.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| schift_ko_pii-0.7.1.tar.gz | 169.5 kB | Without provenance | Details for schift_ko_pii-0.7.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| schift_ko_pii-0.7.1-py3-none-any.whl | Python 3 | none | any | Details for schift_ko_pii-0.7.1-py3-none-any.whl |
Total release size: 222.0 kB
Release files / schift_ko_pii-0.7.1.tar.gz
| Download URL | schift_ko_pii-0.7.1.tar.gz |
|---|---|
| Size | 169.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf6d53e9af67942b6df7e4729fa0b1c06617beb5a6475903e40d670617a00333
|
|
BLAKE2b-256 checksum How to use checksums |
baafba1375c6515ff9584245dacc0c61ee952fa6920a56ad6612a54751b10fe5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Release files / schift_ko_pii-0.7.1-py3-none-any.whl
| Download URL | schift_ko_pii-0.7.1-py3-none-any.whl |
|---|---|
| Size | 52.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d015c2cd8de09a00cf4a24af80a994d6cdfe05d8b8d6ec7afda16f74dc24810d
|
|
BLAKE2b-256 checksum How to use checksums |
a7ccf55a140391fc5a7892b3aebe97e21fa66b26e790847b78790be904fe49e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Security for schift-ko-pii 0.7.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.