# OpenMed Dependencies: Complete Guide to Core and Optional Packages

> Explore OpenMed dependencies, including core packages like pysbd and faker, and optional groups for transformers MLX FastAPI and GLiNER to enable advanced features.

- Repository: [Maziyar Panahi/openmed](https://github.com/maziyarpanahi/openmed)
- Tags: how-to-guide
- Published: 2026-06-13

---

**OpenMed requires only `pysbd` and `faker` for core functionality, but offers eight optional dependency groups—including Hugging Face transformers, MLX, FastAPI, and GLiNER—that enable model inference, REST APIs, and documentation generation.**

OpenMed is a flexible medical NLP toolkit hosted at `maziyarpanahi/openmed` that uses a minimal core installation strategy to keep base requirements lightweight. Understanding the complete **OpenMed dependencies** structure is essential for deploying the right components, whether you need basic sentence segmentation or Apple Silicon-accelerated model serving. All dependency specifications are declared centrally in the project's [`pyproject.toml`](https://github.com/maziyarpanahi/openmed/blob/main/pyproject.toml) file.

## Core Runtime Dependencies

The base installation of OpenMed installs only two essential packages defined in [`pyproject.toml`](https://github.com/maziyarpanahi/openmed/blob/main/pyproject.toml).

### Sentence Segmentation with pysbd

The **`pysbd>=0.3.4,<0.4`** library handles sentence boundary detection for clinical text. This dependency is imported and used throughout the codebase for preprocessing unstructured medical documents.

```python
import pysbd

seg = pysbd.Segmenter(language="en", clean=True)
text = "Patient reports headache. No fever."
sentences = seg.segment(text)
print(sentences)   # ['Patient reports headache.', 'No fever.']

```

### Synthetic Data Generation with faker

The **`faker>=22.0`** package provides utilities for generating synthetic clinical data during testing and demonstration workflows.

## Optional Dependency Groups

OpenMed organizes extended functionality into optional extras that you install via bracket notation (e.g., `pip install openmed[cli]`).

### CLI Tools (rich, typer)

The **CLI extras** group installs **`rich>=13.0`** for formatted terminal output and **`typer>=0.12`** for the command-line interface implementation found in [`openmed/cli/typer_app.py`](https://github.com/maziyarpanahi/openmed/blob/main/openmed/cli/typer_app.py).

```bash
openmed --help          # Shows the Typer-based help menu

openmed run --model gpt4  # Example command using the CLI extras

```

### Model Inference (transformers, accelerate)

The **hf** group enables Hugging Face model loading and acceleration:

- **`transformers>=4.50`**
- **`huggingface-hub>=0.30`**
- **`accelerate>=0.29`**
- **`tokenizers>=0.15`**

These packages support loading pretrained medical models and optimizing inference pipelines.

### MLX Backend (Apple Silicon)

The **MLX backend** group targets Apple Silicon devices using Apple's MLX framework:

- **`mlx>=0.22`**
- **`huggingface-hub>=0.30`**
- **`transformers>=4.50`**
- **`tokenizers>=0.15`**
- **`safetensors>=0.4`**
- **`tiktoken>=0.7`**

This configuration enables high-performance inference on M-series chips without requiring PyTorch.

### CoreML Export (coremltools, torch)

The **CoreML export** group facilitates converting PyTorch models to Apple's Core ML format:

- **`coremltools>=8.0`**
- **`torch>=2.0`**
- **`transformers>=4.50`**

### Entity Extraction (gliner)

The **GLiNER** group adds fast, token-aware named entity recognition:

- **`gliner[tokenizers]>=0.2.0`**
- **`torch>=2.0`**

### FastAPI Service (fastapi, uvicorn)

The **service** group powers the REST API server implemented in [`openmed/mcp/server.py`](https://github.com/maziyarpanahi/openmed/blob/main/openmed/mcp/server.py):

- **`fastapi>=0.110`**
- **`uvicorn[standard]>=0.29`**

```bash
uvicorn openmed.mcp.server:app --host 0.0.0.0 --port 8000

```

### MCP Utilities (mcp)

The **MCP** group includes **`mcp>=1.9`** for model-component-pipeline helper functions.

### Documentation (mkdocs)

The **docs** group generates the project website and includes:

- **`mkdocs>=1.6`**
- **`mkdocs-material>=9.5`**
- **`mkdocs-git-revision-date-localized-plugin>=1.2.6`**
- **`mkdocs-minify-plugin>=0.8.0`**
- **`pymdown-extensions>=10.8`**

### Development Tools (pytest, flake8)

The **development** group supports testing and quality assurance:

- **`flake8>=7.0`** (linting)
- **`pytest>=7.0`** (test execution)
- **`pytest-cov>=4.0`** (coverage reporting)
- **`httpx>=0.27`** (HTTP client utilities)

## Installation Examples

Install only the core OpenMed dependencies for minimal footprint:

```bash
pip install openmed

```

Install multiple optional groups to enable full functionality:

```bash

# Full feature set (CLI + Hugging Face + FastAPI + docs)

pip install "openmed[cli,hf,service,docs]"

```

Target specific backends based on your hardware:

```bash

# For Apple Silicon MLX acceleration

pip install "openmed[mlx]"

# For CoreML model export

pip install "openmed[coreml]"

```

## Key Configuration Files

The dependency structure is controlled by these critical files in the repository:

- **[`pyproject.toml`](https://github.com/maziyarpanahi/openmed/blob/main/pyproject.toml)** – Central declaration of core and optional dependencies, version constraints, and extras groups
- **[`openmed/__about__.py`](https://github.com/maziyarpanahi/openmed/blob/main/openmed/__about__.py)** – Package version metadata referenced during installation
- **[`openmed/cli/typer_app.py`](https://github.com/maziyarpanahi/openmed/blob/main/openmed/cli/typer_app.py)** – Implementation of the CLI interface requiring the `cli` extras
- **[`openmed/mcp/server.py`](https://github.com/maziyarpanahi/openmed/blob/main/openmed/mcp/server.py)** – FastAPI application requiring the `service` extras

## Summary

- **Core dependencies** are limited to `pysbd` (sentence segmentation) and `faker` (synthetic data), keeping the base installation lightweight.
- **Eight optional groups** extend functionality: `cli`, `hf`, `mlx`, `coreml`, `gliner`, `service`, `mcp`, and `docs`.
- **Hardware-specific** groups include `mlx` for Apple Silicon and `coreml` for mobile deployment.
- **Development tools** are isolated in a separate group containing `pytest`, `flake8`, and `httpx`.
- All constraints are defined in [`pyproject.toml`](https://github.com/maziyarpanahi/openmed/blob/main/pyproject.toml) with specific minimum versions (e.g., `transformers>=4.50`).

## Frequently Asked Questions

### What are the minimum OpenMed dependencies required to run the package?

The absolute minimum installation requires only **`pysbd>=0.3.4,<0.4`** and **`faker>=22.0`**. These provide sentence boundary detection and synthetic data generation capabilities without any machine learning frameworks.

### How do I install OpenMed with Hugging Face model support?

Install the **`hf`** optional group using `pip install "openmed[hf]"`. This adds `transformers>=4.50`, `huggingface-hub>=0.30`, `accelerate>=0.29`, and `tokenizers>=0.15` to enable loading and running Hugging Face transformer models.

### Can I run OpenMed on Apple Silicon without installing PyTorch?

Yes. Install the **`mlx`** optional group (`pip install "openmed[mlx]"`) to use Apple's MLX framework for acceleration. This group includes `mlx>=0.22` and related Hugging Face utilities but does not require PyTorch, making it ideal for M-series Macs.

### Which dependency group is needed for the OpenMed REST API server?

The **`service`** group provides the required `fastapi>=0.110` and `uvicorn[standard]>=0.29` packages. Install with `pip install "openmed[service]"` and launch the server using the `uvicorn openmed.mcp.server:app` command.