Repository navigation
Conversation
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%.
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Combined regex sub-patterns per feature category into a single pre-compiled regex
(?:p1)|(?:p2)...inaisec/poison.py.🎯 Why: In
_sentence_score(), evaluating whether a sentence triggered any pattern in each feature category looped through multiple compiled regexes usingany(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.POSITIVESbefore and after changes and validated test suite withpython3 -m pytest.PR created automatically by Jules for task 8116553950359209817 started by @Pyhroff