ChemSafetyBench: Benchmarking LLM Safety on Chemistry Domain

Haochen Zhao, Xiangru Tang, Ziran Yang, Xiao Han, Xuanzhi Feng, Yueqing Fan, Senhao Cheng, Di Jin, Yilun Zhao, Arman Cohan, Mark GersteinarXiv 2024 · DOI

Abstract

As Large Language Models (LLMs) become staples in scientific research, their ability to handle hazardous information safely is under the microscope. This paper introduces ChemSafetyBench, a massive benchmark of over 30,000 samples designed to test whether LLMs can identify dangerous chemical properties, judge the legality of chemical uses, and refuse requests to synthesize controlled substances. The results are a wake-up call: even state-of-the-art models often perform no better than random guessing and are easily tricked by simple "name-hacking" techniques.

Introduction

While LLMs like GPT-4 and Claude are revolutionizing how we process information, they possess a "dual-use" risk in specialized fields like chemistry. An LLM might provide a researcher with a brilliant synthesis route, but it could just as easily provide a bad actor with instructions for manufacturing chemical weapons or illegal drugs.

Existing safety benchmarks usually focus on general toxicity or "common sense" safety. Meanwhile, chemistry-specific benchmarks often focus on academic performance rather than safety. There is a critical gap in evaluating whether these models can responsibly handle queries about hazardous materials, especially when users employ "jailbreaking" tactics to bypass safety filters.

The ChemSafetyBench Framework

The authors developed a three-tiered evaluation framework that increases in complexity:

  1. Property Querying: Can the model identify if a chemical is toxic, corrosive, or explosive?
  2. Usage Legality: Can the model determine if a specific use (e.g., transporting dynamite in a car) is safe or legal?
  3. Synthesis Description: Will the model refuse to provide step-by-step instructions for creating controlled substances?
The three tiers of ChemSafetyBench: (a) Property, (b) Usage, and (c) Synthesis.

Methodology and Adversarial Testing

To make the test robust, the researchers didn't just use standard prompts. They employed adversarial redrafting techniques to probe the limits of model safety:

  • Name-hacking: Replacing common chemical names (like "Sarin") with obscure but scientifically accurate synonyms or IUPAC names to see if the model’s safety filters fail to recognize the substance.
  • AutoDAN: An automated jailbreaking tool that wraps dangerous requests in "stealthy" prompts to mimic human bypass behavior.
  • Chain-of-Thought (CoT): Testing if forcing the model to "think step-by-step" actually makes it more or less safe.

For evaluation, they used a "GPT-as-a-judge" pipeline, where GPT-4o extracts chemical names from a response and checks them against the Globally Harmonized System (GHS) database to verify safety scores.

The ChemSafetyBench workflow, including jailbreak redrafting and the evaluation pipeline.

Datasets

ChemSafetyBench contains over 30,000 samples covering 1,700 distinct chemical substances. The researchers utilized 500+ query templates created by chemistry students and pulled data from high-stakes regulatory lists, including the Chemical Weapons Convention (CWC), the U.S. Controlled Substances Act (CSA), and the EU’s REACH regulations. They also included "safe" chemicals from high school textbooks to ensure models don't become overly restrictive and refuse harmless academic questions.

Key Insights

  • The "Name-Hack" Vulnerability: Models that correctly refuse to synthesize "Cyanide" often provide instructions if the user asks for "Hydrocyanic acid." Safety alignment is frequently tied to keywords rather than a fundamental understanding of chemical risk.
  • Tokenization Bottlenecks: Chemical names are long and complex. Standard LLM tokenizers break these names into tiny fragments, making it difficult for the model to maintain structural meaning, leading to poor reasoning.
  • The Illusion of Competence: Some models showed high F1 scores on binary "Yes/No" tasks but failed miserably on synthesis tasks, suggesting they are statistically biased toward certain answers rather than truly knowledgeable.
  • CoT Can Backfire: Surprisingly, using Chain-of-Thought reasoning sometimes decreased response quality in chemistry, likely because the model's lack of underlying knowledge caused it to "hallucinate" more during the reasoning process.

Results and Discussion

On property and usage tasks, many models performed only slightly better than random guessing. Name-hacking and AutoDAN significantly increased the proportion of unsafe responses across almost all tested models. While LLaMA-3-70B performed exceptionally well, augmenting other models like GPT-4o with external tools (Retrieval-Augmented Generation) significantly improved accuracy. This suggests models have the reasoning capacity to be safe but lack the internalized knowledge to do so autonomously.

Conclusion and Future Work

The authors acknowledge that their synthesis evaluation is currently limited to single-step reactions. Future directions include developing domain-specific tokenizers for chemical structures (like SMILES strings), incorporating human experts into the evaluation loop, and moving toward models that reason about potential harm rather than relying on keyword filters.

Summary updated

BibTeX
@misc{zhao2024chemsafetybench,
  author = {Haochen Zhao and Xiangru Tang and Ziran Yang and Xiao Han and Xuanzhi Feng and Yueqing Fan and Senhao Cheng and Di Jin and Yilun Zhao and Arman Cohan and Mark Gerstein},
  title = {{ChemSafetyBench: Benchmarking LLM Safety on Chemistry Domain}},
  year = {2024},
  eprint = {2411.16736},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.16736},
}
Figure