mirror of
https://github.com/romovpa/claudini.git
synced 2026-09-22 03:10:41 +02:00
Co-Authored-By: Alexander Panfilov <sasha_pusha@mail.de> Co-Authored-By: Claude <noreply@anthropic.com>
name, full_name, reference, paper_url, code
| name | full_name | reference | paper_url | code |
|---|---|---|---|---|
| RR | Regularized Relaxation | chacko2024adversarial | https://arxiv.org/abs/2410.19160 | https://github.com/sj21j/Regularized_Relaxation |
RR — Regularized Relaxation
Paper: Chacko et al., "Adversarial Attacks on Large Language Models Using Regularized Relaxation" (2024) Links: arXiv | Code \cite{chacko2024adversarial}
Algorithm
Continuous embedding-space optimization using AdamW with decoupled weight decay as the regularization mechanism. Unlike PGD (which operates on simplex-projected logits) or PEZ (which uses straight-through estimation), RR directly optimizes soft embeddings with weight decay pulling them toward zero to prevent drift into invalid regions of embedding space.
- Initialize suffix embeddings from random tokens, add Gaussian noise (σ=0.1)
- Each step:
- Forward pass with soft embeddings concatenated into the input sequence
- Compute CE loss on target tokens
- Backprop through soft embeddings only
- Clip gradients (max_norm=1.0)
- AdamW step (weight_decay=0.05 provides L2 regularization)
- Exponential LR decay:
lr = lr_init × 0.99^step
- Discretize via normalized L2 nearest-neighbour projection (both soft embeddings and token embedding matrix are L2-normalized before distance computation)
Hyperparameters
| Parameter | Default | Paper |
|---|---|---|
lr |
0.1 | 0.1 (Llama-2/Vicuna); model-dependent |
weight_decay |
0.05 | 0.05 |
lr_decay |
0.99 | 0.99 |
max_norm |
1.0 | 1.0 |
init_noise_std |
0.1 | 0.1 |
optim_length |
20 | 20 |
Notes
- The paper reports model-dependent learning rates (Falcon: 0.7, MPT: 0.8, Mistral: 0.6); we use 0.1 (Llama-2/Vicuna default) as the general default.
- Weight decay in AdamW is decoupled:
param -= lr * weight_decay * param, equivalent to L2 regularization toward zero. - The normalized L2 projection is equivalent to cosine similarity on the unit
sphere (minimizing
||x̂ - ŵ||₂= minimizing√(2 - 2·cos(x,w))).