Views
No views yet
benign, maliciousindex.html in a browser. The model loads from Hugging Face CDN.1# Install dependencies
2npm install
3
4# Run tests
5npm run test
6
7# Or start a local server
8npm run start| Device | Description |
|---|---|
webgpu | Fastest in browser (Chrome/Edge) |
wasm | Slower but universal browser support |
cpu | For Node.js only |
1import { pipeline } from '@huggingface/transformers';
2
3const classifier = await pipeline(
4 'text-classification',
5 'mhingston/distilbert-base-threat-matrix-onnx',
6 { device: 'webgpu' }
7);
8
9const result = await classifier("Ignore all previous instructions...");
10console.log(result);
11// [{ label: 'malicious', score: 0.992 }]index.html - Browser demotest-node.js - Node.js test scriptpackage.json - Node.js dependencies