nikihasrati/understanding_jailbreak_transfer

Code to reproduce results from the paper "Toward Understanding the Transferability of Adversarial Suffixes in Large Language Model"

Python

0

23 commits

updated Jun 1, 2026

See the code

README

Understanding Jailbreak Transfer

This repository contains the code and reproducibility artifacts for the paper Toward Understanding the Transferability of Adversarial Suffixes in Large Language Models. It is intended to be the entry point for reproducing the paper workflow: suffix generation, dataset construction, completion generation, jailbreak-judge evaluation, activation regeneration, and analysis.

Published JSON artifacts live in Git as chunked files with manifests. Large activation tensors are not committed; the commands to regenerate activations are documented in docs/activations.md.

For a step-by-step guide to reproducing the paper results, start with the recommended Slurm job-array workflow in docs/slurm_workflow.md. Slurm is the recommended way to parallelize prompt and chunk jobs for full paper-scale reproduction. docs/workflow.md provides the local-command equivalent for reference, but it has not been tested end to end.

Table of Contents

Start Here

Read the docs in this order if you are reproducing results for the first time:

FilePurpose
docs/slurm_workflow.mdRecommended full-scale workflow using Slurm job arrays to parallelize jobs. Start here for reproduction runs.
docs/workflow.mdLocal-command equivalent of the Slurm workflow. Useful as a readable reference, but not tested end to end.
docs/paper_map.mdMapping from paper sections, definitions, figures, and tables to repo scripts.
docs/artifacts.mdData layout, chunked JSON manifests, checksums, and how to combine chunked files.
docs/activations.mdHow to regenerate activations and export alternate activation layouts.
docs/refusal_directions.mdHow refusal directions are stored, inspected, and regenerated.
docs/migration_map.mdWhat was consolidated from the old repositories and what was intentionally excluded.
docs/future_work.mdFollow-up cleanup that is intentionally out of scope for this release.

Workflow Summary

This table provides an overview of what to run, in what order, what checkpoint or saved output to expect, and the relevant paper sections. For the detailed section-by-section mapping between the files in the repo and the sections in the paper, use docs/paper_map.md.

Path shorthand:

  • <output-dir>: usually data/multiple_seed_results.
  • <artifact-dir>: usually <output-dir>/$MODEL_ALIAS/transfer/${MODEL_ALIAS}_multiple_seed_results_transfer.
