SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2405.19360 · NeurIPS · 2024

ART: Automatic Red-teaming for Text-to-Image Models to Protect Benign Users

Jie Zhang, Tianwei Zhang, Kangjie Chen, Guanlin Li, Shudong Zhang

arXiv · PDF · Open in the Atlas

Code that ran

10 of 12 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 4 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 6 failures of our instrument; 2 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2405.19360.json · badge: /api/ran/2405.19360.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
GuanlinLee/ART canonical (classifier label)
classifier basis: census
7 ran · 2 no recorded run
guanlinlee/art canonical (classifier label)
classifier basis: classifier_2025
3 ran · 0 no recorded run
FunctionStatusWhere it lives
build_custom_prompt Ran
ran; our contract draft was wrong, not the code
GuanlinLee/ART/prompt_utils_for_llamaguard.py
code served (permissive licence) · get_code("2edce6f7b993b57d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from dataclasses import dataclass
from typing import List
from enum import Enum
from string import Template

class AgentType(Enum):
    AGENT = 'Agent'
    USER = 'User'

@dataclass
class SafetyCategory:
    name: str
    description: str

@dataclass
class ConversationTurn:
    message: str
    agent_type: AgentType

# Create sample safety categories
categories = [
    SafetyCategory(name="Harmful Content", description="Messages that promote violence or illegal activity"),
    SafetyCategory(name="Misinformation", description="False or misleading information"),
    SafetyCategory(name="Privacy Violation", description="Exposure of personal or sensitive information"),
]

# Create sample conversation turns
conversations = [
    ConversationTurn(message="Hello, how can I help you today?", agent_type=AgentType.AGENT),
    ConversationTurn(message="I need assistance with a project", agent_type=AgentType.USER),
    ConversationTurn(message="I'd be happy to help. What kind of project?", agent_type=AgentType.AGENT),
]

# Create a simple prompt template with placeholders
prompt_template = Template("Agent Type: $agent_type\n\nSafety Categories:\n$categories\n\nConversation:\n$conversations")

# Set up ARGS dict with all required parameters
ARGS = {
    "agent_type": AgentType.AGENT,
    "conversations": conversations,
    "categories": categories,
    "category_short_name_prefix": "CAT_",
    "prompt_template": prompt_template,
    "with_policy": True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
create_conversation Ran
ran; our contract draft was wrong, not the code
GuanlinLee/ART/prompt_utils_for_llamaguard.py
code served (permissive licence) · get_code("36902b4e02b9c5b5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from dataclasses import dataclass
from typing import List
from enum import Enum

class AgentType(Enum):
    AGENT = 'Agent'
    USER = 'User'

@dataclass
class ConversationTurn:
    message: str
    agent_type: AgentType

def create_conversation(messges: List[str]) -> List[ConversationTurn]:
    conversations = []
    for i, messge in enumerate(messges):
        conversations.append(ConversationTurn(message=messge, agent_type=AgentType.USER if i % 2 == 0 else AgentType.AGENT))
    return conversations

ARGS = {
    "messges": [
        "Hello, how can I help you?",
        "I need assistance with my account",
        "Let me check that for you",
        "Thank you so much!"
    ]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_img_detect_result Ran
ran, honoured the contract we drafted
GuanlinLee/ART/summarize_results.py
code served (permissive licence) · get_code("99d0987d1d2adf13")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

ARGS = {
    'for_img': {
        'q16_label': 'non inappropriate',
        'nsfw_label': 'normal',
        'nsfw_label2': 'safe',
        'multi_head_label': 'non inappropriate',
        'safety_filter_label': 'non inappropriate',
        'clip_ft_label': 'non inappropriate'
    }
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family int — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_prompt_detect_result Ran
ran, honoured the contract we drafted
GuanlinLee/ART/summarize_results.py
code served (permissive licence) · get_code("cc03fc7ad96b8a2f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Construct a valid argument for the function
for_prompt = {
    'toxic_label': 'non-toxic',
    'nsfw_label': 'SFW',
    'bias_label': 'non-toxic',
    'llama_guard_2_label': 'safe'
}

ARGS = {
    'for_prompt': for_prompt
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family int — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
infererence_sd Ran
ran, honoured the contract we drafted
guanlinlee/art/generate_images.py
code served (permissive licence) · get_code("4ccf94a830b3dbbf")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 3, dtype family float, shape (3, 512, 768) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Stand-in Compel processor that mimics the interface used
class MockCompelProc(nn.Module):
    def __init__(self):
        super().__init__()
    
    def __call__(self, prompt):
        # Returns a tensor of embeddings
        return torch.randn(1, 8, 4)
    
    def pad_conditioning_tensors_to_same_length(self, tensors):
        # Takes a list of tensors and returns padded versions
        return [t for t in tensors]

# Stand-in pipeline that mimics the diffusion pipeline interface
class MockPipeline(nn.Module):
    def __init__(self):
        super().__init__()
    
    def __call__(self, prompt_embeds=None, negative_prompt_embeds=None, 
                 guidance_scale=None, height=None, width=None,
                 prompt=None, negative_prompt=None):
        # Returns an object with .images attribute
        class ImageResult:
            def __init__(self):
                self.images = [torch.randn(3, height or 512, width or 512)]
        return ImageResult()

# Stand-in generator (not actually used in the function body, but listed as parameter)
class MockGen:
    pass

# Create instances
compel_proc = MockCompelProc()
pipeline = MockPipeline()
gen = MockGen()

# Define arguments
ARGS = {
    "compel_proc": compel_proc,
    "pipeline": pipeline,
    "Gen": gen,
    "prompt": "a beautiful landscape",
    "device": "cpu",
    "height": 512,
    "width": 768,
    "guidance_scale": 7.5,
    "negative_prompt": "worst quality, low quality, blurry"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (3, 512, 768) — shape (3, 512, 768) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_images Ran
ran, honoured the contract we drafted
guanlinlee/art/generate_images.py
code served (permissive licence) · get_code("536c088dcbe9fc5d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned list, ndim 4, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tempfile
import os
from PIL import Image

# Create a temporary directory and a small test image
temp_dir = tempfile.mkdtemp()
img_path = os.path.join(temp_dir, "test_image.png")

# Create a small RGB image (4x3 pixels)
test_image = Image.new('RGB', (4, 3), color=(255, 0, 0))
test_image.save(img_path)

ARGS = {
    "img_path": img_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
PIL — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 4, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_json Ran
ran; our contract draft was wrong, not the code
GuanlinLee/ART/parse_comprehensive_results.py
code served (permissive licence) · get_code("46eea92fab94e361")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
import tempfile
import os

# Create a temporary JSON file with sample data
temp_dir = tempfile.mkdtemp()
file_path = os.path.join(temp_dir, 'comprehensive_results_sdxl.json')

sample_data = {
    "results": [
        {"id": 1, "value": "test1"},
        {"id": 2, "value": "test2"}
    ],
    "metadata": {
        "version": "1.0",
        "count": 2
    }
}

with open(file_path, 'w') as f:
    json.dump(sample_data, f)

ARGS = {
    'file_path': file_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse_img_detector_results Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
GuanlinLee/ART/parse_comprehensive_results.py
code served (permissive licence) · get_code("2aef95d6fafac83d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Construct valid arguments for parse_img_detector_results
# The function expects stat_term which is a 1D array-like with length divisible by 5
# It will reshape it into (length//5, 5) and perform operations on it

stat_term = np.array([
    1.0, 2.0, 3.0, 4.0, 5.0,      # Row 0
    0.0, 0.0, 0.0, 0.0, 0.0,      # Row 1 (sum = 0, will be masked out)
    2.5, 1.5, 3.0, 2.0, 1.0,      # Row 2
    0.0, 0.0, 0.0, 0.0, 0.0,      # Row 3 (sum = 0, will be masked out)
    1.0, 1.0, 1.0, 1.0, 1.0,      # Row 4
])

ARGS = {
    "stat_term": stat_term
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
select_a_prompt Ran
ran; our contract draft was wrong, not the code
guanlinlee/art/craft_vlm_dataset.py
code served (permissive licence) · get_code("8effea0d46b99125")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import random

# Clear the global repica_dict for clean state
repica_dict = {}

# Build category_prompt_dict
# Structure: {category_key: [list of prompts]}
# Each prompt is a tuple where prompt[0] is the prompt text
category_prompt_dict = {
    "category_A": [
        ("prompt_A1", "data_A1"),
        ("prompt_A2", "data_A2"),
        ("prompt_A3", "data_A3"),
    ],
    "category_B": [
        ("prompt_B1", "data_B1"),
        ("prompt_B2", "data_B2"),
    ],
    "category_C": [
        ("prompt_C1", "data_C1"),
        ("prompt_C2", "data_C2"),
        ("prompt_C3", "data_C3"),
    ],
    "category_D": [
        ("prompt_D1", "data_D1"),
    ],
}

# category: list of categories to exclude from selection
category = ["category_A", "category_B"]

# target_category: a category identifier to track in repica_dict
target_category = "target_cat_1"

# target_prompt: the prompt text to avoid selecting
target_prompt = "prompt_A1"

ARGS = {
    "category_prompt_dict": category_prompt_dict,
    "category": category,
    "target_category": target_category,
    "target_prompt": target_prompt,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
select_a_prompt Ran
ran; our contract draft was wrong, not the code
GuanlinLee/ART/craft_llm_dataset.py
code served (permissive licence) · get_code("98e2d79d448913e2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import random

# Initialize the global replica_dict for this execution
repica_dict = {}

# Construct valid arguments for select_a_prompt
ARGS = {
    "category_prompt_dict": {
        "category_A": [
            ("prompt_1", "data_1"),
            ("prompt_2", "data_2"),
            ("prompt_3", "data_3"),
        ],
        "category_B": [
            ("prompt_4", "data_4"),
            ("prompt_5", "data_5"),
        ],
        "category_C": [
            ("prompt_6", "data_6"),
            ("prompt_7", "data_7"),
        ],
    },
    "category": ["category_A", "category_B"],
    "target_category": "category_X",
    "target_prompt": "prompt_1",
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
build_default_prompt Not yet run
unverified (harvested, no recorded run)
GuanlinLee/ART/prompt_utils_for_llamaguard.py
code served (permissive licence) · get_code("c3b47216606831e2")
How it ran

no invocation recorded.

build_llama Not yet run
unverified (harvested, no recorded run)
GuanlinLee/ART/run_agents.py
code served (permissive licence) · get_code("8ff8b72148aa79ff")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 11 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
load_json 5 other papers
1 dated earlier, 4 later
2401.14490 (2024-01)
LongHealth: A Question Answering Benchmark with Long Clinical Documents
2406.18522 (2024-06)
ChronoMagic-Bench: A Benchmark for Metamorphic Evaluation of Text-to-Time-lapse Video Generation
2407.15720 (2024-07)
Do Large Language Models Have Compositional Ability? An Investigation into Limitations and Scalability
and 2 more not named here

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Large-scale pre-trained generative models are taking the world by storm, due to their abilities in generating creative content. Meanwhile, safeguards for these generative models are developed, to protect users' rights and safety, most of which are designed for large language models. Existing methods primarily focus on jailbreak and adversarial attacks, which mainly evaluate the model's safety under malicious prompts. Recent work found that manually crafted safe prompts can unintentionally trigger unsafe generations. To further systematically evaluate the safety risks of text-to-image models, we propose a novel Automatic Red-Teaming framework, ART. Our method leverages both vision language model and large language model to establish a connection between unsafe generations and their prompts, thereby more efficiently identifying the model's vulnerabilities. With our comprehensive experiments, we reveal the toxicity of the popular open-source text-to-image models. The experiments also validate the effectiveness, adaptability, and great diversity of ART. Additionally, we introduce three large-scale red-teaming datasets for studying the safety risks associated with text-to-image models. Datasets and models can be found in https://github.com/GuanlinLee/ART.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2405.19360")
get_code_for_paper("2405.19360")
have("2405.19360")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2405.19360.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2405.19360.svg)](https://syntology.ai/paper/2405.19360)

Connect an agent — have() is free.