Manuscript Offprint

arXiv:2609.39688

ShieldCLIP: Selective Safety Alignment for Harmful Content Mitigation in Multimodal Foundation Models

Tobia Poppi, Silvia Cappelletti, Samuele Poppi, Marcella Cornia, Lorenzo Baraldi, Diego Garcia-Olano, Rita Cucchiara

Abstract

Multimodal encoders such as CLIP underlie many downstream systems, but their web-scale training data embed harmful associations that safety alignment must suppress without unnecessarily changing benign representations. Because ethical and practical constraints prevent collecting real unsafe content at scale, existing datasets pair safe real samples with generated counterparts, but label every generated sample unsafe, even when one modality is individually safe. To address this, we introduce ShieldCLIP, the first framework to condition safety alignment on the observed safety state of each modality rather than the origin of a sample, preserving safe content while redirecting only what is unsafe. We also introduce ViSUV2, a 195k-quadruplet dataset with independent per-modality safety labels across 578 concepts and 28 categories. Using these labels, ShieldCLIP defines a four-way conditional objective beyond pair-level supervision: safe content is anchored, unsafe modalities are redirected to their safe counterparts, mixed pairs update only the unsafe branch, and coherence is enforced when both are unsafe. We evaluate ShieldCLIP on cross-modal retrieval, text-to-image generation with Stable Diffusion v1.4 and SDXL, and image-to-text generation with LLaVA. Across these settings, ShieldCLIP consistently reduces harmful outputs over prior safety-aligned encoders and strong mitigation baselines, while preserving the utility of the original embedding space. Extensive ablation studies further show that both modality-specific supervision and the selective alignment objective contribute to these gains. Source code, trained models, and ViSUV2 (under a controlled-access protocol) will be made publicly available at https://aimagelab.github.io/ShieldCLIP/.

Keywords: AI Safety, Vision-and-Language, Trustworthy AI, Harmful Content Mitigation.

Content warning. This article contains examples and descriptions of harmful or explicit content, including sexual and violent material, which some readers may find disturbing or offensive.

1 Introduction

Recent advances in multimodal foundation models, such as CLIP (Radford et al., 2021), LLaVA (H. Liu, Li, Li, & Lee, 2024; H. Liu, Li, Wu, & Lee, 2023), Stable Diffusion (Esser et al., 2024; Podell et al., 2024; Rombach, Blattmann, Lorenz, Esser, & Ommer, 2022), and FLUX (Black Forest Labs, 2024), have enabled rich cross-modal associations between images and text, powering applications from retrieval and captioning to large-scale generative systems. These models derive their generalization abilities from massive web-scale datasets, but uncontrolled data collection can introduce harmful biases (Birhane, Prabhu, & Kahembwe, 2021), unsafe associations (Abid, Farooqi, & Zou, 2021), and inappropriate content (Schuhmann et al., 2022). Their outputs can consequently drift into sexual, violent, or otherwise harmful content, raising serious concerns about responsible deployment (Bommasani et al., 2021; Weidinger et al., 2022).

A central challenge lies in the shared embedding space learned by models such as CLIP. This space supports multimodal retrieval (T. Wang et al., 2024; Wei et al., 2024), text-to-image generation (Podell et al., 2024; Rombach et al., 2022), and visual dialog and reasoning (H. Liu et al., 2024, 2023). Unsafe prompts or images can be projected into harmful regions of this space, steering downstream pipelines toward inappropriate outputs. Conversely, benign prompts can yield unsafe generations because of biases in learned associations (Schramowski, Brack, Deiseroth, & Kersting, 2023). Improving safety at the encoder level can therefore benefit several downstream systems without modifying each decoder independently.

Embedding-level mitigation offers a general way to intervene before decoding (C. Kim & Qi, 2025): unsafe inputs are redirected toward benign representations, while safe content is anchored to the original embedding space (Ahn & Jung, 2025; R. Liu et al., 2024; S. Poppi et al., 2024). Recent work extends this line by restructuring the shared space itself (T. Poppi, Kasarla, Mettes, Baraldi, & Cucchiara, 2025) or by bounding how far unsafe concepts are displaced (Yousaf, Fioresi, Beetham, Bedi, & Shah, 2026). The concern motivating both is that aggressive redirection collapses the semantic structure of the space and erodes utility in ways that standard metrics do not expose (Yousaf, Ghosh, Beetham, Bedi, & Shah, 2026).

