1from transformers import pipeline
2
3# Load the PII detection pipeline
4ner = pipeline("ner", model="OpenMed/OpenMed-PII-Korean-QwenMed-600M-v1", aggregation_strategy="simple")
5
6text = """
7환자 이영희 (생년월일: 1985/03/15, 주민등록번호: 850315-9876543) 오늘 진료함.
8연락처: lee.yh@email.kr, 전화: +82 10-1234-5678.
9주소: 서울시 서초구 반포대로 123.
10"""
11
12entities = ner(text)
13for entity in entities:
14 print(f"{entity['entity_group']}: {entity['word']} (score: {entity['score']:.3f})")
1def redact_pii(text, entities, placeholder='[REDACTED]'):
2 """Replace detected PII with placeholders."""
3 # Sort entities by start position (descending) to preserve offsets
4 sorted_entities = sorted(entities, key=lambda x: x['start'], reverse=True)
5 redacted = text
6 for ent in sorted_entities:
7 redacted = redacted[:ent['start']] + f"[{ent['entity_group']}]" + redacted[ent['end']:]
8 return redacted
9
10# Apply de-identification
11redacted_text = redact_pii(text, entities)
12print(redacted_text)
1from transformers import AutoModelForTokenClassification, AutoTokenizer
2import torch
3
4model_name = "OpenMed/OpenMed-PII-Korean-QwenMed-600M-v1"
5model = AutoModelForTokenClassification.from_pretrained(model_name)
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7
8texts = [
9 "환자 이영희 (생년월일: 1985/03/15, 주민등록번호: 850315-9876543) 오늘 진료함.",
10 "연락처: lee.yh@email.kr, 전화: +82 10-1234-5678.",
11]
12
13inputs = tokenizer(texts, return_tensors='pt', padding=True, truncation=True)
14with torch.no_grad():
15 outputs = model(**inputs)
16 predictions = torch.argmax(outputs.logits, dim=-1)
-
AI4Privacy PII Masking 200K: Multilingual base dataset (200K records across 8 languages)
-
NVIDIA Nemotron-PII: Seed dataset for synthetic data generation
-
Synthetic Korean Data: ~25K high-quality samples generated with locale-specific formatting (주민등록번호 format, +82 phones, Korean names, ₩ currency)
-
Format: BIO-tagged token classification
-
Labels: 76 BIO tags (54 entity types)
1@misc{openmed-pii-2026,
2 title = {OpenMed-PII-Korean-QwenMed-600M-v1: Korean PII Detection Model},
3 author = {OpenMed Science},
4 year = {2026},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/OpenMed/OpenMed-PII-Korean-QwenMed-600M-v1}
7}