본문으로 건너뛰기
Skillpedia
보안5.8k · #14707

generating-synthetic-surrogates

하는 일

이 스킬은 임상 텍스트의 환자 식별자를 유형에 맞는 현실적인 가짜 값으로 바꿉니다. 예를 들어 실제 이름 대신 가짜 이름을 넣습니다. 텍스트는 자연스럽게 읽히고 다른 도구도 여전히 파싱할 수 있습니다. 자연스럽고 안전한 텍스트가 필요한 팀을 위한 스킬입니다.

사용하는 경우

  • ✓비식별화된 노트가 가림 표시로 가득하지 않고 자연스럽고 읽기 쉬워야 할 때.
  • ✓학습용이나 시연용 텍스트에 문서 전체에서 일관된 가짜 신원이 필요할 때.
  • ✓진료기록번호 형식처럼 맞춤 대체 형식이 필요할 때.

스킬 링크

https://github.com/maziyarpanahi/openmed/blob/master/skills/generating-synthetic-surrogates/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/maziyarpanahi/openmed/blob/master/skills/generating-synthetic-surrogates/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 노트의 이름과 진료기록번호를 현실적인 가짜 값으로 바꿔 비식별화해 주세요. 문서 안에서는 일관되게 유지해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 식별자를 탐지하고, 각 유형에 맞는 가짜 값을 만들며, 노트 전체에서 각 사람의 가짜 값을 같게 유지한 뒤, 읽을 수 있는 텍스트를 돌려줍니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Generating synthetic surrogates

method="replace" swaps each detected identifier for a realistic, type-matched fake — John Doe becomes Mark Lee, a phone becomes a plausible phone, a date becomes a plausible date. Unlike opaque [REDACTED]/[NAME] masks, surrogate text reads naturally and stays parseable by downstream NLP, while still containing no real PHI. OpenMed generates surrogates on-device via Faker-backed providers keyed to each canonical label.

When to use this skill

Use surrogates when the de-identified text must remain readable or machine- parseable: training data for clinical NLP, demos, QA, or notes a human still needs to skim. If you only need the identifiers gone and don't care about readability, plain method="mask" is simpler and more obviously redacted.

Quick start

import openmed

note = (
    "Patient John Doe (MRN 1234567) saw Dr. John Doe's colleague on 2024-03-02. "
    "Reach John Doe at 617-555-0142."
)

result = openmed.deidentify(
    note,
    method="replace",
    consistent=True,     # every "John Doe" -> the SAME surrogate within this call
    seed=42,             # reproducible across runs
    locale="en_US",      # shapes the fakes; defaults from lang via LANG_TO_LOCALE
)
print(result.deidentified_text)
# Patient Mark Lee (MRN 8830127) saw Dr. Mark Lee's colleague on 2024-07-18. ...

consistent=True is what makes the output coherent: the three mentions of "John Doe" collapse to one fake identity instead of three different ones, so the note still makes sense. seed= makes that mapping reproducible run to run.

Surrogates vs opaque redaction

method="mask" ([NAME]) method="replace" (surrogate)
Readability low — placeholders high — reads like a real note
Downstream NLP tokenizers see [NAME] everywhere natural distribution preserved
Co-reference lost (all [NAME]) preserved with consistent=True
Obvious it's de-identified yes no (must be tracked out-of-band)
Reversible with keep_mapping=True with keep_mapping=True

Custom providers and label generators

When a built-in surrogate doesn't match your house format (e.g. your MRNs are H + 7 digits), register a generator or a Faker provider.

from openmed import (
    register_label_generator, register_clinical_provider,
    Anonymizer, AnonymizerConfig,
)

# Override the surrogate for one canonical label. Signature: (faker, original, *, locale)
def hospital_mrn(faker, original, *, locale):
    return f"H{faker.numerify('#######')}"

register_label_generator("ID_NUM", hospital_mrn)   # global, all new Anonymizers

# Add a whole custom Faker provider (e.g. proprietary identifier formats):
register_clinical_provider(MyClinicalProvider)     # a faker BaseProvider subclass

# Per-instance control (preferred for isolation): pass providers via config,
# and pull a single surrogate directly when you need one.
anon = Anonymizer(AnonymizerConfig(
    lang="en", consistent=True, seed=7, custom_providers=[MyClinicalProvider],
))
fake = anon.surrogate("1234567", "ID_NUM")

Use register_label_generator(canonical_label, fn) to swap one label's surrogate; register_clinical_provider(provider) to add providers globally; or AnonymizerConfig.custom_providers for per-run scoping. Validate any custom label against openmed.CANONICAL_LABELS.

Workflow

  1. Choose method="replace" (or a profile like gdpr_pseudonymization / canada_pipeda that replaces by default — see configuring-privacy-policies).
  2. Enable consistency with consistent=True and a seed= so repeated mentions resolve to one identity and the result is reproducible.
  3. Set locale= so surrogates look native (pt_BR, de_DE, …); it defaults from lang via LANG_TO_LOCALE (deidentifying-multilingual-text).
  4. Register custom generators for any house-specific formats (MRN, account, address) before the run.
  5. If reversibility is needed, add keep_mapping=True and store result.mapping as a secret, separate from the output.
  6. Verify no surrogate collides with a real value and residual risk is low (auditing-deidentification-runs).

Hand-off to / from OpenMed

  • Core de-id: deidentifying-clinical-text — method, thresholds, keep_mapping, policies.
  • Policies that replace: configuring-privacy-policies (gdpr_pseudonymization, canada_pipeda).
  • **Multilingual surrogat
자주 묻는 질문

가짜 값을 재현할 수 있나요?

네. 고정된 시드를 쓰면 실행할 때마다 같은 결과가 나옵니다.

같은 사람은 같은 가짜 이름을 받나요?

일관성 모드를 켜면 한 문서 안에서 각 식별자가 같은 가짜 값에 대응합니다.

마스킹이 더 나은 경우도 있나요?

네. 읽기 편한 것이 중요하지 않다면 단순 마스킹이 더 간단하며, 가려졌다는 것이 분명히 표시됩니다.

상세 정보

작성자의 원본 설명

Replace detected PHI with realistic, type-matched fake values in OpenMed so clinical notes stay readable and parseable instead of full of [REDACTED] markers. Use when the user wants surrogate names, MRNs, addresses, or dates rather than opaque masks, needs consistent fake identities across a document, must keep notes natural for downstream NLP, or wants to register a custom surrogate generator or provider. Covers deidentify(method=\"replace\", consistent=True, seed=..., locale=...), register_label_generator, register_clinical_provider, and Anonymizer/AnonymizerConfig. Pairs with OpenMed deiden

repo: maziyarpanahi/openmed

인기도

GitHub 스타
5.8k
순위
#14707
라이선스
Apache-2.0
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