StepWorkflow stagePaper section(s)Main moduleSave location
1Generate suffixesSection 4pipeline.suffix_generation.run_gcgSaves raw GCG results to:
data/gcg_results/raw/<model>/
index-*/seed-*/results.json
2Build datasetsSection 4; Section 5.1pipeline.suffix_generation.create_datasets --checkSaves JSON files under:
<output-dir>/$MODEL_ALIAS/no_transfer/
<output-dir>/$MODEL_ALIAS/transfer/
Prints prompt/seed coverage checks.
3Publish JSON artifactsReproducibility support for Sections 4-5tools.split_json_records
tools.verify_manifest
Saves canonical chunks and manifest:
<artifact-dir>/chunks/chunk_*.json
<artifact-dir>/manifest.json
Manifest verification should pass.
4Prepare generation jobsOperational support for Section 4tools.prepare_generation_chunksSaves temporary generation shards:
<artifact-dir>/generation_chunks/chunk_*.json
5Generate responsesSection 4pipeline.generation.generate_completionsUpdates generation shards with response:
<artifact-dir>/generation_chunks/chunk_*.json
6Re-shard for evaluationOperational support for Section 4tools.combine_completionsSaves fewer judge-ready shards:
<artifact-dir>/evaluation_chunks/chunk_*.json
7Judge responsesSection 4; Definition 1; Section 5pipeline.evaluation.evaluate_completionsUpdates evaluation shards with jailbroken:
<artifact-dir>/evaluation_chunks/chunk_*.json
8Publish evaluated artifactsReproducibility support for Section 5tools.combine_completions
--write-manifest
Replaces canonical chunks and manifest:
<artifact-dir>/chunks/chunk_*.json
<artifact-dir>/manifest.json
9Normalize labelsDefinition 1; Section 5pipeline.evaluation.normalize_jailbreak_labelsWrites to the command's --output, commonly:
<artifact-dir>/combined.json
Split back to chunks/ before committing.
10Generate no-suffix baselineSection 4; Section 5.1; Section 5.6pipeline.generation.generate_completions
--no-suffix-completions
pipeline.evaluation.evaluate_completions
--no_suffix_completions
Saves and updates:
data/no_suffix_generations/
${MODEL_ALIAS}_no_suffix_generations/combined.json
11Regenerate activationsSections 3.2-3.3; Sections 5.2-5.5pipeline.activations.save_activationsSaves ignored tensor chunks under:
outputs/activations/$MODEL_ALIAS/
<input-kind>/canonical_tensor_chunks/
12Analyze multi-seed transferSections 5.1-5.5pipeline.analysis.multi_seed_data_analysisPrints ASR summaries.
Saves figures under:
figures/$MODEL_ALIAS/
13Analyze cross-model transferSection 3.1; Section 5.1; Section 5.5pipeline.cross_model.*Saves transfer records under:
data/cross_model_transfer_generations/
${SOURCE_ALIAS}_to_${TARGET_ALIAS}/
Saves figures under:
figures/${SOURCE_ALIAS}_to_${TARGET_ALIAS}/
14Run and analyze GCG-push interventionsSection 5.6; Tables 4-5pipeline.gcg_push.launch_experiment
pipeline.gcg_push.run_gcg
pipeline.gcg_push.create_datasets
pipeline.gcg_push.data_analysis
Raw rerun outputs:
outputs/gcg_push/raw/$MODEL_ALIAS/
Published artifacts:
data/gcg_push_results/$MODEL_ALIAS/
{suffix_push,orth_shift}/coeff-$COEFF/
{no_transfer,transfer}/
Analysis summaries:
outputs/gcg_push_analysis/
15Analyze prompt rephrasingsSection 5.6; Appendix Cpipeline.prompt_rephrasings.setup_dataset
--rephrasings generation/evaluation
Saves setup dataset to:
data/prompt_rephrasings/
${MODEL_ALIAS}_prompt_rephrasings/combined.json
Generation/evaluation chunks live under the same artifact directory.

The recommended command-by-command workflow is in docs/slurm_workflow.md. The local-command equivalent is in docs/workflow.md, but it is provided as an untested reference rather than the primary reproduction path.

Repository Layout

understanding_jailbreak_transfer/
  README.md                         Project entry point and doc index.
  environment.yml                   Conda environment used for reproduction.
  configs/                          Example model, path, and Slurm settings.
    models.example.yaml             Model IDs used in the experiments.
    paths.example.yaml              Cache/output path placeholders.
    slurm.example.yaml              Cluster setting placeholders.
    gcg_push_paper.example.yaml     Config-driven GCG-push paper experiment.
    gcg_push_20_random_indices.txt  Prompt IDs used for the paper GCG-push runs.
  data/                             Versioned artifacts used by the paper workflow.
    processed/                      JailbreakBench prompts and suffixes as chunked JSON.
    multiple_seed_results/          Multi-seed no-transfer and transfer artifacts.
                                      Commit only chunks/ and manifest.json; generation_chunks/,
                                      evaluation_chunks/, and combined.json are temporary.
    gcg_results/raw/                Raw per-prompt/per-seed GCG result JSON files.
    gcg_push_results/               Coefficient-modified GCG-push artifacts by intervention.
    refusal_directions/             Stored refusal-direction vectors and metadata.
  docs/                             Reproducibility guide and reference docs.
  external/                         Small support files for external repositories.
    refusal_direction_model_utils/  Model wrappers to copy into the external refusal-direction repo.
  pipeline/                         Python pipeline modules.
    suffix_generation/              GCG runner plus dataset creation/checking.
    generation/                     Completion generation.
    evaluation/                     Jailbreak-judge evaluation and label normalization.
    activations/                    Activation regeneration and export utilities.
    analysis/                       Multi-seed analysis.
    cross_model/                    Cross-model setup, generation, evaluation, and analysis.
    gcg_push/                       Config-driven altered-GCG runner, artifact builder, launcher, and analysis.
    prompt_rephrasings/             Prompt-rephrasing dataset setup.
    model_utils/                    Model wrappers used by this repository.
  scripts/                          Local and Slurm convenience wrappers.
  tools/                            Artifact chunking, combining, checksum, and tensor utilities.

