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