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.
Metadata
Release files for superred-optimizer-bijection 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| superred_optimizer_bijection-0.1.0.tar.gz | 29.3 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| superred_optimizer_bijection-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 45.6 kB
Release files / superred_optimizer_bijection-0.1.0.tar.gz
| Download URL | superred_optimizer_bijection-0.1.0.tar.gz |
|---|---|
| Size | 29.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d7a208120848f066dbfa63a7da60209effa746bb7097d6783cedd5cb42d1ba9
|
|
BLAKE2b-256 checksum How to use checksums |
1768605ab0c3e2e0270038a62b36175244564c444248f8569c6cbb79bb8f9047
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.
Transparency logRelease files / superred_optimizer_bijection-0.1.0-py3-none-any.whl
| Download URL | superred_optimizer_bijection-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c8842c1da49efbc3a40fcb13b6baacc9bdff7a2a9554b729761168d59338f4ba
|
|
BLAKE2b-256 checksum How to use checksums |
7a5749a833a9c20b1eed4dcb23ec4916241e4d0db54617dcb9c2f0bafe801c58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.
Transparency logSecurity for superred-optimizer-bijection 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for superred_optimizer_bijection-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.