nikihasrati/understanding_jailbreak_transfer

Code to reproduce results from the paper "Toward Understanding the Transferability of Adversarial Suffixes in Large Language Model"

Python

0

23 commits

updated Jun 1, 2026

See the code

README

Understanding Jailbreak Transfer

This repository contains the code and reproducibility artifacts for the paper Toward Understanding the Transferability of Adversarial Suffixes in Large Language Models. It is intended to be the entry point for reproducing the paper workflow: suffix generation, dataset construction, completion generation, jailbreak-judge evaluation, activation regeneration, and analysis.

Published JSON artifacts live in Git as chunked files with manifests. Large activation tensors are not committed; the commands to regenerate activations are documented in docs/activations.md.

For a step-by-step guide to reproducing the paper results, start with the recommended Slurm job-array workflow in docs/slurm_workflow.md. Slurm is the recommended way to parallelize prompt and chunk jobs for full paper-scale reproduction. docs/workflow.md provides the local-command equivalent for reference, but it has not been tested end to end.

Table of Contents

Start Here

Read the docs in this order if you are reproducing results for the first time:

FilePurpose
docs/slurm_workflow.mdRecommended full-scale workflow using Slurm job arrays to parallelize jobs. Start here for reproduction runs.
docs/workflow.mdLocal-command equivalent of the Slurm workflow. Useful as a readable reference, but not tested end to end.
docs/paper_map.mdMapping from paper sections, definitions, figures, and tables to repo scripts.
docs/artifacts.mdData layout, chunked JSON manifests, checksums, and how to combine chunked files.
docs/activations.mdHow to regenerate activations and export alternate activation layouts.
docs/refusal_directions.mdHow refusal directions are stored, inspected, and regenerated.
docs/migration_map.mdWhat was consolidated from the old repositories and what was intentionally excluded.
docs/future_work.mdFollow-up cleanup that is intentionally out of scope for this release.

Workflow Summary

This table provides an overview of what to run, in what order, what checkpoint or saved output to expect, and the relevant paper sections. For the detailed section-by-section mapping between the files in the repo and the sections in the paper, use docs/paper_map.md.

Path shorthand:

  • <output-dir>: usually data/multiple_seed_results.
  • <artifact-dir>: usually <output-dir>/$MODEL_ALIAS/transfer/${MODEL_ALIAS}_multiple_seed_results_transfer.
