From 0c08740238fd0af8af22376c8b36fd08dbcf7669 Mon Sep 17 00:00:00 2001 From: pax-k Date: Thu, 23 Apr 2026 02:01:37 +0300 Subject: [PATCH] add browser example using Transformers.js Single-file HTML demo that loads the pre-quantized q4f16 ONNX weights from the Hugging Face Hub via @huggingface/transformers, runs token-classification on WebGPU (WASM fallback), shows download progress, and renders redacted spans inline. Pins the model revision for stable cache hits. Run with `npm start` in examples/browser. --- examples/browser/index.html | 222 ++++++++++++++++++++++++++++++++++ examples/browser/package.json | 11 ++ 2 files changed, 233 insertions(+) create mode 100644 examples/browser/index.html create mode 100644 examples/browser/package.json diff --git a/examples/browser/index.html b/examples/browser/index.html new file mode 100644 index 0000000..caa8545 --- /dev/null +++ b/examples/browser/index.html @@ -0,0 +1,222 @@ + + + + + + OPF in the browser + + + +

OpenAI Privacy Filter — browser demo

+

+ Runs openai/privacy-filter entirely in your browser via + Transformers.js, + preferring WebGPU and falling back to WASM. + The first run downloads the q4f16-quantized ONNX weights (~810 MB) + and caches them in the browser's Cache Storage; later loads are instant. +

+ + + +

+ + loading model… +

+ +
+
+
+
+ +

Redacted output

+
+ +

Detected spans

+ + + +
typetextscore
+ + + + diff --git a/examples/browser/package.json b/examples/browser/package.json new file mode 100644 index 0000000..1dc5051 --- /dev/null +++ b/examples/browser/package.json @@ -0,0 +1,11 @@ +{ + "name": "browser", + "version": "1.0.0", + "description": "", + "license": "ISC", + "author": "", + "type": "commonjs", + "scripts": { + "start": "npx --yes serve ." + } +}