bridging-presidio-and-spacy
यह क्या करती है
यह स्किल OpenMed क्लिनिकल टेक्स्ट टूल्स को Presidio, spaCy और LangChain से जोड़ती है, जो व्यक्तिगत डेटा पहचानने और भाषा ऐप्स के लोकप्रिय टूल हैं। यह उन डेवलपर्स के लिए है जो इनमें से कोई टूल पहले से चलाते हैं और उसमें OpenMed जोड़ना चाहते हैं।
कब इस्तेमाल करें
- ✓जब आप Microsoft Presidio पहले से चलाते हैं और उसमें OpenMed क्लिनिकल PII पहचान जोड़ना चाहते हैं।
- ✓जब आपकी spaCy पाइपलाइन को OpenMed के व्यक्तिगत डेटा स्पैन बनाने चाहिए।
- ✓जब आप LangChain चेन बनाते हैं और भाषा मॉडल तक पहुँचने से पहले मरीज़ का डेटा हटाना चाहते हैं।
Skill का लिंक
https://github.com/maziyarpanahi/openmed/blob/master/skills/bridging-presidio-and-spacy/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मैं पहले से Microsoft Presidio इस्तेमाल करता हूँ। मेरी Presidio पाइपलाइन में OpenMed क्लिनिकल PII पहचान जोड़िए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट चुने हुए टूल के लिए ज़रूरी अतिरिक्त पैकेज ही इंस्टॉल करता है, फिर मेल खाने वाले एडेप्टर से OpenMed नतीजों और उस टूल के फ़ॉर्मैट के बीच बदलाव करता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Bridging Presidio, spaCy & LangChain
OpenMed interoperates with the dominant PII/NLP ecosystems through a single,
lazy adapter registry: openmed.interop. Adapters live behind explicit
imports, so importing openmed never drags in Presidio, spaCy, or LangChain —
each is an optional extra you install only when you need that bridge.
When to use
Reach for a bridge when:
- you already run Microsoft Presidio and want OpenMed's clinical PII recall on top (or to feed OpenMed spans back into Presidio's anonymizer);
- you have a spaCy pipeline and want OpenMed PII spans on the
Doc; - you build LangChain chains and want to redact PHI before text reaches an LLM (the on-device guardrail in front of a cloud model);
- you need OpenMed's de-identification reachable from an existing framework
instead of rewriting the pipeline around
openmed.deidentify.
The lazy adapter registry (verified)
import openmed.interop as interop
interop.available_adapters()
# ('cda', 'hl7v2', 'langchain', 'presidio', 'spacy')
spec = interop.adapter_spec("presidio")
# AdapterSpec(name='presidio', module='openmed.interop.presidio',
# extra='presidio', description='Presidio RecognizerResult adapter')
mod = interop.get_adapter("presidio") # imports openmed.interop.presidio
# Attribute access also works lazily:
openmed.interop.presidio # same module, imported on first touch
available_adapters() and adapter_spec() never import the adapter module, so
they are safe to call for discovery even without the extra installed.
get_adapter(name) (and attribute access) triggers the import — and the
adapter's own optional dependency.
Install only the extra you need:
pip install "openmed[presidio]" # Presidio RecognizerResult adapter
pip install "openmed[spacy]" # spaCy openmed_deid component
pip install "openmed[langchain]" # LangChain redaction runnable
# cda and hl7v2 adapters ship in core (no extra) — see their own skills
Presidio bridge (verified callables)
Module openmed.interop.presidio converts between Presidio
RecognizerResults and OpenMed canonical PIIEntitys, and merges both
detectors through OpenMed's semantic-unit merger.
from openmed.interop.presidio import (
to_canonical, # RecognizerResult(s) -> [PIIEntity]
from_canonical, # [PIIEntity] -> [RecognizerResult] (needs presidio extra)
merge_with_openmed, # combine OpenMed + Presidio spans, resolve overlaps
PresidioAdapterConfig,
)
import openmed
text = "Dr. Smith called patient at 617-555-0123 on 2024-03-02."
# Presidio gives you RecognizerResults; OpenMed gives PIIEntities.
openmed_spans = openmed.extract_pii(text).entities
presidio_results = analyzer.analyze(text=text, language="en") # your Presidio analyzer
merged = merge_with_openmed(
openmed_spans, presidio_results, text=text,
config=PresidioAdapterConfig(preserve_presidio_labels=True),
)
# -> de-duplicated [PIIEntity]; overlaps resolved by score, length, OpenMed-origin
Why merge instead of union: merge_with_openmed runs both detectors' spans
through merge_entities_with_semantic_units, so overlapping/adjacent detections
collapse into one correct span (e.g. PHONE from Presidio vs a partial OpenMed
hit) rather than producing double redactions. Label mapping is built in
(Presidio PHONE_NUMBER ↔ OpenMed PHONE, US_SSN ↔ SSN, etc.).
To push OpenMed spans into Presidio's anonymizer, convert back:
results = from_canonical(openmed_spans) # [RecognizerResult]
anonymized = anonymizer.anonymize(text=text, analyzer_results=results)
spaCy bridge (verified factory)
Module openmed.interop.spacy_component registers a spaCy pipeline factory
named openmed_deid. Add it to a pipeline and OpenMed PII spans land on the
Doc.
import spacy
import openmed.interop.spacy_component # registers the @Language.factory
nlp = spacy.blank("en")
nlp.add_pipe("openmed_deid", config={
"confidence_threshold": 0.5,
"lang": "en",
"target": "openmed_pii", # doc.spans key
"merge_ents": False, # set True to also write doc.ents
"alignment_mode": "expand", # char->token alignment: strict|contract|expand
})
doc = nlp("Patient John Doe, MRN 12345, seen today.")
for span in doc.spans["openmed_pii"]:
print(span.label_, span.text)
# raw char-offset spans also available on doc._.openmed_pii
`merge
अक्सर पूछे जाने वाले सवाल
क्या OpenMed इंस्टॉल करने पर तीनों टूल लोड होंगे?
नहीं। हर ब्रिज एक वैकल्पिक अतिरिक्त पैकेज है, इसलिए आप केवल वही इंस्टॉल करते हैं जो चाहिए।
क्या OpenMed के स्पैन वापस Presidio में जा सकते हैं?
हाँ। स्किल Presidio के फ़ॉर्मैट में आगे-पीछे बदलाव कवर करती है।
क्या LangChain कवर है?
हाँ। यह भाषा मॉडल तक पहुँचने से पहले टेक्स्ट रिडैक्ट करना कवर करती है।
जानकारी
लेखक का मूल विवरण
Combine OpenMed clinical NLP with Microsoft Presidio, spaCy, or LangChain through OpenMed's built-in interop adapter registry (openmed.interop). Covers the lazy adapter registry (available_adapters, get_adapter, adapter_spec), the presidio/spacy/langchain pip extras, and the verified callables — Presidio to_canonical/from_canonical/merge_with_openmed, the spaCy openmed_deid pipeline factory, and the LangChain create_redaction_runnable. Use when the user wants to add Presidio recognizers, embed OpenMed PII detection in a spaCy pipeline, or use OpenMed de-identification as a LangChain runnable.
repo: maziyarpanahi/openmed
लोकप्रियता
- GitHub स्टार
- 5.8k
- रैंकिंग में स्थान
- #14677
- लाइसेंस
- 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
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।