OpenMed
OpenMed is a Python library that delivers state-of-the-art biomedical and clinical Large Language Models (LLMs), focusing on advanced entity extraction, assertion detection, and medical reasoning. It provides a robust, open-source toolkit for HIPAA-compliant workflows, supporting a simple Python API, a FastAPI-based REST service, and batch processing capabilities. The library is actively developed, with its current version being 0.6.4, and is designed to unify model discovery, advanced extractions, and one-line orchestration for clinical NLP workflows.
Warnings
- gotcha OpenMed relies on underlying biomedical models (often from Hugging Face). These models can be large and require significant memory and/or GPU resources for optimal performance, particularly for larger texts or batch processing. Ensure your environment meets the computational demands, and models are available or downloaded.
- gotcha While OpenMed provides robust tools for HIPAA-compliant PII detection and de-identification (e.g., smart entity merging), achieving full HIPAA compliance is a broader responsibility that extends beyond the library's capabilities. It requires proper configuration, integration into a secure environment, and adherence to organizational policies.
- gotcha OpenMed supports different configuration profiles (e.g., 'dev', 'prod', 'test', 'fast') that can alter default behaviors like confidence thresholds or entity grouping. Not explicitly managing these profiles can lead to inconsistent results between development and production environments.
- gotcha For PII extraction and de-identification in languages other than English, the `lang` parameter (e.g., `lang="es"` for Spanish) must be explicitly provided to the `extract_pii` or `deidentify` functions. Failing to do so may result in incorrect or incomplete PII detection.
Install
-
pip install openmed -
pip install "openmed[hf]" -
pip install "openmed[hf,service]"
Imports
- analyze_text
from openmed import analyze_text
- BatchProcessor
from openmed import BatchProcessor
- extract_pii
from openmed import extract_pii
- deidentify
from openmed import deidentify
- OpenMedConfig
from openmed import OpenMedConfig
Quickstart
from openmed import analyze_text
text = "Patient started on imatinib for chronic myeloid leukemia."
result = analyze_text(
text,
model_name="disease_detection_superclinical", # Example model
confidence_threshold=0.55 # Optional: filter entities by confidence
)
for entity in result.entities:
print(f"{entity.label:<12} {entity.text:<35} {entity.confidence:.2f}")
# Example output:
# DISEASE chronic myeloid leukemia 0.98
# DRUG imatinib 0.95