How supervision is obtained compounds this risk. Because real unsafe images and captions cannot be collected at scale for ethical and practical reasons, existing paired-data formulations synthesize them instead: a safe caption is rewritten into an unsafe variant conditioned on a harmful concept, and an image is generated from that unsafe caption. The resulting pair is then treated as jointly unsafe simply because it was produced by this pipeline, even though neither rewriting a caption around a harmful concept nor rendering an image from it guarantees that the output is actually harmful: a caption about fraud may produce a visually harmless office scene, while a benign caption about an operating room may yield disturbing surgical imagery. Such cases are not marginal. In the data we collect, 39% of generated pairs combine a safe modality with an unsafe one, so uniform redirection alters benign representations and introduces conflicting supervision whenever the two modalities disagree.

To address this problem, we introduce Shield-CLIP, a framework for selective safety alignment in CLIP-like multimodal encoders. It is trained on data that preserve the semantic correspondence between real and generated image-text pairs while carrying an independent safety label for each generated modality. The resulting formulation distinguishes safe-safe, unsafe-unsafe, safe-text/unsafe-image, and unsafe-text/safe-image pairs, allowing supervision to follow the observed content rather than its source.

We further introduce ViSUv2, a dataset of 195k real/generated image-text quadruplets. ViSU (S. Poppi et al., 2024) pairs safe image-text samples with generated counterparts under a common safety assignment and a 20-category taxonomy. ViSUv2 retains this paired structure while labeling generated captions and images independently, expanding the taxonomy to 28 categories grounded in 578 fine-grained concepts, and using more recent language and diffusion models.

These modality-level labels enable a conditional objective that pair-level alignment, which redirects all generated content under a shared safety assignment, cannot express. Real and generated-safe samples are preserved by aligning them with frozen CLIP anchors, while generated-unsafe samples are redirected toward their real safe counterparts.

For mixed pairs, only the unsafe modality is updated while the safe branch is frozen; when both generated modalities are unsafe, an additional coherence term preserves their semantic correspondence during redirection. This selective design reduces over-sanitization while maintaining compatibility with systems built on the original CLIP geometry.

We first validate ViSUV2 against existing safety datasets in terms of diversity and harmfulness. We then evaluate ShieldCLIP across cross-modal retrieval, text-to-image generation with Stable Diffusion v1.4 and SDXL, and image-to-text generation with LLaVA. Beyond the main comparisons, we assess robustness across prompt distributions and different safety classifiers, study the contribution of modality-specific supervision and individual loss components, and analyze the safety–utility trade-off through retrieval, generation, and preservation metrics. Automatic evaluation is further complemented by human judgments of safety and content preservation.

Contributions. Our main contributions are:

• Data and supervision. We introduce ViSUV2, with independent text and image safety labels, 578 concepts, 28 categories, and human validation of the modality-level annotations.

• Selective alignment. We condition preservation and redirection on modality-specific safety states, explicitly handling mixed pairs and maintaining coherence when both modalities are unsafe.

• Evaluation. We evaluate ShieldCLIP across cross-modal retrieval, diffusion models, and multimodal language models, complemented by evaluation with multiple safety classifiers, human judgments, targeted ablation studies of the selective objective, and preservation analyses.

Relation to the Conference Version. This work extends Safe-CLIP (S. Poppi et al., 2024), which addressed encoder-level mitigation through pair-level supervision that treated all generated samples as unsafe. Here, we formulate safety alignment at the modality level and condition the objective on the four possible safety states of generated image-text pairs. We replace ViSU with ViSUV2, which introduces independent text and image safety labels, expands the taxonomy from 20 to 28 categories, and includes human validation of the annotations. To disentangle the contribution of the new data from that of the selective objective, we conduct matched training experiments with Safe-CLIP and ShieldCLIP on both ViSU and ViSUV2. We further extend the experimental analysis with targeted ablation studies of modality-specific supervision and loss design, evaluation with SDXL and multiple safety classifiers, and a human preference study.

The rest of the paper is organized as follows. Section 2 reviews related work on safety alignment. Section 3.1 formalizes safety alignment in multimodal encoders, and Sections 3.2 and 3.3 introduce ViSUV2 and the ShieldCLIP framework, respectively. Section 4 presents the experimental evaluation and analyses. Additional dataset details, extended results, and qualitative examples are provided in the appendices.

References (100)

Couldn't load all references. Reload the page to try again.