{"id":50654088,"url":"https://github.com/FreedomIntelligence/SepsisAgent","last_synced_at":"2026-06-24T19:00:34.028Z","repository":{"id":357982625,"uuid":"1238677791","full_name":"FreedomIntelligence/SepsisAgent","owner":"FreedomIntelligence","description":"Agentifying Patient Dynamics within LLMs through  Interacting with Clinical World Model","archived":false,"fork":false,"pushed_at":"2026-05-15T04:23:04.000Z","size":706,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-15T06:39:40.510Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FreedomIntelligence.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-14T10:49:03.000Z","updated_at":"2026-05-15T04:35:33.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/FreedomIntelligence/SepsisAgent","commit_stats":null,"previous_names":["freedomintelligence/sepsisagent"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/FreedomIntelligence/SepsisAgent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomIntelligence%2FSepsisAgent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomIntelligence%2FSepsisAgent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomIntelligence%2FSepsisAgent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomIntelligence%2FSepsisAgent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FreedomIntelligence","download_url":"https://codeload.github.com/FreedomIntelligence/SepsisAgent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomIntelligence%2FSepsisAgent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34745456,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-24T02:00:07.484Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-07T23:00:21.475Z","updated_at":"2026-06-24T19:00:34.013Z","avatar_url":"https://github.com/FreedomIntelligence.png","language":null,"funding_links":[],"categories":["🧰 Datasets, Benchmarks and Simulators","Multi-Agent Medical Systems"],"sub_categories":["Simulators"],"readme":"# Agentifying Patient Dynamics within LLMs through Interacting with Clinical World Model\n\n\u003cdiv align=\"center\"\u003e\n\u003ch3\u003e\n  SepsisAgent\n\u003c/h3\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003ch4\u003e\n  📃 \u003ca href=\"https://arxiv.org/abs/2605.14723\" target=\"_blank\"\u003ePaper\u003c/a\u003e ｜ 🤗 \u003ca href=\"https://huggingface.co/FreedomIntelligence/SepsisAgent-4B\" target=\"_blank\"\u003eSepsisAgent-4B\u003c/a\u003e\n\u003c/h4\u003e\n\u003c/div\u003e\n\n## ⚡ Introduction\n\n**SepsisAgent** is a world model-augmented LLM agent for ICU sepsis treatment recommendation. It combines an LLM policy with a learned **Clinical World Model** that simulates patient responses under candidate fluid-vasopressor interventions. Instead of directly outputting a treatment action, SepsisAgent follows a **propose-simulate-refine** workflow: it proposes candidate actions, queries the world model for counterfactual patient trajectories, and refines the final prescription using both simulated dynamics and clinical priors.\n\nThe agent is trained with a three-stage curriculum: patient-dynamics supervised fine-tuning, propose-simulate-refine behavior cloning, and world-model-based agentic reinforcement learning. On MIMIC-IV sepsis trajectories, SepsisAgent improves off-policy treatment value while maintaining strong guideline adherence and low unsafe-action rates.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/intro-interaction.png\" width=\"95%\" alt=\"SepsisAgent propose-simulate-refine workflow\"\u003e\n\u003c/p\u003e\n\n## 🧠 Method Overview\n\nSepsisAgent uses a Clinical World Model as both an inference-time simulator and a training environment. The world model predicts action-conditioned patient evolution, while the LLM agent learns how to interpret these simulated responses for long-horizon treatment planning.\n\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/training-pipeline.png\" width=\"95%\" alt=\"Three-stage SepsisAgent training pipeline\"\u003e\n\u003c/p\u003e\n\n## 📊 Main Results\n\n### Clinical World Model Evaluation\n\n| Model Component | Metric | Value |\n| --- | ---: | ---: |\n| State Transition | MAE | 0.316 |\n| State Transition | Ventilation AUC | 0.942 |\n| Outcome Prediction | AUC-ROC | 0.804 |\n| Outcome Prediction | AUC-PR | 0.663 |\n\n### Policy Value and Safety on MIMIC-IV\n\nResults are reported on the 725-episode held-out test set. Higher is better for DR, WIS, WPDIS, and guideline adherence. Lower is better for unsafe actions.\n\n| Method | DR ↑ | WIS ↑ | WPDIS ↑ | Guideline Adherence ↑ | Underdosing ↓ | Overdosing ↓ |\n| --- | ---: | ---: | ---: | ---: | ---: | ---: |\n| Clinicians (Test Set) | 5.06 | 5.27 | 10.82 | 94.76 | 0.35 | 0.19 |\n| WD3QNE | 8.72 | **12.07** | 23.20 | 87.60 | 1.11 | 1.49 |\n| o3 | 8.32 | 9.17 | 20.38 | 90.55 | 0.72 | 1.57 |\n| o3 + WM | 9.46 | 10.27 | 22.95 | 96.91 | 0.09 | 0.24 |\n| Qwen3-4B-Instruct | 7.79 | 7.34 | 18.76 | 78.00 | 0.62 | 2.13 |\n| **SepsisAgent** | **10.01** | 11.14 | **23.40** | **97.95** | **0.08** | **0.14** |\n\nSepsisAgent achieves the best DR and WPDIS scores among evaluated methods, while also obtaining the highest sepsis guideline adherence and the lowest unsafe-action rates. This indicates that the policy-value gains do not come from unsafe treatment shortcuts.\n\n### Ablation Study\n\n| Method | DR ↑ | WIS ↑ | WPDIS ↑ | Guideline Adherence ↑ | Unsafe Actions ↓ | IHM AUROC ↑ | IHM AUPRC ↑ | VR AUROC ↑ | VR AUPRC ↑ |\n| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |\n| Qwen3-4B-Instruct | 7.79 | 7.34 | 18.76 | 78.00 | 2.75 | 65.27 | 45.01 | 70.62 | 61.74 |\n| SepsisAgent Stage I: SFT | 9.21 | 7.17 | 19.56 | 88.01 | 1.09 | 67.50 | 50.25 | 76.40 | 65.11 |\n| SepsisAgent Stage I+II: +BC | 8.99 | 6.81 | 19.61 | 96.89 | 0.51 | 67.55 | 46.63 | 74.56 | 63.70 |\n| **SepsisAgent Stage I+II+III: +RL** | **10.01** | **11.14** | **23.40** | **97.95** | **0.22** | **68.52** | **53.45** | **79.96** | **68.83** |\n\nThe ablation shows that reinforcement learning in the Clinical World Model environment is the main driver of policy-value improvement. The final stage also improves intrinsic patient-dynamics prediction, including in-hospital mortality (IHM) and 24-hour vasopressor requirement (VR), even without simulator access during evaluation.\n\n## 🚀 Quick Start\n\n### Repository Layout\n\n```\nSepsisAgent/\n├── inference.py                 # Main agent inference (vLLM + propose-simulate-refine)\n├── worldmodel_inference.py      # Standalone Clinical World Model inference demo\n├── run_inference.sh             # One-click launcher for the agent demo\n├── requirements.txt             # Python dependencies\n├── worldmodel/                  # Clinical World Model checkpoints \u0026 configs\n│   ├── state_model_log.pt       #   - State Model (next-state predictor)\n│   ├── outcome.pt               #   - Outcome Model (90-day mortality)\n│   ├── scaler_params_log.json   #   - Feature standardization params\n│   └── episode_feature_config.json\n├── test_data/                   # Single anonymized inference case\n│   ├── test_case.pkl            #   - One MIMIC-IV episode (stay_id=37523171)\n│   └── real_episode_rewards_test_case.json\n├── examples/                    # Worked examples (see examples/README.md)\n│   ├── inference_template.json  #   - Full agent rollout (raw JSON)\n│   ├── inference_template.md    #   - Same rollout rendered for humans\n│   └── worldmodel_inference_example.txt\n├── output/                      # Created at runtime (vLLM logs, results)\n└── assets/                      # README figures\n```\n\n### Installation\n\n```bash\npip install -r requirements.txt\n```\n\n\u003e The full MIMIC-IV-derived test set (725 episodes) is not redistributable. We ship a single inference case under `test_data/` that has been derived from a publicly accessible MIMIC-IV stay so the pipeline can be exercised end-to-end.\n\n### 1. Run the World Model alone\n\nThe Clinical World Model is a self-contained module: given a patient's history window and a candidate action, it predicts the next-step dynamics, ventilation probability, and (at trajectory end) 90-day mortality.\n\n```bash\n# Quick demo (first 5 steps + outcome)\npython worldmodel_inference.py --test\n\n# Full trajectory\npython worldmodel_inference.py\n```\n\nA reference output is provided at `examples/worldmodel_inference_example.txt`.\n\n### 2. Run the full SepsisAgent\n\nThe main agent ties the LLM policy together with the World Model via OpenAI tool calling. It auto-launches local vLLM services and runs the propose-simulate-refine loop.\n\n```bash\n# Using the bundled launcher\nbash run_inference.sh /path/to/SepsisAgent-4B 1\n\n# Or directly\npython inference.py \\\n    --model_path /path/to/SepsisAgent-4B \\\n    --model_name SepsisAgent-4B \\\n    --num_gpus 1 \\\n    --base_port 8000 \\\n    --test\n```\n\nThe result JSON (rewards, actions, full multi-turn dialogue) will be written under `output/`. A worked-out reference rollout, including every system / user / tool_call / tool_response message, is provided at `examples/inference_template.md`.\n\n## 🎯 To-Do\n- [x] Release the SepsisAgent-4B.\n- [x] Release a runnable single-case inference demo (this repo).\n- [ ] Upload the data processing scripts.\n\n## 🙏 Acknowledgement\n\nWe gratefully acknowledge the [MIMIC Code Repository](https://github.com/MIT-LCP/mimic-code) for providing valuable reference implementations and resources for processing MIMIC critical care data. Our data processing pipeline was developed with reference to this project.\n\nThe data used in this work are derived from [MIMIC-IV](https://physionet.org/content/mimiciv/), a publicly available, de-identified electronic health record dataset hosted on PhysioNet.\n\n\n## 📖 Citation\n\n```\n@misc{wu2026sepsisagent,\n      title={Agentifying Patient Dynamics within LLMs through Interacting with Clinical World Model}, \n      author={Minghao Wu and Yuting Yan and Zhenyang Cai and Ke Ji and Chuangsen Fang and Ziying Sheng and Xidong Wang and Rongsheng Wang and Hejia Zhang and Shuang Li and Benyou Wang and Hongyuan Zha},\n      year={2026},\n      eprint={2605.14723},\n      archivePrefix={arXiv},\n      primaryClass={cs.AI},\n      url={https://arxiv.org/abs/2605.14723}, \n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFreedomIntelligence%2FSepsisAgent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFreedomIntelligence%2FSepsisAgent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFreedomIntelligence%2FSepsisAgent/lists"}