Downloads · 30 days
57
5% of all-time downloads
rogerdeng/Qwen3Guard-0.6B-ONNX-Quantized
Qwen3Guard-0.6B-ONNX-Quantized is a text generation model from rogerdeng. Use it when you need the model to write or continue text. It is set up for transformers.js. The card lists the license as other.
This repository provides a web-optimized, Q4 quantized ONNX version of Qwen/Qwen3Guard-Gen-0.6B. It is specifically designed for high-performance, client-side safety moderation in browsers using transformers.js.
Downloads · 30 days
57
5% of all-time downloads
All-time downloads
1.2K
Public
Repo size
7 GB
Likes
0
Public
Click a slice to open those files.
.onnx941 MB · 99%
From the Hugging Face model README
This repository provides a web-optimized, Q4 quantized ONNX version of Qwen/Qwen3Guard-Gen-0.6B. It is specifically designed for high-performance, client-side safety moderation in browsers using transformers.js.
transformers.js (v3+/V4).| Attribute | Specification |
|---|---|
| Original Model | Qwen/Qwen3Guard-Gen-0.6B |
| Architecture | Causal Language Model (Qwen3) |
| Format | ONNX (Open Neural Network Exchange) |
| Quantization | Q4 (4-bit) (Optimized for CPU/WebGPU) |
This model is optimized for transformers.js (v3/v4). It is recommended to use the latest development version for full 4-bit WebGPU acceleration support:
npm install @huggingface/[email protected]
Or via CDN:
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]';
It is highly recommended to detect WebGPU support before initialization, falling back to CPU (WASM) if necessary.
async function isWebGPUSupported() {
if (!navigator.gpu) return false;
try {
const adapter = await navigator.gpu.requestAdapter();
return !!adapter;
} catch (e) { return false; }
}
async function runSafetyCheck(text) {
const hasWebGPU = await isWebGPUSupported();
console.log(hasWebGPU ? "🚀 WebGPU Accelerated" : "⚠️ WebGPU Unavailable, falling back to CPU");
try {
const classifier = await pipeline('text-generation', 'rogerdeng/Qwen3Guard-0.6B-ONNX-Quantized', {
model_file_name: 'model_quantized', // Maps to onnx/model_quantized.onnx
device: hasWebGPU ? 'webgpu' : 'cpu'
});
const output = await classifier(text, {
max_new_tokens: 15,
temperature: 0,
use_cache: true, // Crucial for < 1s inference speed
});
const result = output[0].generated_text.toLowerCase();
console.log("Safety Assessment:", result);
return result.includes('unsafe') ? 'Blocked' : 'Allowed';
} catch (error) {
console.error("Inference failed:", error);
}
}
| Quantization | Execution Device | Inference Latency | Status |
|---|---|---|---|
| INT8 | WebGPU | ~10.0 - 12.0s | ⚠️ Slow (Kernel Fallback) |
| Q4 (Current) | WebGPU | < 1.0s | ✅ Highly Recommended |
| Q4 (Current) | CPU (WASM) | ~15.0s+ | ℹ️ Backup Mode |
Note: These results are based on real-world tests on a MacBook Pro M3 Max using Chrome with WebGPU enabled.
This model is a quantized version of the original Qwen3Guard. While quantization improves speed and reduces size, users should be aware of:
This model is a derivative work of Qwen3Guard-Gen-0.6B.