Building Scalable Web Apps with OpenAI's Privacy Filter
OpenAI's open-source Privacy Filter enables developers to build scalable web apps that detect personally identifiable information (PII) in text.
OpenAI has released Privacy Filter on the Hub, an open-source personally-identifiable information (PII) detector that labels text across eight categories in a single forward pass over a 128k context. The model, which has 1.5B parameters and 50M active parameters, is permissively licensed under Apache 2.0 and has achieved state-of-the-art performance on the PII-Masking-300k benchmark. Three web apps were built using Privacy Filter and gradio.Server, a platform that allows custom HTML/JS frontends to be paired with Gradio's queueing, ZeroGPU allocation, and gradio_client SDK.
The apps demonstrate the capabilities of Privacy Filter and gradio.Server in handling PII-heavy documents, images, and text. The first app, OPF-Document-PII-Explorer, allows users to upload a document and view detected PII spans highlighted by category, along with a filter in the sidebar and a summary dashboard. Privacy Filter processes the entire document in a single 128k-context forward pass, eliminating the need for chunking and stitching.
The app uses gradio.Server to serve the reader view as a single HTML file and expose the model behind a queued endpoint. The second app, OPF-SmartRedact-Paste, enables users to upload an image or screenshot and apply black bars to conceal PII. The app uses Tesseract for OCR and Privacy Filter to detect PII spans, which are then mapped to pixel rectangles.
gradio.Server is used to handle the image editing and annotation workflow. The third app, a pastebin service, allows users to paste text and receive two URLs: a public one serving the redacted version and a private one gated by a token. Privacy Filter is used to swap detected PII spans with placeholders, and gradio.Server handles the two distinct GET routes for the same paste ID.
In all three apps, gradio.Server plays a key role in handling the backend and exposing the model through queued endpoints, allowing for a consistent and scalable architecture.
Source: Hugging Face