skills/skillxiv-v0.0.2-claude-opus-4.6/few-tokens-matter-vlm-attacks/SKILL.md
Demonstrate that adversarial attacks on vision-language models need not target all tokens equally. Entropy-guided attacks identify high-entropy tokens (critical decision points) where perturbations have maximum impact, achieving comparable attack success with 80% fewer tokens targeted.
npx skillsauth add ADu2021/skillXiv few-tokens-matter-vlm-attacksInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Prior adversarial attack research on vision-language models assumed all tokens contribute equally to generation instability, leading to global attack strategies. This creates computationally expensive attacks requiring perturbations across extensive token sequences. However, VLM generation follows entropy-driven decision-making where only high-entropy tokens—approximately 20% of positions—disproportionately govern output distributions.
Rather than distributing attacks globally, concentrate perturbations on high-entropy tokens where model uncertainty is maximal.
class EntropyGuidedAttack:
def __init__(self, vlm_model):
self.vlm = vlm_model
def compute_token_entropy(self, logits):
"""Identify uncertainty critical points"""
probs = torch.softmax(logits, dim=-1)
entropy = -torch.sum(probs * torch.log(probs + 1e-8), dim=-1)
return entropy
def targeted_adversarial_attack(self, image, benign_prompt, target_harm):
"""Attack only high-entropy tokens"""
# Step 1: Identify high-entropy token positions
benign_logits = self.vlm.forward_logits(image, benign_prompt)
entropy_scores = self.compute_token_entropy(benign_logits)
# Select top 20% by entropy (critical decision points)
entropy_threshold = torch.quantile(entropy_scores, 0.8)
high_entropy_positions = entropy_scores > entropy_threshold
# Step 2: Generate adversarial perturbations
adversarial_image = image.clone()
for high_entropy_pos in high_entropy_positions.nonzero():
# Optimize perturbation for this position
perturbation = self.compute_perturbation(
image, benign_prompt, high_entropy_pos, target_harm
)
adversarial_image += perturbation * 0.1 # Small perturbation magnitude
return adversarial_image
def compute_perturbation(self, image, prompt, target_position, target_harm):
"""Gradient-based perturbation for specific token position"""
# Use only gradients from target token position
# Standard adversarial optimization: maximize harm output at position
return torch.autograd.grad(
loss=harm_loss(target_position),
inputs=image,
retain_graph=True
)[0]
Empirical Results:
Generalization:
Understanding Vulnerabilities: High-entropy tokens represent uncertain decisions where:
Defensive Strategies:
For Security Researchers:
For VLM Developers:
Models Tested:
Attack Success Metrics:
testing
Uses flow maps as look-ahead operators to enable principled reward-guided diffusion by predicting trajectory endpoints at any denoising step. Deploy when applying rewards or preferences to diffusion trajectories with meaningful gradients throughout generation.
testing
Train language models where each expert learns independently on closed datasets, enabling flexible inference with selective data inclusion or exclusion. 41% performance improvement while allowing users to opt out of specific data sources without retraining.
data-ai
Understand how token generation flexibility in diffusion LMs paradoxically constrains reasoning, as models exploit ordering flexibility to avoid uncertain tokens, and apply simplified approaches that preserve parallel decoding benefits. Use when optimizing diffusion-based language models for reasoning tasks.
devops
Enable LLM agents to improve continuously during deployment by constructing structured experience libraries through self-reflection on successes and failures—achieving 23% improvement on reasoning without gradient-based parameter updates or external training.