Skip to content

⚡ Bolt: combine regex patterns in poison score evaluation - #53

Open
Pyhroff wants to merge 1 commit into
masterfrom
bolt/combine-poison-cat-regex-8116553950359209817
Open

Pyhroff wants to merge 1 commit into
masterfrom
bolt/combine-poison-cat-regex-8116553950359209817

Conversation

@Pyhroff

@Pyhroff Pyhroff commented Oct 31, 2026

Copy link
Copy Markdown
Owner

💡 What: Combined regex sub-patterns per feature category into a single pre-compiled regex (?:p1)|(?:p2)... in aisec/poison.py.
🎯 Why: In _sentence_score(), evaluating whether a sentence triggered any pattern in each feature category looped through multiple compiled regexes using any(rx.search(sent) for rx in _CAT[name]), resulting in ~24 regex search operations and generator overhead per sentence.
📊 Impact: Reduces regex searches per sentence from ~24 to 7. Benchmark across all 108 positive benchmark attacks demonstrated an ~18.5% overall speedup (from 1.46s to 1.19s across 20 runs) with 100% output equivalence.
🔬 Measurement: Benchmarked against benchmarks.poison.attacks.POSITIVES before and after changes and validated test suite with python3 -m pytest.


PR created automatically by Jules for task 8116553950359209817 started by @Pyhroff

Combine regex sub-patterns per feature category into a single pre-compiled
regex in aisec/poison.py. This reduces regex searches per sentence evaluation
from ~24 calls down to 7 calls, improving text scoring performance by ~18-20%.
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant