Reproduce “Scalable Defense against In-the-wild Jailbreaking Attacks with Safety Context Retrieval” on OpenResearch

Run Claude Code, Codex or any coding agent as a research agent: literature, hypotheses and experiments on your laptop, cluster or cloud GPUs.

Universal app for Apple silicon and Intel. Requires macOS 11 or later.

About this paper

Taiye Chen, Zeming Wei, Ang Li, Yisen Wang

Peking University researchers developed Safety Context Retrieval (SCR), a retrieval-augmented generation (RAG) based defense that dynamically counters "in-the-wild" jailbreaking attacks on large language models by integrating targeted safety contexts. This approach achieves high robustness and scalability against emerging threats without degrading performance on benign tasks.

Key insights

  • Even a minimal number of targeted safety contexts (e.g., four examples) can drastically reduce the Attack Success Rate (ASR) against specific jailbreaking patterns.
  • A RAG mechanism can accurately identify and retrieve highly relevant safety contexts for specific attack types from a large database, achieving nearly 100% accuracy with few dedicated examples.
  • Integrating RAG for defense offers a scalable and adaptive solution, allowing dynamic updates to the safety knowledge base without costly model fine-tuning and mitigating catastrophic forgetting.

Summary by alphaXiv.

Tip: change arxiv.org to autoarxiv.org in any arXiv abstract link to open the paper here.