Spaces:
Sleeping
Sleeping
File size: 5,675 Bytes
88b4d0a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# MAI Diagnostic Orchestrator (MAI-DxO)
> **An open-source implementation of Microsoft Research's "Sequential Diagnosis with Language Models" paper, built with the Swarms AI framework.**
MAI-DxO (MAI Diagnostic Orchestrator) is a sophisticated AI-powered diagnostic system that simulates a virtual panel of physician-agents to perform iterative medical diagnosis with cost-effectiveness optimization. This implementation faithfully reproduces the methodology described in the Microsoft Research paper while providing additional features and flexibility.
[](https://arxiv.org/abs/2506.22405)
[](LICENSE)
[](https://python.org)
## β¨ Key Features
- **8 AI Physician Agents**: Specialized roles for comprehensive diagnosis.
- **5 Operational Modes**: Instant, question-only, budgeted, no-budget, and ensemble modes.
- **Cost Tracking**: Real-time budget monitoring with costs for 25+ medical tests.
- **Clinical Evaluation**: 5-point accuracy scoring with detailed feedback.
- **Model Agnostic**: Works with GPT, Gemini, Claude, and other leading LLMs.
- **Token-Optimized Prompts**: Ultra-compact role prompts reduce token usage and latency without sacrificing reasoning quality.
## π Quick Start
### 1. Installation
Install the package directly via pip:
```bash
pip install mai-dx
```
Or, for development, clone the repository and install the requirements:
```bash
git clone https://github.com/The-Swarm-Corporation/Open-MAI-Dx-Orchestrator.git
cd Open-MAI-Dx-Orchestrator
pip install -r requirements.txt
```
### 2. Environment Setup
Create a `.env` file in your project root and add your API keys:
```txt
OPENAI_API_KEY="Your OpenAI API key"
GEMINI_API_KEY="Your Gemini API key"
ANTHROPIC_API_KEY="Your Anthropic API key"
```
### 3. Basic Usage
```python
from mai_dx import MaiDxOrchestrator
# Create the orchestrator (defaults to a capable model)
orchestrator = MaiDxOrchestrator()
# Run a diagnosis
result = orchestrator.run(
initial_case_info="29-year-old woman with sore throat and peritonsillar swelling...",
full_case_details="Patient: 29-year-old female. History: Onset of sore throat...",
ground_truth_diagnosis="Embryonal rhabdomyosarcoma of the pharynx"
)
# Print the results
print(f"Final Diagnosis: {result.final_diagnosis}")
print(f"Accuracy: {result.accuracy_score}/5.0")
print(f"Total Cost: ${result.total_cost:,.2f}")
```
## βοΈ Advanced Usage & Configuration
Customize the orchestrator's model, budget, and operational mode.
```python
from mai_dx import MaiDxOrchestrator
# Configure with a specific model and budget
orchestrator = MaiDxOrchestrator(
model_name="gemini/gemini-2.5-flash", # or "gpt-4", "claude-3-5-sonnet"
max_iterations=10,
initial_budget=3000,
mode="budgeted" # Other modes: "instant", "question_only", "no_budget"
)
# Run the diagnosis
# ...
```
## π₯ How It Works: The Virtual Physician Panel
MAI-DxO employs a multi-agent system where each agent has a specific role:
- **π§ Dr. Hypothesis**: Maintains the differential diagnosis.
- **π¬ Dr. Test-Chooser**: Selects the most cost-effective diagnostic tests.
- **π€ Dr. Challenger**: Prevents cognitive biases and diagnostic errors.
- **π° Dr. Stewardship**: Ensures cost-effective care.
- **β
Dr. Checklist**: Performs quality control checks.
- **π€ Consensus Coordinator**: Synthesizes panel decisions.
- **π Gatekeeper**: Acts as the clinical information oracle.
- **βοΈ Judge**: Evaluates the final diagnostic accuracy.
## Documentation
Learn more about this repository [with the docs](DOCS.md)
## π€ Contributing
We welcome contributions! Please feel free to open an issue or submit a pull request.
## π License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## π Citation
If you use this work in your research, please cite both the original paper and this software implementation.
```bibtex
@misc{nori2025sequentialdiagnosislanguagemodels,
title={Sequential Diagnosis with Language Models},
author={Harsha Nori and Mayank Daswani and Christopher Kelly and Scott Lundberg and Marco Tulio Ribeiro and Marc Wilson and Xiaoxuan Liu and Viknesh Sounderajah and Jonathan Carlson and Matthew P Lungren and Bay Gross and Peter Hames and Mustafa Suleyman and Dominic King and Eric Horvitz},
year={2025},
eprint={2506.22405},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2506.22405},
}
@software{mai_dx_orchestrator,
title={Open-MAI-Dx-Orchestrator: An Open Source Implementation of Sequential Diagnosis with Language Models},
author={The-Swarm-Corporation},
year={2025},
url={https://github.com/The-Swarm-Corporation/Open-MAI-Dx-Orchestrator.git}
}
```
## π Related Work
- [Original Paper](https://arxiv.org/abs/2506.22405) - Sequential Diagnosis with Language Models
- [Swarms Framework](https://github.com/kyegomez/swarms) - Multi-agent AI orchestration
- [Microsoft Research](https://www.microsoft.com/en-us/research/) - Original research institution
## π Support
- **Issues**: [GitHub Issues](https://github.com/The-Swarm-Corporation/Open-MAI-Dx-Orchestrator/issues)
- **Discussions**: [GitHub Discussions](https://github.com/The-Swarm-Corporation/Open-MAI-Dx-Orchestrator/discussions)
- **Documentation**: [Full Documentation](https://docs.swarms.world)
---
<p align="center">
<strong>Built with Swarms for advancing AI-powered medical diagnosis</strong>
</p> |