Downloads · 30 days
0
kunalj890/clinical-trial-review
clinical-trial-review is a machine learning model from kunalj890. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
An OpenEnv-compatible evaluation environment where agents review full-length clinical trial protocols, highlight regulatory issues, and explain their reasoning. The repo contains the simulator, FastAPI surface used in…
Downloads · 30 days
0
Access
Public
Updated Apr 8, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.lock449 KB · 81%
From the Hugging Face model README
An OpenEnv-compatible evaluation environment where agents review full-length clinical trial protocols, highlight regulatory issues, and explain their reasoning. The repo contains the simulator, FastAPI surface used inside the Hugging Face Space, and a reference inference loop for benchmarking models.
app.py) exposes /reset, /step, and /state endpoints that plug directly into the Space UI or custom agentsenvironment/data/protocols/ with per-task annotations used for scoringinference.py) that can call any OpenAI-compatible endpoint (Hugging Face Inference, OpenAI, local gateways, etc.)| Path | Purpose |
|---|---|
environment/env.py | Core ClinicalTrialEnv class, schemas, reward functions |
environment/data/protocols/ | JSON protocols with sections, dosage info, and contradictions |
app.py | FastAPI wiring for /reset, /step, /state |
server/app.py | Uvicorn entry point used by Docker/HF Space |
inference.py | Baseline agent loop + logging utilities |
Dockerfile | Minimal image that runs uvicorn app:app on port 7860 |
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
uvicorn server.app:main --host 0.0.0.0 --port 7860
The Hugging Face Space uses the exact same command through the bundled Dockerfile.ENV_URL=http://127.0.0.1:7860 (default) before running agents/tests.| Method | Path | Body | Response |
|---|---|---|---|
POST | /reset?task_id=1 | none | First observation for the requested task |
POST | /step | {action_type, target_section, issue_description, severity} | Next observation + reward, done, info.total_reward |
GET | /state | none | Internal simulator state (for debugging/visualization) |
Example:
curl -X POST "http://localhost:7860/reset?task_id=2"
curl -X POST http://localhost:7860/step \
-H "Content-Type: application/json" \
-d '{
"action_type": "flag_issue",
"target_section": "dosage",
"issue_description": "DrugY dosage is 2400mg/day, above the 2000mg/day limit.",
"severity": "high"
}'
| Task ID | Focus | Success Criteria |
|---|---|---|
| 1 | Missing Section Detection | Flag every required protocol section that is absent, optionally approve sections that are present |
| 2 | Dosage Safety Compliance | Identify drug doses that exceed MAX_DRUG_DOSES in environment/data/rules.py and justify severity |
| 3 | Contradiction Detection | Point out conflicting statements between sections with references to both sides |
Protocols are sampled at reset time and contain sections plus a ground_truth blob (missing sections, unsafe dosages, contradictions) that drives the reward.
Observation model): trial_id, protocol_text, task_description, step_number, available_actionsAction model): JSON object with action_type (flag_issue, approve_section, recommend_amendment), target_section, issue_description, severityReward model): score in [0, 1], breakdown dict listing reward components, textual feedbackReward weights differ per task:
The reference agent in inference.py loops over the three tasks, logs every step, and prints a summary average. It talks to the environment via HTTP and to an OpenAI-compatible text model for decisions.
ENV_URL.export HF_TOKEN="hf_xxx" # required for Hugging Face text models
export MODEL_NAME="Qwen/Qwen2.5-72B-Instruct" # or any compatible chat-completions model
export API_BASE_URL="https://router.huggingface.co/v1" # defaults to OpenAI API
export ENV_URL="https://clinical-trial-review.hf.space" # optional when running against the Space
python inference.py to stream step-level logs and an overall average score. Logs follow the START/STEP/END pattern expected by OpenEnv submissions.sdk: docker with the provided Dockerfile. Any local change will be replicated by rebuilding and pushing the repo.docker build -t clinical-trial-review .
docker run -p 7860:7860 clinical-trial-review
Then run agents against http://localhost:7860.pip install -U "huggingface_hub[cli]"
huggingface-cli login
ORG/clinical-trial-review with your handle):
huggingface-cli repo create ORG/clinical-trial-review \
--type space --space-sdk docker
You can also create it from https://huggingface.co/spaces/new by choosing Docker as the SDK.git remote add hf https://huggingface.co/spaces/ORG/clinical-trial-review
git push hf main
Every subsequent push to hf will trigger a rebuild using the bundled Dockerfile.inference.py to call hosted models:
HF_TOKEN – token with access to the selected text modelMODEL_NAME, API_BASE_URL, ENV_URL – override defaults consumed by inference.pyApplication running on 0.0.0.0:7860, the environment is live at https://ORG-clinical-trial-review.hf.space.openenv.yaml documents the task metadata consumed by the OpenEnv leaderboard.pyproject.toml exposes a server entry point (python -m server.app) if you prefer pip install . workflows.GET /state to inspect accumulated actions and rewards.