Skip to main content

superred-optimizer-many-shot

A Many-Shot Jailbreaking single-turn optimizer for the superred red-teaming framework.

Community port — not an official implementation. This module is an unofficial re-implementation of Many-shot Jailbreaking (Anil et al., Anthropic) for superred. It is not affiliated with, endorsed by, or maintained by the original authors. See ASSUMPTIONS.md for every deliberate deviation from the paper and reference code.

Many-shot jailbreaking abuses long context windows. It builds one prompt packed with many faux user/assistant exchanges in which the assistant always complies with a harmful request, then appends the real objective as the final user turn. Faced with a long run of "compliant" examples, the model tends to continue the pattern and comply too.

Reference: Anil et al., "Many-shot Jailbreaking," Anthropic, April 2024 (research page, PDF; later NeurIPS 2024). There is no official code release; this is an independent implementation from the paper. See ASSUMPTIONS.md for the full paper-to-code mapping and every deliberate departure.

Install

pip install superred-optimizer-many-shot

Usage

from many_shot_optimizer import ManyShotOptimizer

# Default: one 256-shot attempt (matches the paper's main many-shot setup).
optimizer = ManyShotOptimizer()

# Sweep the number of shots across staged runs.
optimizer = ManyShotOptimizer(example_counts=[32, 64, 128, 256, 400, 512])

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.

License

MIT for this port's code (see LICENSE). Many-shot jailbreaking was published by Anthropic without an official code release, so there is no upstream repository to vendor from; this module is an independent implementation of the technique described in the paper.

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_many_shot-0.1.0.tar.gz (207.2 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_many_shot-0.1.0-py3-none-any.whl (203.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for superred_optimizer_many_shot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d750eeeb46221de54929ee32af1efe1447f274c0cbdf958087ca61bac2755293
MD5 1c07f605f214897bb9a87ee149e3347d
BLAKE2b-256 41c23a3b09774f2ebb6eabbcf17a1557afcceec081f0662c5f561e6659628539

See more details on using hashes here.

Provenance

The following attestation bundles were made for superred_optimizer_many_shot-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_many_shot-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for superred_optimizer_many_shot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f670b42f677be576be2b514a2da3a5348fcee9558e3ccecaf8dc826875ec82a
MD5 eaf5a7e747f001e87bb207e207df6179
BLAKE2b-256 9d76a2a58b1114b73528e59021c8fb8076482442b4f30809b539c464d1d56046

See more details on using hashes here.

Provenance

The following attestation bundles were made for superred_optimizer_many_shot-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