StepWorkflow stagePaper section(s)Main moduleSave location
1Generate suffixesSection 4pipeline.suffix_generation.run_gcgSaves raw GCG results to:
data/gcg_results/raw/<model>/
index-*/seed-*/results.json
2Build datasetsSection 4; Section 5.1pipeline.suffix_generation.create_datasets --checkSaves JSON files under:
<output-dir>/$MODEL_ALIAS/no_transfer/
<output-dir>/$MODEL_ALIAS/transfer/
Prints prompt/seed coverage checks.
3Publish JSON artifactsReproducibility support for Sections 4-5tools.split_json_records
tools.verify_manifest
Saves canonical chunks and manifest:
<artifact-dir>/chunks/chunk_*.json
<artifact-dir>/manifest.json
Manifest verification should pass.
4Prepare generation jobsOperational support for Section 4tools.prepare_generation_chunksSaves temporary generation shards:
<artifact-dir>/generation_chunks/chunk_*.json
5Generate responsesSection 4pipeline.generation.generate_completionsUpdates generation shards with response:
<artifact-dir>/generation_chunks/chunk_*.json
6Re-shard for evaluationOperational support for Section 4tools.combine_completionsSaves fewer judge-ready shards:
<artifact-dir>/evaluation_chunks/chunk_*.json
7Judge responsesSection 4; Definition 1; Section 5pipeline.evaluation.evaluate_completionsUpdates evaluation shards with jailbroken:
<artifact-dir>/evaluation_chunks/chunk_*.json
8Publish evaluated artifactsReproducibility support for Section 5tools.combine_completions
--write-manifest
Replaces canonical chunks and manifest:
<artifact-dir>/chunks/chunk_*.json
<artifact-dir>/manifest.json
9Normalize labelsDefinition 1; Section 5pipeline.evaluation.normalize_jailbreak_labelsWrites to the command's --output, commonly:
<artifact-dir>/combined.json
Split back to chunks/ before committing.
10Generate no-suffix baselineSection 4; Section 5.1; Section 5.6pipeline.generation.generate_completions
--no-suffix-completions
pipeline.evaluation.evaluate_completions
--no_suffix_completions
Saves and updates:
data/no_suffix_generations/
${MODEL_ALIAS}_no_suffix_generations/combined.json
11Regenerate activationsSections 3.2-3.3; Sections 5.2-5.5pipeline.activations.save_activationsSaves ignored tensor chunks under:
outputs/activations/$MODEL_ALIAS/
<input-kind>/canonical_tensor_chunks/
12Analyze multi-seed transferSections 5.1-5.5pipeline.analysis.multi_seed_data_analysisPrints ASR summaries.
Saves figures under:
figures/$MODEL_ALIAS/
13Analyze cross-model transferSection 3.1; Section 5.1; Section 5.5pipeline.cross_model.*Saves transfer records under:
data/cross_model_transfer_generations/
${SOURCE_ALIAS}_to_${TARGET_ALIAS}/
Saves figures under:
figures/${SOURCE_ALIAS}_to_${TARGET_ALIAS}/
14Run and analyze GCG-push interventionsSection 5.6; Tables 4-5pipeline.gcg_push.launch_experiment
pipeline.gcg_push.run_gcg
pipeline.gcg_push.create_datasets
pipeline.gcg_push.data_analysis
Raw rerun outputs:
outputs/gcg_push/raw/$MODEL_ALIAS/
Published artifacts:
data/gcg_push_results/$MODEL_ALIAS/
{suffix_push,orth_shift}/coeff-$COEFF/
{no_transfer,transfer}/
Analysis summaries:
outputs/gcg_push_analysis/
15Analyze prompt rephrasingsSection 5.6; Appendix Cpipeline.prompt_rephrasings.setup_dataset
--rephrasings generation/evaluation
Saves setup dataset to:
data/prompt_rephrasings/
${MODEL_ALIAS}_prompt_rephrasings/combined.json
Generation/evaluation chunks live under the same artifact directory.

The recommended command-by-command workflow is in docs/slurm_workflow.md. The local-command equivalent is in docs/workflow.md, but it is provided as an untested reference rather than the primary reproduction path.

Repository Layout

understanding_jailbreak_transfer/
  README.md                         Project entry point and doc index.
  environment.yml                   Conda environment used for reproduction.
  configs/                          Example model, path, and Slurm settings.
    models.example.yaml             Model IDs used in the experiments.
    paths.example.yaml              Cache/output path placeholders.
    slurm.example.yaml              Cluster setting placeholders.
    gcg_push_paper.example.yaml     Config-driven GCG-push paper experiment.
    gcg_push_20_random_indices.txt  Prompt IDs used for the paper GCG-push runs.
  data/                             Versioned artifacts used by the paper workflow.
    processed/                      JailbreakBench prompts and suffixes as chunked JSON.
    multiple_seed_results/          Multi-seed no-transfer and transfer artifacts.
                                      Commit only chunks/ and manifest.json; generation_chunks/,
                                      evaluation_chunks/, and combined.json are temporary.
    gcg_results/raw/                Raw per-prompt/per-seed GCG result JSON files.
    gcg_push_results/               Coefficient-modified GCG-push artifacts by intervention.
    refusal_directions/             Stored refusal-direction vectors and metadata.
  docs/                             Reproducibility guide and reference docs.
  external/                         Small support files for external repositories.
    refusal_direction_model_utils/  Model wrappers to copy into the external refusal-direction repo.
  pipeline/                         Python pipeline modules.
    suffix_generation/              GCG runner plus dataset creation/checking.
    generation/                     Completion generation.
    evaluation/                     Jailbreak-judge evaluation and label normalization.
    activations/                    Activation regeneration and export utilities.
    analysis/                       Multi-seed analysis.
    cross_model/                    Cross-model setup, generation, evaluation, and analysis.
    gcg_push/                       Config-driven altered-GCG runner, artifact builder, launcher, and analysis.
    prompt_rephrasings/             Prompt-rephrasing dataset setup.
    model_utils/                    Model wrappers used by this repository.
  scripts/                          Local and Slurm convenience wrappers.
  tools/                            Artifact chunking, combining, checksum, and tensor utilities.