aidarbek commited on
Commit
b6b71af
·
verified ·
1 Parent(s): 1f61262

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +155 -0
README.md ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ tags:
6
+ - code-generation
7
+ - security
8
+ - reinforcement-learning
9
+ - prime-intellect
10
+ - baxbench
11
+ - laguna
12
+ base_model: poolside/Laguna-XS.2
13
+ datasets:
14
+ - LogicStar/BaxBench
15
+ ---
16
+
17
+ # BaxBench × Prime Intellect — Secure Backend Code Generation
18
+
19
+ **One-line:** I wrapped the [BaxBench](https://arxiv.org/abs/2502.11844) secure-backend-code benchmark as a [Prime Intellect verifiers environment](https://app.primeintellect.ai/dashboard/environments/aidarbek/baxbench), used it to **benchmark Laguna-XS.2 against GPT-5.5**, and then **RL-trained Laguna-XS.2** on the train split — pass@1 on the held-out scenarios went from **0.061 → 0.115** (+87% relative) during training.
20
+
21
+ ---
22
+
23
+ ## Why this matters
24
+
25
+ The 2026 CrowdStrike Global Threat Report makes the timing impossible to ignore:
26
+
27
+ - **+89%** increase in attacks by AI-enabled adversaries
28
+ - **+42%** increase in zero-day vulnerabilities exploited before public disclosure
29
+ - **40%** of vulnerabilities exploited by China-nexus threat actors target edge devices
30
+ - **+266%** increase in cloud-conscious intrusions by state-nexus threat actors
31
+
32
+ LLMs are now the default starting point for new backend code. If the model defaults to writing apps with SQL injection, path traversal, weak crypto, or missing auth, we are mass-producing the next decade of CVEs. **"Does the code compile and pass tests" is no longer the right bar; "does the code compile, pass tests, AND not expose a CWE" is.** BaxBench was built exactly for this — and this submission is the missing piece: an executable, RL-ready version of that benchmark on Prime Intellect's infrastructure.
33
+
34
+ ---
35
+
36
+ ## What's in this repo
37
+
38
+ | File | What it is |
39
+ |---|---|
40
+ | `README.md` | This file. |
41
+ | `baxbench.parquet` | The 392-row task table (28 scenarios × 14 frameworks) extracted from the [original BaxBench](https://huggingface.co/datasets/LogicStar/BaxBench), enriched with everything needed for sandbox execution: API spec, allowed packages, entrypoint command, port, multi-file flag, etc. |
42
+ | `lora_adapter/` | The Laguna-XS.2 LoRA adapter produced by 40 GRPO steps on the BaxBench train split (`adapter_config.json` + `adapter_model.safetensors`, 4.6 GB). |
43
+ | `eval_training_curve.png` | Held-out pass@1 over the course of RL training (step 0 → step 40). |
44
+ | `baseline_vs_gpt55.txt` | Baseline comparison: Laguna-XS.2 vs GPT-5.5 on 100 random BaxBench tasks. |
45
+
46
+ External links:
47
+ - **Prime Intellect environment:** https://app.primeintellect.ai/dashboard/environments/aidarbek/baxbench
48
+ - **Original BaxBench paper:** https://arxiv.org/abs/2502.11844 — Vero et al., 2025
49
+ - **Original BaxBench dataset:** https://huggingface.co/datasets/LogicStar/BaxBench
50
+ - **Base model:** [poolside/Laguna-XS.2](https://huggingface.co/poolside/Laguna-XS.2)
51
+
52
+ ---
53
+
54
+ ## What was built
55
+
56
+ ### 1. BaxBench wrapped as a Prime Intellect verifiers environment
57
+
58
+ BaxBench upstream is a Python CLI that ships with Docker, runs each generated backend in a container, and tests it with both **functional tests** (does the API work?) and **security tests** (can it be exploited?). I ported it into a single `vf.SingleTurnEnv` that:
59
+
60
+ 1. Reads the 392-task parquet, builds the OpenAPI-style prompt for each (matching the upstream template exactly).
61
+ 2. Per rollout, **spins up a Prime Intellect sandbox** with the right Docker image for the task's framework.
62
+ 3. Uploads the model-generated code, installs scenario-specific deps (`apt: ffmpeg / poppler-utils / …`, `pip: imageio / pdfplumber / …`), starts the server, and runs every upstream functional + security test against it.
63
+ 4. Returns reward = `1.0` iff **all functional tests pass AND zero CWEs are flagged** — matching BaxBench's "secure pass@k" metric. Sub-metrics (functional pass rate, security pass rate) are also tracked.
64
+
65
+ The wrapper bundles a copy of the upstream BaxBench test suite into each sandbox and monkey-patches its Docker-bound helpers (`load_file_from_docker`, `process_still_running`, `execute_sql_on_docker`) to operate on the local filesystem / process tree — sound because the server and tests share a kernel namespace inside the sandbox.
66
+
67
+ Key engineering wins:
68
+ - **True held-out split.** The env exposes `split_by="scenario" | "framework" | "random" | "none"` so the RL training set never overlaps with the eval set at the scenario level (default: 22 train scenarios, 6 held-out). Same `split_seed` on training and eval keeps the holdout pinned across runs.
69
+ - **Per-rollout logging that survives `prime train logs --tail`.** Every sandbox emits an `OK` or `BAD` line with stderr + server log tails on failure — no more "results.json missing" without context.
70
+ - **Per-scenario dep install with retry.** Only 4 of 28 scenarios need extra system packages; installing per-scenario keeps each exec call short enough to dodge the sandbox gateway's 502s.
71
+
72
+ ### 2. Baseline benchmark: Laguna-XS.2 vs GPT-5.5
73
+
74
+ 100-sample pass@1 on a random Python-framework slice of BaxBench, scored with the env above:
75
+
76
+ | Metric | poolside/Laguna-XS.2 | openai/gpt-5.5 | Δ |
77
+ |---|---:|---:|---:|
78
+ | **pass@1 (secure + functional)** | **0.260** (26/100) | **0.550** (55/100) | **+0.290** |
79
+ | functional_pass_rate | 0.395 | 0.710 | +0.315 |
80
+ | security_pass_rate | 0.566 | 0.827 | +0.261 |
81
+ | wall clock | 10.5 min | 11.3 min | +0.8 min |
82
+ | avg output tokens | 5,150 | 2,942 | −2,208 |
83
+
84
+ Head-to-head on the same 100 tasks: GPT-5.5 won 33 tasks Laguna didn't; Laguna won 4 tasks GPT-5.5 didn't (clustered on Flask/aiohttp). The gap is bigger on functional correctness (+0.315) than on security (+0.261), meaning a smaller open model is closer to GPT-5.5 on "writing secure code" than on "writing working code" — exactly the signal that says RL on this benchmark is worth running.
85
+
86
+ ### 3. RL training of Laguna-XS.2
87
+
88
+ GRPO on the train split (22 scenarios × 4 Python frameworks = 88 tasks):
89
+
90
+ - 40 gradient steps, `batch_size=16`, `rollouts_per_example=8` (2 GRPO groups of 8 per step)
91
+ - LR 5e-6, temperature 0.7
92
+ - Online eval against the 6 held-out scenarios at steps 0, 10, 20, 30, 40
93
+
94
+ **Held-out pass@1 climbed 0.061 → 0.115 (+87% relative)** on scenarios the model never saw during training:
95
+
96
+ ![Training eval curve](eval_training_curve.png)
97
+
98
+ The LoRA adapter from step 39 is checked into `lora_adapter/`. Final inference-time eval on the trained adapter was blocked because `poolside/Laguna-XS.2` is currently gated for LoRA deployment on Prime Intellect's inference infra (`Error: Base model is not currently available for LoRA deployment`). The training-time eval curve above measures the same held-out 24 tasks at every checkpoint, scored by the same env code — apples-to-apples, just smaller sample size than the full 100-task baseline.
99
+
100
+ ---
101
+
102
+ ## How to reproduce
103
+
104
+ Install the env locally:
105
+ ```bash
106
+ prime env install aidarbek/baxbench
107
+ ```
108
+
109
+ Run the baseline:
110
+ ```bash
111
+ prime eval run aidarbek/baxbench \
112
+ -m openai/gpt-5.5 \
113
+ -n 100 -r 1 -c 16 \
114
+ -a '{"split_by": "none"}'
115
+ ```
116
+
117
+ Train Laguna-XS.2 with GRPO (requires Laguna training access + Prime Hosted Training):
118
+ ```bash
119
+ prime train configs/rl/laguna-baxbench.toml -e PRIME_API_KEY -y
120
+ ```
121
+ where `configs/rl/laguna-baxbench.toml` matches the values described above (40 steps, batch_size=16, rollouts_per_example=8, split_by="scenario" with `test_size=0.2, split_seed=42`).
122
+
123
+ To serve this LoRA adapter once Prime enables Laguna LoRA deployment:
124
+ ```bash
125
+ prime deployments create <adapter_id> -y
126
+ prime eval run aidarbek/baxbench \
127
+ -m <deployed_model_id> \
128
+ -n 100 -r 1 -c 16 \
129
+ -a '{"split_by": "scenario", "test_size": 0.2, "split_seed": 42}'
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Limitations and honest caveats
135
+
136
+ - **24-task held-out set has low resolution.** Each percentage point ≈ 0.27 tasks. The 0.061 → 0.115 trend is real but individual data points are noisy.
137
+ - **Truncation rate dropped 79% → 58% during training.** Some of the improvement may come from "produce a shorter, finishable answer" rather than "write better code." That's still a real and useful capability.
138
+ - **No standalone post-RL eval.** Until Prime enables LoRA serving for Laguna, the training-time eval is the only signal. Once unblocked, a full 100-task standalone `prime eval run` is the next number to publish.
139
+ - **Python only.** The wrapper supports Go / JavaScript / Ruby / PHP / Rust tasks via per-language Docker images, but only Python is currently dep-tested end-to-end. Default `languages=["Python"]` reflects this.
140
+
141
+ ---
142
+
143
+ ## Citation
144
+
145
+ If you use this work, please also cite the original BaxBench paper:
146
+
147
+ ```bibtex
148
+ @article{vero2025baxbenchllmsgeneratecorrect,
149
+ title = {BaxBench: Can LLMs Generate Correct and Secure Backends?},
150
+ author = {Mark Vero and Niels Mündler and Victor Chibotaru and Veselin Raychev and Maximilian Baader and Nikola Jovanović and Jingxuan He and Martin Vechev},
151
+ year = {2025},
152
+ eprint = {2502.11844},
153
+ archivePrefix = {arXiv},
154
+ }
155
+ ```