PRJ: Perception–Retrieval–Judgement for Generated Images

Qiang Fu, Zonglei Jing, Zonghao Ying, Xiaoqian Li

TL;DR

Traditional image safety checkers rely on rigid binary filters that struggle to catch nuanced or adversarially masked harms in AI-generated content. To address this, researchers have introduced PRJ (Perception-Retrieval-Judgement), a language-driven framework that mimics human cognition by describing an image, retrieving relevant toxic knowledge via RAG, and judging harm using a multi-dimensional risk matrix. This approach significantly boosts detection accuracy, handles complex adversarial jailbreaks, and provides explainable, fine-grained toxicity scores rather than a simple "safe/unsafe" label.

What Problem Does This Paper Address?

The rapid proliferation of text-to-image (T2I) models like Stable Diffusion and DALL-E 3 has made generating high-quality imagery effortless. However, it has also opened the door to harmful outputs, including NSFW content, violence, hate speech, and copyright violations.

Current image safety tools suffer from two major flaws:

  1. Rigid Binary Outputs: They act as simple "Yes/No" filters, failing to provide context or understand fluid, context-dependent risks (e.g., a red armband might be benign in a historical reenactment prompt but toxic in a hate speech context).
  2. Vulnerability to Jailbreaks: They are easily bypassed by adversarial attacks that subtly alter prompts or image latents to mask toxicity.

Furthermore, standard evaluation metrics like Attack Success Rate (ASR) only measure whether an attack bypassed a filter, completely ignoring the severity or escalation of the harm.

Methods

PRJ shifts the paradigm from shallow visual classification to a language-centric, structured reasoning process. It breaks toxicity detection down into three cognitively inspired stages:

  1. Perception: The framework uses a Vision-Language Model (VLM), specifically LLaVA-34B, to translate the visual input into text. It generates both a global image caption and a detailed list of localized semantic features (objects, attributes, text overlays).
  2. Retrieval: Using Retrieval-Augmented Generation (RAG), the framework queries an external toxic knowledge base using the generated text features. This step mimics human memory recall, pulling in structured definitions of specific harm categories (e.g., trademark laws or hate symbol descriptions).
  3. Judgement: A Large Language Model (LLM) evaluates the combined image descriptions and retrieved knowledge against a multi-dimensional Toxicity Risk Matrix. This matrix scores the content across five cognitive dimensions: Moral Cognition, Emotional Processing, Visual Memory Impact, Attentional Capture, and Semantic Intensity.

The final output is a continuous toxicity score, a specific harm category, and a textual justification explaining the decision.

The three-stage PRJ pipeline: Perception (VLM), Retrieval (RAG), and Judgement (LLM).

Datasets

The authors evaluated PRJ using a dataset of 1,200 text prompts:

  • 720 prompts from the public I2P (Inappropriate Image Prompts) dataset, focusing on standard NSFW and violent content.
  • 480 curated prompts designed to capture underrepresented but safety-critical categories, such as copyright/trademark infringements and subtle hate symbols.

Images were generated across six diverse T2I models: SDXL, SD-3-Medium, SD-3.5-Medium, SD-3.5-Large, SD-3.5-Large-Turbo, and DALL-E 3. To evaluate robustness, the authors subjected these models to four advanced jailbreak methods: QF-PGD, SneakyPrompt, RT-Attack, and CogMorph.

Key Insights and Ideas

  • Language as a Common Interface: By converting visual pixels into structured text features, PRJ unifies multimodal signals. This allows the system to leverage the deep reasoning capabilities of LLMs and external text databases, making the safety check inherently explainable.
  • Toxicity is a Spectrum: Moving away from binary classification allows the system to track toxicity escalation—quantifying exactly how much more harmful an image becomes under adversarial pressure.
  • Granular Harm Attribution: PRJ can distinguish between 10 primary harm categories (e.g., Copyright Infringement, Self-Harm, Discrimination, Illicit Content). This provides downstream moderation systems with highly actionable signals compared to traditional tools.

Key Results

  • Superior Detection Rates: PRJ consistently outperformed established baselines (SDSC, OpenAI Moderation, and Q16) across all six T2I models. It achieved the highest Toxic Image Detection Rate (TIDR), showing an average improvement of over 10 percentage points compared to the neural classifier Q16.
  • Quantifying Jailbreaks: The framework successfully exposed the potency of different attacks. On SDXL, the CogMorph attack was identified as the most effective, yielding a Toxicity Escalation Success Rate (TESR) of 66.13% and the highest Mean Toxicity Score (MTS) of 0.1890.
  • Cross-Model Generalizability: PRJ proved highly robust across different generator architectures, successfully flagging latent harm even in commercially aligned models like DALL-E 3 (achieving a 71.58% detection rate).

Limitations and Future Work

The primary trade-off for PRJ’s depth is inference latency. Because it runs multiple RAG queries per image feature, PRJ takes an average of 8.74 seconds per image, whereas traditional binary checkers take only 2 to 3 seconds. This makes it challenging to deploy in high-throughput, real-time applications without optimization. Additionally, its accuracy is tightly coupled with the quality and cultural comprehensiveness of its external toxic knowledge base.

For future work, the authors plan to explore efficient approximations to speed up the retrieval loop, develop adaptive risk matrices tailored to different regional cultures/languages, and extend the framework to video generation and multimodal AI agents.

Summary updated

BibTeX
@inproceedings{fu2025prj,
  author = {Qiang Fu and Zonglei Jing and Zonghao Ying and Xiaoqian Li},
  title = {{PRJ: Perception–Retrieval–Judgement for Generated Images}},
  booktitle = {Electronics},
  year = {2025},
  doi = {10.3390/electronics14122354},
}
Figure