joywin2003/crispr-editing-env
crispr-editing-env v2
A tool-based OpenEnv environment for CRISPR gene editing. An AI agent uses bioinformatics tools to analyze DNA sequences, find PAM sites, design guide RNAs, evaluate off-target risks, and apply precision edits under resource constraints.
Why CRISPR?
CRISPR guide RNA design is a real-world bioinformatics task requiring multi-step investigation: researchers must find PAM sites, design guides, evaluate safety, and manage limited experimental resources. This environment models that workflow as a sequential tool-use problem for LLM agents.
Action Space (8 Bioinformatics Tools)
The agent sends free-form tool commands as actions. Budget limits prevent brute-force approaches.
Observation Space
No pre-computed guide candidates or utility scores. The agent must discover everything through tool use.
Tasks (3 Qualitatively Different)
Grading
- Easy: 70% correction + 20% safety + 10% efficiency
- Medium: 50% correction + 25% safety + 15% efficiency + 10% grouping bonus
- Hard: 35% correction + 25% safety + 30% regulatory integrity (binary!) + 10% efficiency
Baseline Scores (Greedy Agent, 10 seeds)
single_target : avg=0.77
multi_repair : avg=0.63
precision_editing : avg=0.49The greedy baseline searches for the nearest PAM site and applies without evaluating off-targets. On the hard task, this frequently damages the regulatory region.
Setup & Usage
Install locally
pip install -r requirements.txt
python inference.py # LLM inference (needs HF_TOKEN)Docker
docker build -t crispr-editing-env .
docker run --rm -p 7860:7860 crispr-editing-envAPI Endpoints
# Health check
curl http://localhost:7860/
# Reset environment
curl -X POST http://localhost:7860/reset \
-H "Content-Type: application/json" \
-d '{"task_level": "single_target", "seed": 42}'
# Take a step
curl -X POST http://localhost:7860/step \
-H "Content-Type: application/json" \
-d '{"action": "search_pam_sites NGG"}'
# Get current state
curl http://localhost:7860/state
# List tasks
curl http://localhost:7860/tasksEnvironment Variables
export API_BASE_URL="https://router.huggingface.co/v1"
export MODEL_NAME="Qwen/Qwen2.5-72B-Instruct"
export HF_TOKEN="your-token-here"
python inference.pyProject Structure
crispr-editing-env/
├── server/
│ ├── app.py # FastAPI server (reset/step/state/tasks)
│ ├── environment.py # CrisprEnv: tool dispatch engine
│ ├── models.py # Pydantic models
│ ├── simulation.py # PAM search, guide design, off-target scan
│ ├── tasks.py # 3 task generators
│ ├── graders.py # Final scoring logic
│ └── reward.py # Step-level rewards + tool costs
├── app.py # Root re-export for Dockerfile
├── inference.py # LLM agent with [START]/[STEP]/[END] format
├── openenv.yaml # OpenEnv spec metadata
├── Dockerfile
├── pyproject.toml
└── requirements.txt