Formula
= suffix of tokens, = target prefix βSure, here isβ¦β.
Per iteration: take the gradient w.r.t. the one-hot token embeddings, keep the top-K candidate tokens per position, evaluate a batch of one-token swaps with forward passes, keep the best. It is discrete PGD: gradients propose, forward passes decide.
Why it works: safety training mostly shapes the first answer tokens; once βSure, here isβ is likely, autoregression continues. Suffixes found on open models transfer to ChatGPT, Claude, Bard. AmpleGCG trains a generator on GCG outputs.