superred-optimizer-bijection
A Bijection Learning jailbreak optimizer for the superred red-teaming framework.
Bijection learning is a black-box, model-agnostic jailbreak: it randomizes a bijective character map ("Language Alpha"), teaches the target model that map in-context with a few encode/decode examples, then sends the harmful query encoded under the same map. Capable models follow the encoding into the encoded answer space, sidestepping refusal training that was only ever trained on plain English. One superred run samples and tries one fresh random bijection; multiple runs give best-of-N, as in the paper.
Reference: Huang, Li, Tang, "Endless Jailbreaks with Bijection Learning," arXiv:2410.01294 (ICLR 2025, Haize Labs). See ASSUMPTIONS.md for the full paper-to-code mapping and every deliberate departure.
Install
pip install superred-optimizer-bijection
Usage
from bijection_optimizer import BijectionOptimizer
# Auto-tunes codomain + fixed_size from the in-scope `model` observable
# (paper Table 1: digit codomain for stronger models, letter for weaker ones).
optimizer = BijectionOptimizer(max_attempts=6)
# Explicit configuration always wins over auto-tune.
optimizer = BijectionOptimizer(bijection_type="digit", fixed_size=8, num_digits=2)
Wire it into a Controller like any other superred optimizer — see the
framework's architecture overview and a
target's README (e.g. superred-target-chatbot) for a full Controller.run()
example.
Behaviour notes
- Single-turn, packed prompt. Upstream can use multi-turn teaching; superred has no assistant-prefill primitive, so a multi-turn version would cost ~11x more model calls for no accuracy upside here, and this port stays single-turn by design (see ASSUMPTIONS.md).
- Two-channel split when
system_promptis in scope: the alphabet-table teaching content goes in the system prompt, the encoded query in the user message, matching the paper's stronger configuration. - Response-blind construction. Bijection construction never depends on
seeing the target's previous response (matches the paper); in
response-visible settings, only the early-stop decision uses
RunEndEvent.evaluation.success. target_controllable_namelets you point the optimizer at a non-chatbottarget's user-message controllable by name.
License
MIT for this port's code. The upstream reference implementation,
haizelabs/bijection-learning,
carries no license file (default all-rights-reserved). This port does not
vendor or copy any of its files — src/bijection_optimizer/bijection.py is an
independent reimplementation of the bijection construction/encode/decode
algorithm described in the paper and observable in the upstream repo (new
classes, new structure, new docstrings), not a copy of upstream's source text.
If upstream publishes a license in the future, or if any literal upstream code
is ever vendored here, this notice should be revisited.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file superred_optimizer_bijection-0.1.0.tar.gz.
File metadata
- Download URL: superred_optimizer_bijection-0.1.0.tar.gz
- Upload date:
- Size: 29.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d7a208120848f066dbfa63a7da60209effa746bb7097d6783cedd5cb42d1ba9
|
|
| MD5 |
4ef18abcebcd64efd0827d4d4610ac86
|
|
| BLAKE2b-256 |
1768605ab0c3e2e0270038a62b36175244564c444248f8569c6cbb79bb8f9047
|
Provenance
The following attestation bundles were made for superred_optimizer_bijection-0.1.0.tar.gz:
Publisher:
release.yml on RoldSI/superred-modules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
superred_optimizer_bijection-0.1.0.tar.gz -
Subject digest:
0d7a208120848f066dbfa63a7da60209effa746bb7097d6783cedd5cb42d1ba9 - Sigstore transparency entry: 2214948802
- Sigstore integration time:
-
Permalink:
RoldSI/superred-modules@ff92389cd4ecc6690ecd16f410231274785c4afb -
Branch / Tag:
refs/tags/superred-optimizer-bijection-v0.1.0 - Owner: https://github.com/RoldSI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ff92389cd4ecc6690ecd16f410231274785c4afb -
Trigger Event:
push
-
Statement type:
File details
Details for the file superred_optimizer_bijection-0.1.0-py3-none-any.whl.
File metadata
- Download URL: superred_optimizer_bijection-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8842c1da49efbc3a40fcb13b6baacc9bdff7a2a9554b729761168d59338f4ba
|
|
| MD5 |
d8ea5bf4a9848017bec64df435af6f0f
|
|
| BLAKE2b-256 |
7a5749a833a9c20b1eed4dcb23ec4916241e4d0db54617dcb9c2f0bafe801c58
|
Provenance
The following attestation bundles were made for superred_optimizer_bijection-0.1.0-py3-none-any.whl:
Publisher:
release.yml on RoldSI/superred-modules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
superred_optimizer_bijection-0.1.0-py3-none-any.whl -
Subject digest:
c8842c1da49efbc3a40fcb13b6baacc9bdff7a2a9554b729761168d59338f4ba - Sigstore transparency entry: 2214948816
- Sigstore integration time:
-
Permalink:
RoldSI/superred-modules@ff92389cd4ecc6690ecd16f410231274785c4afb -
Branch / Tag:
refs/tags/superred-optimizer-bijection-v0.1.0 - Owner: https://github.com/RoldSI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ff92389cd4ecc6690ecd16f410231274785c4afb -
Trigger Event:
push
-
Statement type: