prithivMLmods commited on
Commit
bd8797d
·
verified ·
1 Parent(s): 1ac2be3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +229 -1
README.md CHANGED
@@ -2,4 +2,232 @@
2
  license: apache-2.0
3
  base_model:
4
  - prithivMLmods/VisionGuardrail-9B
5
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: apache-2.0
3
  base_model:
4
  - prithivMLmods/VisionGuardrail-9B
5
+ ---
6
+
7
+ # VisionGuardrail-9B-FP8
8
+
9
+ 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).
10
+
11
+ 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.
12
+
13
+ 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.
14
+
15
+ > [!TIP]
16
+ > hf.co/blog — [vision-guardrail-mini-blog](https://huggingface.co/blog/prithivMLmods/vision-guardrail-mini-blog)
17
+
18
+ > [!NOTE]
19
+ > **This model is an experimental release and may generate unexpected behaviors or reasoning artifacts in certain scenarios.**
20
+
21
+ > [!IMPORTANT]
22
+ > **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.
23
+
24
+ ## Quantization Details
25
+
26
+ Quantization was performed using `llmcompressor` with the following recipe:
27
+
28
+ ```yaml
29
+ default_stage:
30
+ default_modifiers:
31
+ QuantizationModifier:
32
+ targets: [Linear]
33
+ ignore: ['re:.*lm_head', 're:.*embed_tokens$', 're:.*visual.*', 're:.*model.visual.*',
34
+ 're:.*linear_attn.*']
35
+ scheme: FP8_DYNAMIC
36
+ bypass_divisibility_checks: false
37
+ requires_calibration_data: false
38
+ ```
39
+
40
+ 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.
41
+
42
+ 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.
43
+
44
+ | | |
45
+ | ------------------------------ | -------------------------------------------------- |
46
+ | **Base model** | prithivMLmods/VisionGuardrail-9B |
47
+ | **Underlying model** | Qwen/Qwen3.5-9B |
48
+ | **Quantization scheme** | FP8_DYNAMIC (Linear layers only) |
49
+ | **Format** | compressed-tensors |
50
+ | **Calibration required** | No |
51
+ | **Excluded from quantization** | `lm_head`, `embed_tokens`, `visual`, `linear_attn` |
52
+
53
+ ## Model Details
54
+
55
+ | | |
56
+ | -------------------- | ------------------------------------------- |
57
+ | **Developer** | prithivMLmods |
58
+ | **Quantized by** | prithivMLmods |
59
+ | **Architecture** | Multimodal decoder-only language model |
60
+ | **Parameters** | 9B |
61
+ | **Base model** | Qwen/Qwen3.5-9B |
62
+ | **Training dataset** | ImageShield-Guardrail-Pro |
63
+ | **Task** | Multimodal content-safety classification |
64
+ | **Input** | Image + text prompt |
65
+ | **Output** | Safe / Unsafe classification with reasoning |
66
+ | **Quantization** | FP8 Dynamic |
67
+ | **Format** | compressed-tensors |
68
+
69
+ ## Intended Use
70
+
71
+ VisionGuardrail-9B-FP8 is intended for multimodal content-safety research and visual content classification.
72
+
73
+ The model can be used to analyze images for potentially sensitive or unsafe visual content, including:
74
+
75
+ * NSFW sensual content
76
+ * Explicit visual content
77
+ * Clothing exposure
78
+ * Dress-code related visual cues
79
+ * Poses and body positioning
80
+ * Framing and visual composition
81
+ * Potentially sensitive visual settings
82
+ * Other content requiring conservative safety classification
83
+
84
+ The model is designed to provide a **Safe** or **Unsafe** classification based on the visual content and accompanying prompt.
85
+
86
+ ## Usage with Transformers
87
+
88
+ The FP8 checkpoint can be loaded using the Transformers ecosystem with support for compressed-tensors quantization.
89
+
90
+ ```python
91
+ from transformers import AutoProcessor, AutoModelForImageTextToText
92
+ from PIL import Image
93
+
94
+ model_id = "prithivMLmods/VisionGuardrail-9B-fp8"
95
+
96
+ processor = AutoProcessor.from_pretrained(model_id)
97
+ model = AutoModelForImageTextToText.from_pretrained(
98
+ model_id,
99
+ device_map="auto",
100
+ )
101
+
102
+ image = Image.open("image.jpg")
103
+
104
+ messages = [
105
+ {
106
+ "role": "user",
107
+ "content": [
108
+ {"type": "image"},
109
+ {
110
+ "type": "text",
111
+ "text": "Classify this image as Safe or Unsafe and explain the safety classification.",
112
+ },
113
+ ],
114
+ }
115
+ ]
116
+
117
+ text = processor.apply_chat_template(
118
+ messages,
119
+ tokenize=False,
120
+ add_generation_prompt=True,
121
+ )
122
+
123
+ inputs = processor(
124
+ text=text,
125
+ images=image,
126
+ return_tensors="pt",
127
+ ).to(model.device)
128
+
129
+ outputs = model.generate(
130
+ **inputs,
131
+ max_new_tokens=512,
132
+ )
133
+
134
+ response = processor.batch_decode(
135
+ outputs,
136
+ skip_special_tokens=True,
137
+ )[0]
138
+
139
+ print(response)
140
+ ```
141
+
142
+ > **Note:** Refer to the base [VisionGuardrail-9B](https://huggingface.co/prithivMLmods/VisionGuardrail-9B) model card for the recommended prompt format and inference behavior.
143
+
144
+ ## Prompt Format
145
+
146
+ A simple classification prompt can be used:
147
+
148
+ ```text
149
+ Analyze the provided image for content safety.
150
+
151
+ Classify the image as either:
152
+ - Safe
153
+ - Unsafe
154
+
155
+ Provide a concise explanation for the classification.
156
+ ```
157
+
158
+ For production applications, it is recommended to define a strict output schema and validate the generated response before consuming the classification programmatically.
159
+
160
+ ## Hardware Requirements
161
+
162
+ FP8 inference is recommended on GPUs with native FP8 support, such as NVIDIA Hopper and Blackwell architectures.
163
+
164
+ 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.
165
+
166
+ For best performance:
167
+
168
+ * Use a recent PyTorch release with FP8 support.
169
+ * Use a recent Transformers release with `compressed-tensors` support.
170
+ * Prefer NVIDIA Hopper or Blackwell GPUs for native FP8 execution.
171
+ * Use `bfloat16` for non-quantized components where supported.
172
+
173
+ ## Quantization Recipe
174
+
175
+ The complete quantization configuration is:
176
+
177
+ ```yaml
178
+ default_stage:
179
+ default_modifiers:
180
+ QuantizationModifier:
181
+ targets: [Linear]
182
+ ignore:
183
+ - 're:.*lm_head'
184
+ - 're:.*embed_tokens$'
185
+ - 're:.*visual.*'
186
+ - 're:.*model.visual.*'
187
+ - 're:.*linear_attn.*'
188
+ scheme: FP8_DYNAMIC
189
+ bypass_divisibility_checks: false
190
+ requires_calibration_data: false
191
+ ```
192
+
193
+ ### Quantization Strategy
194
+
195
+ * **Linear layers:** FP8 Dynamic
196
+ * **Activation scaling:** Dynamic
197
+ * **Calibration dataset:** Not required
198
+ * **Language-model head:** Full precision
199
+ * **Token embeddings:** Full precision
200
+ * **Vision encoder:** Full precision
201
+ * **Linear attention layers:** Full precision
202
+
203
+ Keeping the vision components and selected attention layers in higher precision is intended to preserve multimodal representation quality and classification behavior.
204
+
205
+ ## Limitations
206
+
207
+ VisionGuardrail-9B-FP8 inherits the limitations of [VisionGuardrail-9B](https://huggingface.co/prithivMLmods/VisionGuardrail-9B).
208
+
209
+ 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.
210
+
211
+ 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.
212
+
213
+ 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.
214
+
215
+ ## Responsible AI
216
+
217
+ This model is intended for research, evaluation, and responsible content-safety applications.
218
+
219
+ Users are responsible for ensuring that their deployment complies with applicable laws, regulations, platform policies, and organizational safety requirements.
220
+
221
+ 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).
222
+
223
+ ## License
224
+
225
+ 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.
226
+
227
+ Please review the applicable licenses before using the model in production or redistribution.
228
+
229
+ ## Related Models and Datasets
230
+
231
+ * [VisionGuardrail-9B](https://huggingface.co/prithivMLmods/VisionGuardrail-9B)
232
+ * [Qwen/Qwen3.5-9B](https://huggingface.co/Qwen/Qwen3.5-9B)
233
+ * [ImageShield-Guardrail-Pro](https://huggingface.co/datasets/prithivMLmods/ImageShield-Guardrail-Pro)