Download the PHP package directorytree/privacy-filter without Composer
On this page you can find all versions of the php package directorytree/privacy-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download directorytree/privacy-filter
More information about directorytree/privacy-filter
Files in directorytree/privacy-filter
Package privacy-filter
Short Description Laravel wrapper for privacy-filter.cpp binaries.
License MIT
Informations about the package privacy-filter
Introduction
Privacy Filter provides a Laravel wrapper around the privacy-filter.cpp command line binary. It installs the compiled binary for the current operating system, downloads the GGUF model used by the binary, and exposes a small PHP API for detecting private entities in text.
Installation
You may install the package via Composer:
After installing the package, run the privacy-filter:install Artisan command. This command will install both the compiled binary and the GGUF model required by the runtime API:
If either file already exists, the installer will leave it in place. You may use the --force option to overwrite the installed files:
Configuration
You may publish the package configuration file using the vendor:publish Artisan command:
The published configuration file allows you to customize the installed binary path, model path, process timeout, model URL, and binary release source:
Installing Assets
The privacy-filter:install command installs all assets required by the package:
You may install the binary and model independently if you need more control over deployment:
The binary installer downloads the correct archive for the current operating system from the configured GitHub release. You may install a different release or provide a direct archive URL:
The model installer downloads the configured GGUF model. You may also provide a direct model URL:
Usage
You may classify text using the PrivacyFilter facade. The entities method returns an array of Entity instances:
Each entity contains the detected type, original text, byte offsets, and confidence score. You may also retrieve the byte length of the entity:
You may use the detected entities to redact personal information from text:
Thresholds
The classifier uses a default threshold of 0.5. Only entities with a confidence score equal to or greater than the threshold will be returned.
You may provide a threshold at runtime when classifying text:
Queueing And Memory
Privacy Filter runs the native privacy-filter.cpp binary when classifying text. The GGUF model is loaded into memory by the native process while classification is running. Larger models require more memory.
For production workloads, you should avoid running many classifications concurrently from normal web requests. Instead, dispatch classification work to a dedicated queue and limit the number of workers assigned to that queue based on the memory available on your server.
For example, if your selected model uses approximately 3 GB of memory while classifying, running four concurrent workers may require approximately 12 GB of memory, plus memory used by PHP, Redis, your database, and the rest of your application.
A typical Horizon configuration may dedicate a small worker pool to privacy filtering:
You may then dispatch redaction or classification work to the dedicated queue:
Tune the processes value according to your server memory and model size. Each concurrent classification may load its own copy of the model into memory.
Entity Types
The raw entity type is available through the entity's type property:
For known privacy-filter entity types, you may retrieve the matching EntityType enum instance:
If the binary returns an entity type that is not known by this package, the type method will return null.
Testing
You may use the fake method to prevent the package from invoking the installed binary during tests. The fake method accepts a list of entities that should be returned for every classification:
You may also fake responses for specific text using exact strings or wildcard patterns:
All versions of privacy-filter with dependencies
ext-zip Version *
illuminate/http Version ^11.0|^12.0|^13.0
illuminate/console Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
directorytree/privacy-filter-classifier Version ^1.1