R-Judge: Benchmarking Safety Risk Awareness for LLM Agents

Tongxin Yuan, Zhiwei He, Lingzhong Dong, Yiming Wang, Ruijie Zhao, Tian Xia, Lizhen Xu, Binglin Zhou, Li Fangqi, Zhuosheng Zhang, Rui Wang, Gongshen Liu · DOI

TL;DR

This paper introduces R-Judge, a novel benchmark designed to evaluate how well Large Language Model (LLM) agents can identify and judge safety risks in their own actions within interactive environments. The study reveals that current LLM agents have significant room for improvement in safety awareness, with even top models struggling to consistently identify risks.

What Problem Does This Paper Address?

LLM agents are increasingly capable of performing complex tasks autonomously. However, their interaction with diverse environments introduces unforeseen safety risks, such as privacy leakage or financial loss, which go beyond just the safety of generated text. Existing safety evaluations often focus on LLM outputs rather than the agents' behavior in dynamic, interactive settings. This paper addresses the critical need for a benchmark that specifically assesses an LLM agent's ability to understand and flag potential safety issues arising from its own actions and interactions.

Methods

The core contribution is the R-Judge dataset, a benchmark comprising 569 multi-turn agent interaction records. Each record includes a user instruction, the agent's thought process, actions, and environment feedback. These records are meticulously annotated with binary safety labels (safe/unsafe) and detailed risk descriptions, following a Motivation-Trigger-Outcome (MTO) schema. The authors also propose a two-stage evaluation process for LLMs: first, risk identification (analyzing the situation) and second, safety judgment (classifying as safe/unsafe). They evaluate LLMs using both zero-shot and few-shot prompting techniques, and also explore the impact of fine-tuning.

Datasets

The primary dataset introduced is R-Judge. It contains 569 agent interaction records, spanning 27 scenarios across 5 application categories (Program, Web, Software, IoT, Finance) and 10 risk types (e.g., Privacy Leakage, Computer Security, Financial Loss). The dataset is curated from existing works (ToolEmu, InjecAgent, AgentMonitor) and supplemented with human-annotated data to ensure quality and balance between safe and unsafe cases.

Key Insights and Ideas

  • LLM agents are surprisingly unaware of their own safety risks: Even the best-performing LLMs struggle to identify potential dangers in their actions, highlighting a significant gap in current agent safety.
  • Safety is more than just text generation: The focus needs to shift from the safety of LLM outputs to the safety of LLM behaviors in interactive environments.
  • Prompting alone isn't enough: Simple prompting techniques, even with risk type hints or few-shot examples, offer limited improvement for safety judgment.
  • Fine-tuning is crucial: Fine-tuning LLMs on safety judgment tasks, especially with high-quality, diverse data, shows a promising path to enhancing risk awareness.
  • Risk awareness is multi-dimensional: It requires not just knowledge but also sophisticated reasoning abilities to understand context and potential consequences.

Key Results

  • GPT-40 was the best-performing model on the R-Judge safety judgment test, achieving an F1 score of 74.45%. However, no other models significantly outperformed random chance.
  • For risk identification, the best models achieved an Effectiveness score around 88%, but this is still a challenging task.
  • Fine-tuning (specifically with Llama Guard) significantly improved performance, with Meta-Llama-Guard-2-8B surpassing GPT-40 in some metrics.
  • Prompting techniques like Zero-Shot-CoT and Few-Shot-CoT showed minimal or inconsistent improvements, suggesting their limitations for this complex task.

Limitations and Future Work

  • Dataset Size: While R-Judge is a significant contribution, the authors acknowledge that it's smaller than some previous LLM safety benchmarks due to the complexity of annotating agent interactions. They plan to expand it.
  • LLM Capabilities: The study highlights that current LLMs lack the necessary knowledge and reasoning to consistently identify safety risks in complex, multi-turn interactions.
  • Future Work: The authors suggest that fine-tuning LLMs on safety judgment with high-quality, diverse data is a promising direction. They also emphasize the need for further research into the multi-dimensional nature of risk awareness in LLM agents. The R-Judge benchmark is intended to facilitate this future research.

Summary updated

BibTeX
@inproceedings{yuan2024r,
  author = {Tongxin Yuan and Zhiwei He and Lingzhong Dong and Yiming Wang and Ruijie Zhao and Tian Xia and Lizhen Xu and Binglin Zhou and Li Fangqi and Zhuosheng Zhang and Rui Wang and Gongshen Liu},
  title = {{R-Judge: Benchmarking Safety Risk Awareness for LLM Agents}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.findings-emnlp.79},
}
Figure