File size: 9,965 Bytes
a19dc50
 
bb719d9
 
305cb9d
 
 
 
5530bc6
305cb9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bd8797d
 
27d1aa4
bd8797d
27d1aa4
bd8797d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
---
license: apache-2.0
base_model:
- prithivMLmods/VisionGuardrail-9B
tags:
- text-generation-inference
- fp8
- VisionGuardrail
- v1.0
- JSON
- image-classification
- content-safety
- content-moderation
- multimodal
- safety-classifier
- guardrail
- visual-safety
- multimodal-content-filter
- mmcf
datasets:
- prithivMLmods/ImageShield-Guardrail-Pro
language:
- en
pipeline_tag: image-text-to-text
library_name: transformers
---

# VisionGuardrail-9B-fp8

VisionGuardrail-9B-fp8 is an FP8 dynamic quantized version of [prithivMLmods/VisionGuardrail-9B](https://huggingface.co/prithivMLmods/VisionGuardrail-9B), a multimodal content-safety classifier based on [Qwen/Qwen3.5-9B](https://huggingface.co/Qwen/Qwen3.5-9B).

The model is trained on the [ImageShield-Guardrail-Pro](https://huggingface.co/datasets/prithivMLmods/ImageShield-Guardrail-Pro) content-safety guardrail dataset and is designed to classify visual content as **Safe** or **Unsafe**, with a particular focus on detecting **Not Safe for Work (NSFW) sensual content** and other potentially sensitive visual content.

The FP8 dynamic quantization reduces the model's memory footprint while retaining the multimodal vision and classification capabilities of the original BF16 model, making deployment more accessible on GPUs with FP8 support.

> [!TIP]
> hf.co/blog — [vision-guardrail-mini-blog](https://huggingface.co/blog/prithivMLmods/vision-guardrail-mini-blog)

> [!NOTE]
> **This model is an experimental release and may generate unexpected behaviors or reasoning artifacts in certain scenarios.**

> [!IMPORTANT]
> **This model is intended for research and content-safety classification only.** Any outputs generated by this model are the sole responsibility of the user. The authors and hosting platform disclaim all liability for generated content. Users must ensure safe, ethical, and lawful usage.

## Quantization Details

Quantization was performed using `llmcompressor` with the following recipe:

```yaml
default_stage:
  default_modifiers:
    QuantizationModifier:
      targets: [Linear]
      ignore: ['re:.*lm_head', 're:.*embed_tokens$', 're:.*visual.*', 're:.*model.visual.*',
        're:.*linear_attn.*']
      scheme: FP8_DYNAMIC
      bypass_divisibility_checks: false
      requires_calibration_data: false
```

Linear layers are quantized to FP8 using dynamic per-tensor activation scaling. The `lm_head`, embedding table, vision components (`visual`), and `linear_attn` layers are excluded from quantization and remain at full precision.

This approach reduces the overall model size and memory requirements while preserving the vision-language representation and content-safety classification capabilities of the base model.

|                                |                                                    |
| ------------------------------ | -------------------------------------------------- |
| **Base model**                 | prithivMLmods/VisionGuardrail-9B                   |
| **Underlying model**           | Qwen/Qwen3.5-9B                                    |
| **Quantization scheme**        | FP8_DYNAMIC (Linear layers only)                   |
| **Format**                     | compressed-tensors                                 |
| **Calibration required**       | No                                                 |
| **Excluded from quantization** | `lm_head`, `embed_tokens`, `visual`, `linear_attn` |

## Model Details

|                      |                                             |
| -------------------- | ------------------------------------------- |
| **Developer**        | prithivMLmods                               |
| **Quantized by**     | prithivMLmods                               |
| **Architecture**     | Multimodal decoder-only language model      |
| **Parameters**       | 9B                                          |
| **Base model**       | Qwen/Qwen3.5-9B                             |
| **Training dataset** | ImageShield-Guardrail-Pro                   |
| **Task**             | Multimodal content-safety classification    |
| **Input**            | Image + text prompt                         |
| **Output**           | Safe / Unsafe classification with reasoning |
| **Quantization**     | FP8 Dynamic                                 |
| **Format**           | compressed-tensors                          |

## Intended Use

VisionGuardrail-9B-FP8 is intended for multimodal content-safety research and visual content classification.

The model can be used to analyze images for potentially sensitive or unsafe visual content, including:

* NSFW sensual content
* Explicit visual content
* Clothing exposure
* Dress-code related visual cues
* Poses and body positioning
* Framing and visual composition
* Potentially sensitive visual settings
* Other content requiring conservative safety classification

The model is designed to provide a **Safe** or **Unsafe** classification based on the visual content and accompanying prompt.

## Usage with Transformers

The FP8 checkpoint can be loaded using the Transformers ecosystem with support for compressed-tensors quantization.

```python
from transformers import AutoProcessor, AutoModelForImageTextToText
from PIL import Image

model_id = "prithivMLmods/VisionGuardrail-9B-fp8"

processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForImageTextToText.from_pretrained(
    model_id,
    device_map="auto",
)

image = Image.open("image.jpg")

messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {
                "type": "text",
                "text": "Classify this image as Safe or Unsafe and explain the safety classification.",
            },
        ],
    }
]

text = processor.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
)

inputs = processor(
    text=text,
    images=image,
    return_tensors="pt",
).to(model.device)

outputs = model.generate(
    **inputs,
    max_new_tokens=512,
)

response = processor.batch_decode(
    outputs,
    skip_special_tokens=True,
)[0]

print(response)
```

> **Note:** Refer to the base [VisionGuardrail-9B](https://huggingface.co/prithivMLmods/VisionGuardrail-9B) model card for the recommended prompt format and inference behavior.

## Prompt Format

A simple classification prompt can be used:

```text
Analyze the provided image for content safety.

Classify the image as either:
- Safe
- Unsafe

Provide a concise explanation for the classification.
```

For production applications, it is recommended to define a strict output schema and validate the generated response before consuming the classification programmatically.

## Hardware Requirements

FP8 inference is recommended on GPUs with native FP8 support, such as NVIDIA Hopper and Blackwell architectures.

The quantized model can also be used on other supported GPUs where FP8 weights are dequantized during execution, although performance and memory characteristics may differ.

For best performance:

* Use a recent PyTorch release with FP8 support.
* Use a recent Transformers release with `compressed-tensors` support.
* Prefer NVIDIA Hopper or Blackwell GPUs for native FP8 execution.
* Use `bfloat16` for non-quantized components where supported.

## Quantization Recipe

The complete quantization configuration is:

```yaml
default_stage:
  default_modifiers:
    QuantizationModifier:
      targets: [Linear]
      ignore:
        - 're:.*lm_head'
        - 're:.*embed_tokens$'
        - 're:.*visual.*'
        - 're:.*model.visual.*'
        - 're:.*linear_attn.*'
      scheme: FP8_DYNAMIC
      bypass_divisibility_checks: false
      requires_calibration_data: false
```

### Quantization Strategy

* **Linear layers:** FP8 Dynamic
* **Activation scaling:** Dynamic
* **Calibration dataset:** Not required
* **Language-model head:** Full precision
* **Token embeddings:** Full precision
* **Vision encoder:** Full precision
* **Linear attention layers:** Full precision

Keeping the vision components and selected attention layers in higher precision is intended to preserve multimodal representation quality and classification behavior.

## Limitations

VisionGuardrail-9B-FP8 inherits the limitations of [VisionGuardrail-9B](https://huggingface.co/prithivMLmods/VisionGuardrail-9B).

The model is an experimental content-safety classifier and should not be treated as a definitive safety system. Classification errors, false positives, and false negatives may occur.

FP8 quantization may introduce small numerical differences compared with the original BF16 checkpoint. Downstream performance should therefore be evaluated against the original model for production deployments.

The model should be used as one component of a broader content-moderation pipeline rather than as the sole safety mechanism for high-risk applications.

## Responsible AI

This model is intended for research, evaluation, and responsible content-safety applications.

Users are responsible for ensuring that their deployment complies with applicable laws, regulations, platform policies, and organizational safety requirements.

For the full safety guidance, intended use, limitations, and responsible AI considerations, refer to the [VisionGuardrail-9B model card](https://huggingface.co/prithivMLmods/VisionGuardrail-9B).

## License

VisionGuardrail-9B-FP8 follows the licensing terms of the underlying [Qwen/Qwen3.5-9B](https://huggingface.co/Qwen/Qwen3.5-9B) model and the [VisionGuardrail-9B](https://huggingface.co/prithivMLmods/VisionGuardrail-9B) release.

Please review the applicable licenses before using the model in production or redistribution.

## Related Models and Datasets

* [VisionGuardrail-9B](https://huggingface.co/prithivMLmods/VisionGuardrail-9B)
* [Qwen/Qwen3.5-9B](https://huggingface.co/Qwen/Qwen3.5-9B)
* [ImageShield-Guardrail-Pro](https://huggingface.co/datasets/prithivMLmods/ImageShield-Guardrail-Pro)