Files
claudini/claudini/methods/original/mc_gcg
5b6058b3c4 Initial commit
Co-Authored-By: Alexander Panfilov <sasha_pusha@mail.de>
Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-25 02:09:26 +00:00
..
2026-03-25 02:09:26 +00:00
2026-03-25 02:09:26 +00:00
2026-03-25 02:09:26 +00:00

name, full_name, reference, paper_url, code
name full_name reference paper_url code
MC-GCG Multi-Coordinate GCG jia2025improved https://arxiv.org/abs/2405.21018 https://github.com/jiaxiaojunQAQ/I-GCG

MC-GCG — Multi-Coordinate GCG

Paper: Jia et al., "Improved Techniques for Optimization-Based Jailbreaking on Large Language Models" (ICLR 2025) Links: arXiv | Code \cite{jia2025improved}

Algorithm

MC-GCG extends GCG with a progressive multi-coordinate merging strategy (called "automatic multi-coordinate updating" in the paper). Instead of keeping the single best candidate per step, it:

  1. Generates B single-token candidates (standard GCG sampling)
  2. Evaluates all B candidates and sorts by loss
  3. Takes the top-K best candidates
  4. Progressive merge: greedily merges token changes from the top-K candidates to create K merged candidates with increasing numbers of changed positions
  5. Evaluates the K merged candidates and keeps the best

The merging works as follows: starting from the current suffix, iterate through the top-K candidates (best first). For each candidate, wherever it differs from the original suffix, apply that change to the running merged suffix. This creates K candidates that accumulate more and more beneficial single-token changes.

The paper also proposes diverse target templates and easy-to-hard initialization, which are jailbreak-specific and not implemented here.

Hyperparameters

Parameter Default Description
search_width 512 Number of single-token candidates (B)
topk 256 Top-k tokens per position for gradient sampling
n_replace 1 Tokens replaced per candidate (standard GCG)
merge_k 7 Number of top candidates to merge (K)

The paper uses K=7 as the default merge depth.

Notes

  • The paper calls the full method "I-GCG" but we use "MC-GCG" to avoid confusion with the existing i_gcg package (Li et al. 2024, LSGM/LILA), which is a different paper.
  • The progressive merge adds K extra forward passes per step (for evaluating merged candidates), which is negligible compared to the B candidate evaluations.
  • The merge can change up to K positions per step, but the actual number depends on how many of the top-K candidates change different positions.