Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,9 +1,135 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
- `easy`: eligibility
|
| 6 |
-
- `medium`: ranking
|
| 7 |
-
- `hard`:
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Clinical Trial Patient Screening
|
| 3 |
+
emoji: π§ͺ
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: indigo
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
app_port: 8000
|
| 9 |
+
tags:
|
| 10 |
+
- openenv
|
| 11 |
+
short_description: RL environment for clinical trial patient screening.
|
| 12 |
+
---
|
| 13 |
+
# Clinical Trial Patient Screening Environment
|
| 14 |
|
| 15 |
+
OpenEnv environment for clinical trial patient screening with three deterministic healthcare tasks:
|
| 16 |
|
| 17 |
+
- `easy`: binary eligibility screening against 5 criteria
|
| 18 |
+
- `medium`: ranking 3 patients by protocol fit
|
| 19 |
+
- `hard`: protocol deviation and exclusion detection from unstructured clinical text
|
| 20 |
|
| 21 |
+
This environment is designed as a real-world screening workflow rather than a toy game. It uses typed Pydantic models, deterministic programmatic graders, incremental reward shaping for correct data extraction, and terminal rewards for correct screening outcomes.
|
| 22 |
+
|
| 23 |
+
## Task Overview
|
| 24 |
+
|
| 25 |
+
### Easy
|
| 26 |
+
EGFR-mutated metastatic NSCLC eligibility check using structured oncology data.
|
| 27 |
+
|
| 28 |
+
### Medium
|
| 29 |
+
Rank 3 HER2-positive metastatic breast cancer candidates by fit for a trial.
|
| 30 |
+
|
| 31 |
+
### Hard
|
| 32 |
+
Detect subtle exclusions from an AML screening note, including protocol deviations such as recent investigational treatment, active infection, QTc prolongation, and CYP3A4 inhibitor exposure.
|
| 33 |
+
|
| 34 |
+
## Reward Design
|
| 35 |
+
|
| 36 |
+
- `+0.20` for each correct clinical data point or valid deviation extracted
|
| 37 |
+
- `+1.00` for a correct final screening decision
|
| 38 |
+
- `-0.50` for hallucinated fields, invalid deviation claims, or destructive actions
|
| 39 |
+
|
| 40 |
+
Each task also produces a deterministic grader score in `(0.0, 1.0)`.
|
| 41 |
+
|
| 42 |
+
## Project Structure
|
| 43 |
+
|
| 44 |
+
```text
|
| 45 |
+
clinical_trial_env/
|
| 46 |
+
βββ .env
|
| 47 |
+
βββ Dockerfile
|
| 48 |
+
βββ README.md
|
| 49 |
+
βββ __init__.py
|
| 50 |
+
βββ client.py
|
| 51 |
+
βββ env.py
|
| 52 |
+
βββ inference.py
|
| 53 |
+
βββ models.py
|
| 54 |
+
βββ openenv.yaml
|
| 55 |
+
βββ pyproject.toml
|
| 56 |
+
βββ server/
|
| 57 |
+
βββ __init__.py
|
| 58 |
+
βββ app.py
|
| 59 |
+
βββ clinical_trial_env_environment.py
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
## Build And Run
|
| 63 |
+
|
| 64 |
+
Build the container from the project root:
|
| 65 |
+
|
| 66 |
+
```bash
|
| 67 |
+
docker build -t clinical-trial-env:latest .
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
Run the server locally:
|
| 71 |
+
|
| 72 |
+
```bash
|
| 73 |
+
docker run --rm -p 8000:8000 clinical-trial-env:latest
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
Validate the environment:
|
| 77 |
+
|
| 78 |
+
```bash
|
| 79 |
+
openenv validate .
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
## Inference
|
| 83 |
+
|
| 84 |
+
The root [inference.py](/Users/abhishekkanade/Desktop/Hackathon/OpenEnv/clinical_trial_env/inference.py) uses the OpenAI client and emits exactly:
|
| 85 |
+
|
| 86 |
+
- `[START]`
|
| 87 |
+
- `[STEP]`
|
| 88 |
+
- `[END]`
|
| 89 |
+
|
| 90 |
+
Required environment variables:
|
| 91 |
+
|
| 92 |
+
- `HF_TOKEN`
|
| 93 |
+
- `LOCAL_IMAGE_NAME` or `ENV_BASE_URL`
|
| 94 |
+
- `API_BASE_URL` optional, defaults to Hugging Face router
|
| 95 |
+
- `MODEL_NAME` optional
|
| 96 |
+
- `CLINICAL_TRIAL_TASK` with values `easy`, `medium`, or `hard`
|
| 97 |
+
|
| 98 |
+
Example:
|
| 99 |
+
|
| 100 |
+
```bash
|
| 101 |
+
set -a
|
| 102 |
+
source .env
|
| 103 |
+
set +a
|
| 104 |
+
python3 inference.py
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
## Python Usage
|
| 108 |
+
|
| 109 |
+
```python
|
| 110 |
+
import asyncio
|
| 111 |
+
|
| 112 |
+
from clinical_trial_env import ClinicalTrialAction, ClinicalTrialEnv
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
async def main() -> None:
|
| 116 |
+
env = await ClinicalTrialEnv.from_docker_image("clinical-trial-env:latest")
|
| 117 |
+
try:
|
| 118 |
+
result = await env.reset(task_id="easy")
|
| 119 |
+
result = await env.step(
|
| 120 |
+
ClinicalTrialAction(action_type="extract_data", field_name="age", value="56")
|
| 121 |
+
)
|
| 122 |
+
print(result.reward, result.observation.reward_details.grader_score)
|
| 123 |
+
finally:
|
| 124 |
+
await env.close()
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
asyncio.run(main())
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
## Audit Notes
|
| 131 |
+
|
| 132 |
+
- `reset()`, `step(action)`, and OpenEnv `state` access are implemented in [env.py](/Users/abhishekkanade/Desktop/Hackathon/OpenEnv/clinical_trial_env/env.py).
|
| 133 |
+
- Gold answers are not exposed through observation metadata.
|
| 134 |
+
- Graders are deterministic and bounded in `(0.0, 1.0)`.
|
| 135 |
+
- The hard task uses unstructured medical text and clinically realistic exclusion criteria.
|