Spaces:
Runtime error
Runtime error
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,421 +1,432 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
<
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
</
|
| 17 |
-
|
| 18 |
-
<p align="center">
|
| 19 |
-
|
| 20 |
-
</p>
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
- [
|
| 41 |
-
- [
|
| 42 |
-
-
|
| 43 |
-
|
| 44 |
-
- [
|
| 45 |
-
|
| 46 |
-
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
- [
|
| 51 |
-
|
| 52 |
-
--
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
```
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
β
|
| 106 |
-
β
|
| 107 |
-
β β
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
β
|
| 112 |
-
β
|
| 113 |
-
β β
|
| 114 |
-
β
|
| 115 |
-
β
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
β
|
| 122 |
-
β
|
| 123 |
-
β
|
| 124 |
-
β
|
| 125 |
-
ββββββββββββ
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
#
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
#
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
#
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
##
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
``
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
β βββ
|
| 247 |
-
β
|
| 248 |
-
β
|
| 249 |
-
βββ
|
| 250 |
-
β
|
| 251 |
-
β
|
| 252 |
-
|
| 253 |
-
β
|
| 254 |
-
|
| 255 |
-
β
|
| 256 |
-
βββ
|
| 257 |
-
βββ
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
βββ
|
| 264 |
-
βββ
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
βββ
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
#
|
| 274 |
-
|
| 275 |
-
#
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
|
| 295 |
-
|
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
--
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: ReproAgent
|
| 3 |
+
emoji: π¬
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: indigo
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 4.12.0
|
| 8 |
+
app_file: server/app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
<p align="center">
|
| 13 |
+
<img src="assets/banner.png" alt="ReproAgent Banner" width="100%"/>
|
| 14 |
+
</p>
|
| 15 |
+
|
| 16 |
+
<h1 align="center">π¬ ReproAgent</h1>
|
| 17 |
+
|
| 18 |
+
<p align="center">
|
| 19 |
+
<strong>An AI-powered agent that automatically reproduces machine learning research papers.</strong>
|
| 20 |
+
</p>
|
| 21 |
+
|
| 22 |
+
<p align="center">
|
| 23 |
+
<a href="#-features"><img src="https://img.shields.io/badge/Features-8-blue?style=for-the-badge" alt="Features"/></a>
|
| 24 |
+
<a href="#-quick-start"><img src="https://img.shields.io/badge/Python-3.10+-green?style=for-the-badge&logo=python&logoColor=white" alt="Python"/></a>
|
| 25 |
+
<a href="#-license"><img src="https://img.shields.io/badge/License-MIT-orange?style=for-the-badge" alt="License"/></a>
|
| 26 |
+
<a href="https://huggingface.co/spaces"><img src="https://img.shields.io/badge/π€-HuggingFace_Spaces-yellow?style=for-the-badge" alt="HF Spaces"/></a>
|
| 27 |
+
</p>
|
| 28 |
+
|
| 29 |
+
<p align="center">
|
| 30 |
+
Upload a research paper PDF β ReproAgent reads it β finds the repo β clones the code β sets up the environment β runs it β debugs errors β tunes hyperparameters β compares results.
|
| 31 |
+
</p>
|
| 32 |
+
|
| 33 |
+
---
|
| 34 |
+
|
| 35 |
+
## π OpenEnv Hackathon Submission
|
| 36 |
+
|
| 37 |
+
This project is submitted to the **OpenEnv Hackathon**. It is a fully compliant environment built on top of the framework.
|
| 38 |
+
|
| 39 |
+
### Required Materials
|
| 40 |
+
- **Hugging Face Space**: [ReproAgent Live Demo](https://huggingface.co/spaces/username/reproagent)
|
| 41 |
+
- **Training Script (TRL/PPO)**: [Colab Notebook](training/train_reproagent.ipynb)
|
| 42 |
+
- **Evidence of Training**: We trained the agent using Proximal Policy Optimization (PPO) over 50 episodes.
|
| 43 |
+
<br><img src="assets/reward_plot.png" alt="Reward Plot" width="400"/> <img src="assets/loss_plot.png" alt="Loss Plot" width="400"/>
|
| 44 |
+
- **Presentation**: [Mini-Blog on HuggingFace](https://huggingface.co/blog/reproagent-openenv) / [YouTube Demo (< 2 minutes)](https://youtube.com/watch?v=demo_link)
|
| 45 |
+
|
| 46 |
+
---
|
| 47 |
+
|
| 48 |
+
## π Table of Contents
|
| 49 |
+
|
| 50 |
+
- [Overview](#-overview)
|
| 51 |
+
- [Features](#-features)
|
| 52 |
+
- [Architecture](#-architecture)
|
| 53 |
+
- [Quick Start](#-quick-start)
|
| 54 |
+
- [Usage](#-usage)
|
| 55 |
+
- [Project Structure](#-project-structure)
|
| 56 |
+
- [Configuration](#-configuration)
|
| 57 |
+
- [How It Works](#-how-it-works)
|
| 58 |
+
- [Validation](#-validation)
|
| 59 |
+
- [Docker Deployment](#-docker-deployment)
|
| 60 |
+
- [Contributing](#-contributing)
|
| 61 |
+
- [License](#-license)
|
| 62 |
+
|
| 63 |
+
---
|
| 64 |
+
|
| 65 |
+
## π Overview
|
| 66 |
+
|
| 67 |
+
**ReproAgent** is an AI-driven framework built on [OpenAI Gymnasium](https://gymnasium.farama.org/) that automates the end-to-end reproduction of machine learning research papers. Given a PDF, it autonomously:
|
| 68 |
+
|
| 69 |
+
1. **Parses** the paper to extract title, metrics, datasets, and GitHub links
|
| 70 |
+
2. **Clones** the linked repository
|
| 71 |
+
3. **Sets up** the environment (conda/venv) and installs dependencies
|
| 72 |
+
4. **Runs** inference or training scripts
|
| 73 |
+
5. **Debugs** errors using real traceback analysis
|
| 74 |
+
6. **Tunes** hyperparameters to close the gap between reproduced and claimed results
|
| 75 |
+
7. **Compares** final metrics against the paper's claims
|
| 76 |
+
|
| 77 |
+
It supports both a **Simulation** mode (safe, no system changes) and a **Real Execution** mode (actually clones repos, creates envs, runs code on your machine).
|
| 78 |
+
|
| 79 |
+
---
|
| 80 |
+
|
| 81 |
+
## β¨ Features
|
| 82 |
+
|
| 83 |
+
| Feature | Description |
|
| 84 |
+
|---------|-------------|
|
| 85 |
+
| π **PDF Parsing** | Extracts metadata using Groq LLM (llama-3.3-70b) with regex fallback |
|
| 86 |
+
| π **Repo Discovery** | Finds GitHub links from paper text, cleans trailing punctuation |
|
| 87 |
+
| π¦ **Smart Environment Setup** | Auto-detects `requirements.txt`, `environment.yml`, or `pyproject.toml` and creates the correct env (pip venv or conda) |
|
| 88 |
+
| π§ **Intelligent Entry Point** | Scans for `inference.py`, `eval.py`, `main.py`, `train.py`, or extracts scripts from README bash blocks |
|
| 89 |
+
| π **Real Error Debugging** | Captures actual `stderr` tracebacks and feeds them into the debugging pipeline |
|
| 90 |
+
| π§ͺ **Hyperparameter Tuning** | Modifies learning rate, batch size, optimizer, and epochs to reproduce paper metrics |
|
| 91 |
+
| π **Dynamic Metric Extraction** | Extracts the actual evaluation metric (FID, BLEU, accuracy, PSNR, etc.) from the paper β not hardcoded |
|
| 92 |
+
| π₯οΈ **Gradio Web UI** | Beautiful web interface with live logs, state tracking, and result visualization |
|
| 93 |
+
|
| 94 |
+
---
|
| 95 |
+
|
| 96 |
+
## ποΈ Architecture
|
| 97 |
+
|
| 98 |
+
```
|
| 99 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 100 |
+
β Gradio Web UI β
|
| 101 |
+
β (server/app.py) β
|
| 102 |
+
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
|
| 103 |
+
β
|
| 104 |
+
ββββββββββββββΌβββββββββββββ
|
| 105 |
+
β Reasoning Agent β
|
| 106 |
+
β (agents/reasoning_ β
|
| 107 |
+
β agent.py) β
|
| 108 |
+
ββββββββββββββ¬βββββββββββββ
|
| 109 |
+
β select_action()
|
| 110 |
+
ββββββββββββββΌβββββββββββββ
|
| 111 |
+
β Gymnasium Environment β
|
| 112 |
+
β (reproagent/ β
|
| 113 |
+
β environment.py) β
|
| 114 |
+
β β
|
| 115 |
+
β βββββββββββββββββββ β
|
| 116 |
+
β β State Machine β β
|
| 117 |
+
β β βββββββββββββ β β
|
| 118 |
+
β β β Parsing β β β
|
| 119 |
+
β β β RepoAnalysβ β β
|
| 120 |
+
β β β Setup β β β
|
| 121 |
+
β β β Execution β β β
|
| 122 |
+
β β β Debugging β β β
|
| 123 |
+
β β β Experimentβ β β
|
| 124 |
+
β β β Comparisonβ β β
|
| 125 |
+
β β βββββββββββββ β β
|
| 126 |
+
β βββββββββββββββββββ β
|
| 127 |
+
βββββββββββββββββββββββββββ
|
| 128 |
+
β β
|
| 129 |
+
ββββββββββββ ββββββββββββ
|
| 130 |
+
βΌ βΌ
|
| 131 |
+
βββββββββββββββββ ββββββββββββββββββ
|
| 132 |
+
β Simulation β β Real Execution β
|
| 133 |
+
β (mock state β β (subprocess, β
|
| 134 |
+
β transitions)β β git clone, β
|
| 135 |
+
β β β conda/venv) β
|
| 136 |
+
βββββββββββββββββ ββββββββββββββββββ
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
---
|
| 140 |
+
|
| 141 |
+
## π Quick Start
|
| 142 |
+
|
| 143 |
+
### Prerequisites
|
| 144 |
+
|
| 145 |
+
- **Python** 3.10+
|
| 146 |
+
- **Git** (for real execution mode)
|
| 147 |
+
- **Conda** (optional, for repos that use `environment.yml`)
|
| 148 |
+
- A **Groq API key** (free at [console.groq.com](https://console.groq.com))
|
| 149 |
+
|
| 150 |
+
### Installation
|
| 151 |
+
|
| 152 |
+
```bash
|
| 153 |
+
# 1. Clone the repository
|
| 154 |
+
git clone https://github.com/your-username/ReproAgent.git
|
| 155 |
+
cd ReproAgent
|
| 156 |
+
|
| 157 |
+
# 2. Create a virtual environment
|
| 158 |
+
python -m venv venv
|
| 159 |
+
|
| 160 |
+
# Windows
|
| 161 |
+
.\venv\Scripts\activate
|
| 162 |
+
|
| 163 |
+
# macOS/Linux
|
| 164 |
+
source venv/bin/activate
|
| 165 |
+
|
| 166 |
+
# 3. Install dependencies
|
| 167 |
+
pip install -r requirements.txt
|
| 168 |
+
|
| 169 |
+
# 4. Set up environment variables
|
| 170 |
+
cp .env.example .env
|
| 171 |
+
# Edit .env and add your GROQ_API_KEY
|
| 172 |
+
```
|
| 173 |
+
|
| 174 |
+
### Run
|
| 175 |
+
|
| 176 |
+
```bash
|
| 177 |
+
# Launch the Gradio web interface
|
| 178 |
+
python server/app.py
|
| 179 |
+
```
|
| 180 |
+
|
| 181 |
+
The UI will be available at `http://localhost:7860` with a public share link.
|
| 182 |
+
|
| 183 |
+
---
|
| 184 |
+
|
| 185 |
+
## π» Usage
|
| 186 |
+
|
| 187 |
+
### Web Interface (Recommended)
|
| 188 |
+
|
| 189 |
+
1. Open the Gradio UI at `http://localhost:7860`
|
| 190 |
+
2. **Upload** a research paper PDF (or paste a URL)
|
| 191 |
+
3. Choose **Execution Mode**:
|
| 192 |
+
- `Simulation` β Safe demo, no system changes
|
| 193 |
+
- `Real Execution` β Actually clones repos and runs code
|
| 194 |
+
4. Set **Clone Directory** (where repos will be cloned, e.g. `D:\reproductions`)
|
| 195 |
+
5. Click **Start Reproduction** and watch the agent work in real-time
|
| 196 |
+
|
| 197 |
+
### Command Line
|
| 198 |
+
|
| 199 |
+
```bash
|
| 200 |
+
# Run validation to ensure everything works
|
| 201 |
+
python validate.py
|
| 202 |
+
|
| 203 |
+
# Run a quick inference test
|
| 204 |
+
python inference.py
|
| 205 |
+
```
|
| 206 |
+
|
| 207 |
+
### Programmatic API
|
| 208 |
+
|
| 209 |
+
```python
|
| 210 |
+
from reproagent.environment import ReproAgentEnv
|
| 211 |
+
from agents.reasoning_agent import create_agent
|
| 212 |
+
|
| 213 |
+
# Create environment
|
| 214 |
+
env = ReproAgentEnv(
|
| 215 |
+
difficulty="easy",
|
| 216 |
+
max_steps=100,
|
| 217 |
+
use_llm=True,
|
| 218 |
+
exec_mode="Real Execution",
|
| 219 |
+
workspace_dir="./workspace"
|
| 220 |
+
)
|
| 221 |
+
|
| 222 |
+
# Create agent
|
| 223 |
+
agent = create_agent(env, agent_type="reasoning", use_llm=True)
|
| 224 |
+
|
| 225 |
+
# Run episode
|
| 226 |
+
obs, info = env.reset()
|
| 227 |
+
agent.reset()
|
| 228 |
+
|
| 229 |
+
for step in range(100):
|
| 230 |
+
action = agent.select_action(obs, info)
|
| 231 |
+
obs, reward, terminated, truncated, info = env.step(action)
|
| 232 |
+
|
| 233 |
+
print(f"Step {step}: {info['action_type']} | reward={reward:.2f}")
|
| 234 |
+
|
| 235 |
+
if terminated or truncated:
|
| 236 |
+
break
|
| 237 |
+
```
|
| 238 |
+
|
| 239 |
+
---
|
| 240 |
+
|
| 241 |
+
## π Project Structure
|
| 242 |
+
|
| 243 |
+
```
|
| 244 |
+
ReproAgent/
|
| 245 |
+
βββ reproagent/ # Core Gymnasium environment
|
| 246 |
+
β βββ __init__.py
|
| 247 |
+
β βββ environment.py # Main env with action implementations
|
| 248 |
+
β βββ state.py # Dataclasses for full reproduction state
|
| 249 |
+
β βββ actions.py # Action space definition (30+ actions)
|
| 250 |
+
β βββ reward.py # Multi-component reward function
|
| 251 |
+
β βββ models.py # LLM client (Groq, OpenAI, HuggingFace)
|
| 252 |
+
β βββ papers.py # Paper dataset loader
|
| 253 |
+
β
|
| 254 |
+
βββ agents/ # Agent implementations
|
| 255 |
+
β βββ reasoning_agent.py # Phase-based reasoning agent
|
| 256 |
+
β βββ paper_parser.py # PDF text extraction + LLM analysis
|
| 257 |
+
β βββ repo_analyzer.py # Repository structure analysis
|
| 258 |
+
β βββ debugger.py # Error traceback analysis
|
| 259 |
+
β
|
| 260 |
+
βββ server/
|
| 261 |
+
β βββ app.py # Gradio web interface (900+ lines)
|
| 262 |
+
β
|
| 263 |
+
βββ utils/
|
| 264 |
+
β βββ pdf_reader.py # PDF extraction (PyPDF2 + pdfplumber)
|
| 265 |
+
β βββ github_utils.py # GitHub API utilities
|
| 266 |
+
β
|
| 267 |
+
βββ graders/ # Reproduction quality grading
|
| 268 |
+
βββ data/papers/ # Sample paper configs (easy/medium/hard)
|
| 269 |
+
βββ baseline/ # Baseline agent implementations
|
| 270 |
+
βββ static/ # Static assets for UI
|
| 271 |
+
β
|
| 272 |
+
βββ validate.py # Full validation suite
|
| 273 |
+
βββ inference.py # CLI inference entry point
|
| 274 |
+
βββ openenv.yaml # OpenEnv compatibility spec
|
| 275 |
+
βββ pyproject.toml # Python project metadata
|
| 276 |
+
βββ requirements.txt # pip dependencies
|
| 277 |
+
βββ Dockerfile # Container deployment
|
| 278 |
+
βββ run.bat / run.sh / run.ps1 # Platform-specific launchers
|
| 279 |
+
βββ .env.example # Environment variable template
|
| 280 |
+
```
|
| 281 |
+
|
| 282 |
+
---
|
| 283 |
+
|
| 284 |
+
## βοΈ Configuration
|
| 285 |
+
|
| 286 |
+
### Environment Variables
|
| 287 |
+
|
| 288 |
+
Create a `.env` file from the template:
|
| 289 |
+
|
| 290 |
+
```bash
|
| 291 |
+
cp .env.example .env
|
| 292 |
+
```
|
| 293 |
+
|
| 294 |
+
| Variable | Required | Description |
|
| 295 |
+
|----------|----------|-------------|
|
| 296 |
+
| `GROQ_API_KEY` | **Yes** | Groq API key for LLM-powered extraction ([get one free](https://console.groq.com)) |
|
| 297 |
+
| `OPENAI_API_KEY` | No | OpenAI API key (alternative LLM backend) |
|
| 298 |
+
| `HF_TOKEN` | No | HuggingFace token for model downloads |
|
| 299 |
+
| `GITHUB_TOKEN` | No | GitHub API token for higher rate limits |
|
| 300 |
+
|
| 301 |
+
### Execution Modes
|
| 302 |
+
|
| 303 |
+
| Mode | What it does | Use case |
|
| 304 |
+
|------|-------------|----------|
|
| 305 |
+
| **Simulation** | Simulates all actions with mock state transitions | Safe demos, hackathons, testing |
|
| 306 |
+
| **Real Execution** | Runs `git clone`, `conda env create`, `pip install`, `python script.py` on your system | Actually reproducing papers |
|
| 307 |
+
|
| 308 |
+
---
|
| 309 |
+
|
| 310 |
+
## π How It Works
|
| 311 |
+
|
| 312 |
+
The agent follows a **phase-based state machine** with 7 phases:
|
| 313 |
+
|
| 314 |
+
```
|
| 315 |
+
PARSING β REPO_ANALYSIS β SETUP β EXECUTION β DEBUGGING β EXPERIMENTATION β COMPARISON
|
| 316 |
+
```
|
| 317 |
+
|
| 318 |
+
### Phase Details
|
| 319 |
+
|
| 320 |
+
| Phase | Actions | What Happens |
|
| 321 |
+
|-------|---------|--------------|
|
| 322 |
+
| **Parsing** | `PARSE_PDF`, `EXTRACT_GITHUB`, `EXTRACT_METRICS` | LLM reads paper, extracts title, GitHub URL, target metric (e.g., FID=7.5) |
|
| 323 |
+
| **Repo Analysis** | `CLONE_REPO`, `READ_README`, `FIND_ENTRY_POINT`, `EXTRACT_DEPS` | Clones repo, reads README, finds scripts from bash blocks, detects `environment.yml` |
|
| 324 |
+
| **Setup** | `CREATE_VENV`, `INSTALL_REQUIREMENTS`, `VERIFY_SETUP` | Creates conda/venv env, installs deps, verifies setup |
|
| 325 |
+
| **Execution** | `RUN_TRAINING`, `RUN_EVAL`, `CHECK_LOGS` | Runs the entry point script via subprocess, captures stdout/stderr |
|
| 326 |
+
| **Debugging** | `ANALYZE_ERROR`, `SEARCH_SOLUTION`, `APPLY_FIX` | Parses real Python tracebacks, proposes and applies fixes |
|
| 327 |
+
| **Experimentation** | `MODIFY_LR`, `MODIFY_BATCH`, `RUN_EXPERIMENT` | Tunes hyperparameters to close the metric gap |
|
| 328 |
+
| **Comparison** | `COMPARE_RESULTS`, `GENERATE_REPORT` | Compares reproduced metric vs. paper claim, generates summary |
|
| 329 |
+
|
| 330 |
+
### Reward Function
|
| 331 |
+
|
| 332 |
+
The environment provides a multi-component reward signal:
|
| 333 |
+
|
| 334 |
+
- **Phase progress** (+10 for advancing through phases)
|
| 335 |
+
- **Code execution** (+20 for successful script runs)
|
| 336 |
+
- **Error fixing** (+15 per resolved error)
|
| 337 |
+
- **Metric improvement** (scaled by how close the reproduced result is to the paper's claim)
|
| 338 |
+
- **Time penalty** (-0.01 per step to encourage efficiency)
|
| 339 |
+
|
| 340 |
+
---
|
| 341 |
+
|
| 342 |
+
## β
Validation
|
| 343 |
+
|
| 344 |
+
Run the full validation suite to confirm everything works:
|
| 345 |
+
|
| 346 |
+
```bash
|
| 347 |
+
python validate.py
|
| 348 |
+
```
|
| 349 |
+
|
| 350 |
+
This tests:
|
| 351 |
+
|
| 352 |
+
| Test | What it validates |
|
| 353 |
+
|------|-------------------|
|
| 354 |
+
| Environment | `ReproAgentEnv` creates, resets, steps correctly |
|
| 355 |
+
| Spaces | Observation and action spaces match the Gymnasium spec |
|
| 356 |
+
| Episodes | Full multi-step episodes run without crashes |
|
| 357 |
+
| Agents | `ReasoningAgent` and `RandomAgent` interact with the env |
|
| 358 |
+
| Demo | Gradio app imports successfully |
|
| 359 |
+
| Graders | Reproduction quality grader loads |
|
| 360 |
+
| OpenEnv | `openenv.yaml` is present and well-formed |
|
| 361 |
+
|
| 362 |
+
Expected output:
|
| 363 |
+
|
| 364 |
+
```
|
| 365 |
+
ENVIRONMENT β
PASSED
|
| 366 |
+
AGENTS β
PASSED
|
| 367 |
+
DEMO β
PASSED
|
| 368 |
+
GRADERS β
PASSED
|
| 369 |
+
OPENENV_YAML β
PASSED
|
| 370 |
+
|
| 371 |
+
π ALL VALIDATIONS PASSED!
|
| 372 |
+
β
System is ready for deployment
|
| 373 |
+
```
|
| 374 |
+
|
| 375 |
+
---
|
| 376 |
+
|
| 377 |
+
## π³ Docker Deployment
|
| 378 |
+
|
| 379 |
+
```bash
|
| 380 |
+
# Build the image
|
| 381 |
+
docker build -t reproagent .
|
| 382 |
+
|
| 383 |
+
# Run with your API key
|
| 384 |
+
docker run -p 7860:7860 -e GROQ_API_KEY=your_key_here reproagent
|
| 385 |
+
```
|
| 386 |
+
|
| 387 |
+
Or deploy to **HuggingFace Spaces**:
|
| 388 |
+
|
| 389 |
+
```bash
|
| 390 |
+
pip install gradio
|
| 391 |
+
gradio deploy
|
| 392 |
+
```
|
| 393 |
+
|
| 394 |
+
---
|
| 395 |
+
|
| 396 |
+
## π£οΈ Roadmap
|
| 397 |
+
|
| 398 |
+
- [x] Gymnasium-compatible environment with 30+ actions
|
| 399 |
+
- [x] Groq LLM integration with regex fallback
|
| 400 |
+
- [x] Gradio web interface with live logs
|
| 401 |
+
- [x] Real Execution mode (git clone, conda/venv, subprocess)
|
| 402 |
+
- [x] Dynamic metric extraction (FID, BLEU, accuracy, PSNR, etc.)
|
| 403 |
+
- [x] Bash block parsing from README for entry point discovery
|
| 404 |
+
- [ ] Multi-script sequential execution (run 5 scripts in order per README)
|
| 405 |
+
- [ ] Automatic checkpoint downloading from HuggingFace
|
| 406 |
+
- [ ] GPU-aware execution scheduling
|
| 407 |
+
- [ ] Result visualization and plot generation
|
| 408 |
+
- [ ] Support for Jupyter notebook-based repos
|
| 409 |
+
|
| 410 |
+
---
|
| 411 |
+
|
| 412 |
+
## π€ Contributing
|
| 413 |
+
|
| 414 |
+
Contributions are welcome! Please:
|
| 415 |
+
|
| 416 |
+
1. Fork the repository
|
| 417 |
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
| 418 |
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
| 419 |
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
| 420 |
+
5. Open a Pull Request
|
| 421 |
+
|
| 422 |
+
---
|
| 423 |
+
|
| 424 |
+
## π License
|
| 425 |
+
|
| 426 |
+
This project is licensed under the **MIT License** β see the [LICENSE](LICENSE) file for details.
|
| 427 |
+
|
| 428 |
+
---
|
| 429 |
+
|
| 430 |
+
<p align="center">
|
| 431 |
+
Built with β€οΈ for the ML research community
|
| 432 |
+
</p>
|