How gersteinlab/medagents works
MedAgents runs medical-question inference using either direct prompting or a multi-disciplinary collaboration workflow. In the collaborative path, utils.py orchestrates domain selection, expert analyses, report synthesis, optional consensus-and-revision rounds, and final answer generation; api_utils.py sends model requests to Azure OpenAI. run.py loads dataset examples and appends prediction records. The README describes evaluation on several datasets, but only the MedQA data directory is present in this tree. The stage wiring is based on the sampled orchestration and prompt code.
Main entry points: utils.py Decode workflow · run.py Inference runner · api_utils.py API handler · data_utils.py Dataset loader
Components 16
Inference execution
- Inference runner
run.py - Prediction records
run.py
Medical collaboration
- Decode workflow
utils.py - Domain selection
utils.py - Expert analysis
utils.py - Report synthesis
utils.py - Consensus review
utils.py - Report revision
utils.py - Answer decision
utils.py - Prompt templates
prompt_generator.py
Dataset handling
- Dataset loader
data_utils.py - MedQA examples
datasets/MedQA/test.jsonl - Output cleaning
data_utils.py
Model integration
- API handler
api_utils.py - Azure OpenAI
Other components
- Inference operator
Connections 17
- Inference operator → Inference runner: runs inference
- Inference runner → Dataset loader: loads examples
- MedQA examples → Dataset loader: provides examples
- Inference runner → Decode workflow: decodes question
- Decode workflow → Domain selection: starts workflow
- Domain selection → Expert analysis: selects domains
- Expert analysis → Report synthesis: provides analyses
- Report synthesis → Consensus review: submits report
- Consensus review → Report revision: requests changes
- Report revision → Consensus review: rechecks report
- Report synthesis → Answer decision: provides report
- Consensus review → Answer decision: provides final report
- Decode workflow → Prompt templates: builds prompts
- Decode workflow → API handler: requests completions
- API handler → Azure OpenAI: sends requests
- Decode workflow → Output cleaning: cleans responses
- Inference runner → Prediction records: appends records