CoolFace
Apppublic

yatin-superintelligence/digital-hospital-environment

sourceHugging Facecc-by-4.0updated 4mo agoView on Hugging Face
1likes
App README

Digital Hospital Environment

Digital Hospital is a deterministic clinical AI environment for evaluating and training agents that operate inside a hospital workflow. It is served as a FastAPI Space and exposes standard HTTP endpoints for episode reset, step execution, state inspection, closing, cross-role email injection, and clinic-data injection.

The environment contains 11 hospital roles, 47 patient cases, 550 role-specific MCQs, hidden answer keys, specialty-specific tool permissions, deterministic grading, dense per-step rewards, a Clinical Research Expert inbox workflow, a Hospital Director review workflow, and trajectory capture for offline reinforcement learning or process-supervision datasets.

Roles

RoleName
S01Emergency Physician
S02Intensivist
S03Cardiologist
S04Surgeon
S05Nephrologist
S06Senior Hospitalist
S07Neurologist
S08Infectious Disease Physician
S09Clinical Pharmacist
C01Clinical Research Expert
D01Hospital Director

API Usage

Set the Space URL:

bash
export ENV_URL="https://yatin-superintelligence-digital-hospital-environment.hf.space"

Check health:

bash
curl "$ENV_URL/health"

Start a single role episode:

bash
curl -X POST "$ENV_URL/reset" \
  -H "Content-Type: application/json" \
  -d '{"role_id":"S01","seed":42,"session_id":"demo-s01"}'

Take a step:

bash
curl -X POST "$ENV_URL/step" \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "demo-s01",
    "command": "answer_mcq",
    "arguments": {"answer": "B"},
    "reasoning": "Choose the best role-specific answer."
  }'

Inspect available actions:

bash
curl "$ENV_URL/action_space?session_id=demo-s01"

Close and retrieve final score plus trajectory:

bash
curl -X POST "$ENV_URL/close" \
  -H "Content-Type: application/json" \
  -d '{"session_id":"demo-s01"}'

Running With Your Own Model

This Space is the environment server. Your model can run anywhere as long as it can emit JSON tool calls and call the Space over HTTP.

The included inference.py runner supports two modes:

  • —--api openai-local: call any OpenAI-compatible chat-completions server at INFERENCE_URL.
  • —--api local: load a local Hugging Face model through Transformers.

Example with an OpenAI-compatible local or remote inference server:

bash
export ENV_URL="https://yatin-superintelligence-digital-hospital-environment.hf.space"
export INFERENCE_URL="http://localhost:8000"

python inference.py \
  --api openai-local \
  --model your-model-name \
  --role S01 \
  --env-url "$ENV_URL" \
  --seed 42 \
  --output results_S01.json \
  --output-dir trajectories_demo

The inference server should implement:

text
POST /v1/chat/completions
GET  /health

Concurrent Rollout Collection

For training data, use collect_rollouts.sh. It launches multiple isolated sessions concurrently by assigning a unique session_id to every run, then aggregates per-role JSON/parquet outputs.

bash
export ENV_URL="https://yatin-superintelligence-digital-hospital-environment.hf.space"
export INFERENCE_URL="http://localhost:8000"
export MODEL="your-model-name"
export API="openai-local"

bash collect_rollouts.sh --iter 1 --runs 5 --seed 42

Run only one role:

bash
bash collect_rollouts.sh --iter 1 --runs 3 --roles S01

Each rollout row contains the model-visible context, raw model output, parsed command and arguments, environment observation, reward, role metadata, and advantage signal. This is the stable interface for offline policy-improvement experiments.

Local Development

bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn server.app:app --host 0.0.0.0 --port 7861

Then open:

text
http://localhost:7861

What The Environment Rewards

Digital Hospital rewards clinical process, not only final answers. Agents are evaluated on role-specific knowledge, patient triage, chart review, investigation, critical finding recognition, treatment-option review, safe treatment selection, research support, communication, director review, and reflection after feedback.

Correct treatment guesses without workup receive limited credit. Unsafe shortcuts, missing mandatory investigations, repeated tool calls, and unsupported treatment submissions are penalized. Hidden answer keys and process rubrics remain server-side.