r/learnmachinelearning • u/spartanarun04 • 21h ago
Project [P] The detection rule memorized the test: held-out evaluation of LLM agents writing security rules
I evaluated four ways of getting an LLM to write SIEM detection rules (Sigma), graded only on held-out events the model never saw:
| Method (gpt-4.1-mini, 75 runs each) | Passed |
|---|---|
| Naive prompt | 0/75 |
| Prompt + schema/rules/benign samples | 7/75 |
| + one compile-fix retry | 10/75 |
| Tool-calling test-and-revise agent | 40/75 |
Agent vs each baseline: Fisher exact p < 0.001. On gpt-4.1 (separate, earlier held-out set, 25 runs each) the context baseline got 14/25 and the agent 17/25, not significant (p ≈ 0.56).
Eval lessons that I think generalize:
- Per-event feedback teaches memorization. The agent patched a missed role name into its regex: 5/5 clean on the visible set, 0/5 on held-out. Splitting the practice set into visible (per-event) and hidden (counts only) removed the payoff.
- Prompts don't enforce workflow. gpt-4.1 skipped validation in 11/25 runs. The harness now decides when the agent is done and submits the best tested rule, not the last.
- Held-out sets go stale once you read their failures. I retired and rewrote mine 5 times.
- Grade behavior, and check what replay ignores. None of 102 passing rules carried ATT&CK tags; the harness now normalizes metadata and the gate checks it (re-grading 400 stored rules changed no verdict).
Limits: synthetic, small corpus (38 events/scenario), one model family.
Code and raw per-run results: https://github.com/ramaswaa/sigmaseal Walkthrough: https://ramaswaa.github.io/sigmaseal/article/
1
u/Otherwise-Bat2036 8h ago
Point 3 is the one I wish more people took seriously. Once you've read the failures on a held-out set, you start designing around them, even without meaning to. One thing that's helped: keep a small final set you almost never look at, and use it only to confirm a result before you trust it.
The visible/hidden split for feedback is a neat fix. I'd be curious whether the hidden counts also leak over many iterations, since an agent seeing only counts can still hill-climb on them if it gets enough tries.
On the gpt-4.1 result, I wouldn't read too much into 25 runs either way. But it does make me wonder whether the test-and-revise loop helps the smaller model more because it makes up for weaker first drafts. Did you look at how many revise rounds each model needed?