RareMind is a locally deployable, multi-agent clinical reasoning pipeline grounded in RareGraph, the structured rare-disease knowledge graph developed for this project. It converts clinical notes, phenotype terms, images, and genomic evidence into:
- a ranked rare-disease differential;
- clinician-readable explanations for the leading diagnoses;
- prioritized next tests and evaluations; and
- the specialties or referral services responsible for those actions.
Pipeline: RareMind
Knowledge graph: RareGraph
Default model:Qwen/Qwen3-8B
Default workflow: Stages 1β10, from extraction through clinical recommendations
- π Extracts phenotypes, negated findings, demographics, family history, prior testing, and genes from clinical notes
- πΌοΈ Incorporates phenotype evidence from medical images when available
- 𧬠Accepts structured HPO terms and completed genomic-ranking results
- π Grounds retrieval and reasoning in RareGraph, HPO, MONDO, OMIM, and Orphanet
- π€ Audits evidence, compares candidates, and reconciles subtype- and disease-group rankings
- π Preserves the Original Rank, Final Rank, and major reasoning transitions
- π©Ί Produces a readable Top-10 disease-group differential
- π§ͺ Recommends normalized next tests and initial evaluations
- π©ββοΈ Identifies responsible specialties and explicit referrals when supported by RareGraph
RareMind is designed for auditable clinical research: ground-truth diagnoses and future observed tests are used only for retrospective evaluation and never during patient inference.
| Stage | Purpose | Main result |
|---|---|---|
| 1 | Multimodal extraction | Clinical findings, family history, testing, genes, and image evidence |
| 2 | Ontology normalization | Normalized HPO evidence, temporal context, inheritance, and incongruity |
| 3 | Retrieval and composite scoring | Original subtype and disease-group rankings |
| 3.5 | Case-signal assessment | Genetic/rare-disease, acquired/control, or insufficient-information signal |
| 4 | Optional frontier consultation | Targeted second opinion for selected ambiguous cases |
| 5 | Evidence audit | Supporting, contradictory, and unresolved expected evidence |
| 6 | Pairwise adjudication | Direct comparisons among plausible candidates |
| 7 | Rank aggregation | Aggregated subtype and disease-group rankings |
| 8 | Reconciliation and fusion | Canonical Final Rank |
| 9 | Clinical synthesis | Patient summary and readable Top-10 differential |
| 10 | Next-step synthesis | Top investigations, responsible specialties, and supported referrals |
Detailed stage logic, resume behavior, sharding, and the complete artifact list are documented in the Pipeline reference.
RareMind is tested on Linux with Python 3.11 and an NVIDIA GPU.
git clone https://github.com/WGLab/RareMind.git
cd RareMind
conda create -n raremind python=3.11 -y
conda activate raremind
python -m pip install --upgrade pip uv
uv pip install -r requirements.txt \
"vllm==0.32.0" \
--extra-index-url https://wheels.vllm.ai/0.32.0/cu129 \
--torch-backend=cu129
flashinfer download-kernelsAfter installation, verify:
python - <<'PY'
import torch
import vllm
print("torch:", torch.__version__, "CUDA build:", torch.version.cuda)
print("vLLM:", vllm.__version__)
PYIf installation fails with ImportError: libcudart.so.13: cannot open shared object file, see GitHub Issue #1.
If inference fails with RuntimeError: Could not find nvcc and default cuda_home='/usr/local/cuda' doesn't exist, see GitHub Issue #2.
Only the local PHI-deidentification workflow needs one additional model download:
python -m spacy download en_core_web_lgAuthenticate with Hugging Face if a configured model is gated:
hf auth loginCheck the environment and configured resources before a long run:
python scripts/check_setup.py --config configs/default.yamlThe large data/ resources are intentionally not committed to Git.
python scripts/00_download_hpo.pyThis downloads data/hpo/hp.obo.
Request access to the gated RareGraph dataset. After approval, run from the repository root:
hf auth loginRESOURCE_REPO="quannguyenminh103/RareGraph"
hf download "$RESOURCE_REPO" \
data/knowledge_graph/RareGraph.json \
data/knowledge_graph/raregraph_next_steps_normalized.json \
data/mondo/hierarchy.json \
data/mondo/omim_conversion.json \
data/mondo/orphanet_conversion.json \
--repo-type dataset \
--local-dir .Build the BioLORD normalization caches:
python scripts/01_build_indexes.py --config configs/default.yamlQwen and BioLORD weights download from Hugging Face on first use unless already available in a shared cache.
No patient records are distributed with the repository. CHOP and UDN data require authorization from the data-owning institution. Public benchmark cohorts must be obtained from their original sources and converted to the input structure below. Ground-truth label files are needed only for evaluationβnot inference.
The filename stem is the case identifier shared across modalities:
inputs/
βββ demo/
βββ free_hpo/
β βββ case001.txt # cerebrocostomandibular syndrome
βββ text/
β βββ case002.txt # fragile X syndrome
βββ image/
β βββ <case_id>.png # optional clinical image (.png or .jpg)
βββ vcf/
βββ <case_id>.vcf # optional genomic variants
Clinical text is the usual starting point. Never send protected health information to an external provider unless explicitly approved under the applicable governance process; the default text and vision providers are local.
python scripts/run_pipeline.py \
--config configs/default.yaml \
--input_dir inputs \
--dataset demo \
--output_dir outputs \
--case_id case001 \
--workflow allpython scripts/run_pipeline.py \
--config configs/default.yaml \
--input_dir inputs \
--dataset demo \
--output_dir outputs \
--workflow all \
--resume--resume excludes cases already complete for the requested workflow and reconstructs missing prerequisites only where necessary.
Submit from the repository root after activating the environment:
mkdir -p logs
sbatch \
--job-name=raremind-demo \
--partition=gpuq \
--gres=gpu:a100:1 \
--cpus-per-gpu=1 \
--mem=64G \
--time=5-00:00:00 \
--output=logs/raremind-demo-%j.out \
--error=logs/raremind-demo-%j.err \
--export=ALL \
--wrap="bash scripts/run_agents.sh \
--config configs/default.yaml \
--input_dir inputs \
--dataset demo \
--output_dir outputs \
--text_model Qwen/Qwen3-8B \
--workflow all \
--resume"Without a SLURM array, one job processes the complete dataset. For five deterministic shards, add --array=1-5 to sbatch and --n_shards 5 to run_agents.sh.
First run with a new model: submit only one shard initially. Wait until its log completes model/JIT initialization and begins processing Cases before submitting the remaining shards concurrently.
| Command option | Runs through |
|---|---|
--workflow extract |
Stage 2: extracted and normalized patient evidence |
--workflow rank-original |
Stage 3: Original Rank |
--workflow case-signal |
Stage 3.5 only, reusing/recovering Stages 1β3 |
--workflow rank-final |
Stage 8: Final Rank |
--workflow all |
Stage 10: diagnoses, clinical report, tests, and specialties |
To complete missing Stage 9/10 reports from saved upstream results:
python scripts/run_pipeline.py \
--config configs/default.yaml \
--input_dir inputs --dataset demo --output_dir outputs \
--workflow all --start-stage 9 --resumeUse --workflow all --force-stages 9 when existing Stage 9/10 files must be overwritten.
Each case is saved under outputs/<dataset>/<case_id>/.
stage1_extraction.json structured clinical extraction
stage2_patient_evidence.json normalized patient evidence
stage3_group_ranking.tsv Original disease-group ranking
stage8_final_group_ranking.tsv Final disease-group ranking
stage9_reasoning_report.json structured clinical synthesis
stage9_reasoning_report.txt readable clinical report
stage9_reasoning_report.pdf review-ready report
stage10_next_steps.tsv investigations, specialties, and referrals
rank_trajectory.tsv auditable ranking transitions
Stage 9 explains the leading disease groups without changing their ranks. Stage 10 converts those hypotheses into normalized investigations and responsible specialties; it labels an action as a literal referral only when the underlying RareGraph evidence explicitly recommends referral or consultation.
The CPU-only disease-ranking evaluator calculates group-level Original or Final Rank performance using the fixed directional_label_compatible policy.
Quick final-rank evaluation:
bash evaluation/run_disease_ranking_evaluation.sh \
--results-dir outputs/demo \
--ground-truth evaluation/ground_truth_template.tsv \
--hierarchy data/mondo/hierarchy.json \
--kg data/knowledge_graph/RareGraph.json \
--ranking final \
--output-dir evaluation_results/demo_finalUse --ranking original to evaluate the Stage 3 ranking. Evaluation labels are used only by the evaluator and remain isolated from inference.
src/raremind/ main RareMind implementation
configs/ runtime configuration and prompts
scripts/ pipeline, setup, and SLURM entry points
evaluation/ disease-ranking evaluation
clinical_impact_analyses/ retrospective clinical-impact analyses
docs/ detailed project and pipeline references
All pipeline imports use the raremind namespace. RareGraph refers to the knowledge graph, not a Python package.
RareMind is a research decision-support system. Its rankings and suggested actions are not medical advice or a substitute for clinical judgment. All outputs require review in the context of the complete patient record, prior testing, local practice, and test availability.
The full RareMind and RareGraph manuscripts are in preparation. Until they become available, please cite our related publication.