Add Combination Attack - #3
Open
ishayyemini wants to merge 73 commits into
Open
Conversation
and unified init trigger
# Conflicts: # .github/workflows/deploy_docs.yml # README.md # docs/api/attack_zoo.rst # docs/api/loss.rst # docs/api/models.rst # docs/api/optimizer.rst # docs/build_docs.py # pyproject.toml # scripts/attack_evaluate/evaluate_jailbreakness.py # tests/models/huggingface/test_encoder.py # tests/models/huggingface/test_lm.py # tests/optimizer/test_base_optimizer.py # tests/optimizer/test_gaslite_optimizer.py # tests/optimizer/test_gcg_optimizer.py # tests/optimizer/test_rasliteplus_optimizer.py # tropt/attack_zoo/RASLITEPlus.py # tropt/common.py # tropt/loss/__init__.py # tropt/loss/base.py # tropt/models/__init__.py # tropt/models/google/encoder.py # tropt/models/huggingface/base.py # tropt/models/huggingface/encoder.py # tropt/models/huggingface/lm.py # tropt/models/inputs.py # tropt/models/model_mixins.py # tropt/models/openai/__init__.py # tropt/models/openai/encoder.py # tropt/optimizer/base.py # tropt/optimizer/beast_optimizer.py # tropt/optimizer/gaslite_optimizer.py # tropt/optimizer/gasliteplus_optimizer.py # tropt/optimizer/gcg_optimizer.py # tropt/optimizer/rasliteplus_optimizer.py # tropt/optimizer/utils/token_constraints.py
ishayyemini
commented
May 17, 2026
|
|
||
| # Iteratively append tokens one by one to reach total_tokens. This is a greedy approach: | ||
| # once a token is selected for position N, it is fixed, and we optimize position N+1. | ||
| for n in range(self.total_tokens - len(tokens)): |
Author
There was a problem hiding this comment.
Matan asked: so if we optimize a relatively short trigger we skip this step? isn't this limiting if we'd like to train more stealthy, short triggers?
This is just after the hot start, which generates 10-20 tokens. If you want a really short trigger, you can either still stay with the hot start, and let’s say the hot start “filled up” the trigger length. Then we randomize in square attack.
ishayyemini
commented
May 17, 2026
| ) | ||
| return result | ||
|
|
||
| def _p_selection(self, it: int) -> float: |
Author
There was a problem hiding this comment.
Matan asked: just out of curiosity - how did you converse to this very specific function?
It follows the original function from the original square attack: https://github.com/max-andr/square-attack/blob/ea95eebb5aca62ec790a927b5aa985ba4e87245c/attack.py#L12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds the Combinatio Attack optimizer.