Skip to main content

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_prompt is 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_name lets you point the optimizer at a non-chatbot target'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

superred_optimizer_bijection-0.1.0.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

superred_optimizer_bijection-0.1.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file superred_optimizer_bijection-0.1.0.tar.gz.

File metadata

File hashes

Hashes for superred_optimizer_bijection-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0d7a208120848f066dbfa63a7da60209effa746bb7097d6783cedd5cb42d1ba9
MD5 4ef18abcebcd64efd0827d4d4610ac86
BLAKE2b-256 1768605ab0c3e2e0270038a62b36175244564c444248f8569c6cbb79bb8f9047

See more details on using hashes here.

Provenance

The following attestation bundles were made for superred_optimizer_bijection-0.1.0.tar.gz:

Publisher: release.yml on RoldSI/superred-modules

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file superred_optimizer_bijection-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for superred_optimizer_bijection-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c8842c1da49efbc3a40fcb13b6baacc9bdff7a2a9554b729761168d59338f4ba
MD5 d8ea5bf4a9848017bec64df435af6f0f
BLAKE2b-256 7a5749a833a9c20b1eed4dcb23ec4916241e4d0db54617dcb9c2f0bafe801c58

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page