generating-synthetic-surrogates
यह क्या करती है
यह स्किल क्लिनिकल टेक्स्ट में मरीज़ के पहचानकर्ताओं को यथार्थवादी, प्रकार से मेल खाते नकली मानों से बदलती है, जैसे किसी असली नाम की जगह नकली नाम। टेक्स्ट पढ़ने योग्य रहता है और दूसरे टूल से भी पढ़ा जा सकता है। यह उन टीमों के लिए है जिन्हें सहज दिखने वाला, सुरक्षित टेक्स्ट चाहिए।
कब इस्तेमाल करें
- ✓जब डी-आइडेंटिफ़ाई किए गए नोट्स पढ़ने योग्य और स्वाभाविक रहने चाहिए, न कि रिडैक्शन चिह्नों से भरे।
- ✓जब प्रशिक्षण या डेमो टेक्स्ट में पूरे दस्तावेज़ में एकसमान नकली पहचान चाहिए।
- ✓जब आपको कस्टम बदलाव फ़ॉर्मैट चाहिए, जैसे अपना रिकॉर्ड नंबर पैटर्न।
Skill का लिंक
https://github.com/maziyarpanahi/openmed/blob/master/skills/generating-synthetic-surrogates/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“इस नोट को डी-आइडेंटिफ़ाई कीजिए। नाम और रिकॉर्ड नंबर को यथार्थवादी नकली मानों से बदलिए, जो पूरे दस्तावेज़ में एकसमान रहें।”
हर हफ़्ते 5 नई skills, 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
- Choose
method="replace"(or a profile likegdpr_pseudonymization/canada_pipedathat replaces by default — seeconfiguring-privacy-policies). - Enable consistency with
consistent=Trueand aseed=so repeated mentions resolve to one identity and the result is reproducible. - Set
locale=so surrogates look native (pt_BR,de_DE, …); it defaults fromlangviaLANG_TO_LOCALE(deidentifying-multilingual-text). - Register custom generators for any house-specific formats (MRN, account, address) before the run.
- If reversibility is needed, add
keep_mapping=Trueand storeresult.mappingas a secret, separate from the output. - 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
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
annotating-variants
5.8kआपके एजेंट को मुफ़्त सार्वजनिक एनोटेटर से जेनेटिक वेरिएंट का असर बताने, HGVS नामों को जीनोम पोज़िशन में बदलने और जनसंख्या आवृत्ति जोड़ने में मदद करती है।
ask-openmed
5.8kआपके एजेंट को क्लिनिकल टेक्स्ट अनुरोध के लिए सही OpenMed वर्कफ़्लो चुनने में मदद करती है, जहाँ मरीज़ का डेटा हो सकता है वहाँ पहले गोपनीयता जाँच से शुरू करके।
assembling-fhir-bundles
5.8kकई FHIR स्वास्थ्य रिकॉर्ड को एक ट्रांज़ैक्शन Bundle में पैक करती है, जो EHR को भेजने के लिए तैयार हो और आंतरिक संदर्भ सही जुड़े हों।
auditing-deid-leakage
5.8kडी-आइडेंटिफ़ाइड क्लिनिकल टेक्स्ट में बचे पहचानकर्ता जैसे SSN, कार्ड नंबर, ईमेल और तारीखें खोजती है, और कुछ बचा हो तो रिलीज़ रोक देती है।
मिलती-जुलती skills
reverse-engineer-anything
422kयह आपके एजेंट को REA टूल से शिप हुई ऐप्स और पैकेज को अंदर से समझने, वर्ज़न की तुलना करने या दोबारा बनाने में मदद करती है।
1password
394kयह आपके एजेंट को 1Password CLI सेट करने, साइन इन करने और सीक्रेट्स की वैल्यू चैट में छापे बिना उन्हें पढ़ने या इस्तेमाल करने में मदद करती है।
healthcheck
394kयह आपके एजेंट को उस कंप्यूटर या सर्वर का सुरक्षा ऑडिट करने देती है जिस पर OpenClaw चलता है, जिसमें SSH, firewall, अपडेट और बैकअप शामिल हैं, और फिर सुरक्षित सुधार सुझाती है।