Skip to content

Piiranha Server - PII Detection and Masking Service

License

Notifications You must be signed in to change notification settings

burgonet-eu/piiserver

Repository files navigation

Piiranha Server - PII Detection and Masking Service

PII-Ranha Logo

Version française

A FastAPI-based service for detecting and masking Personally Identifiable Information (PII) in text using the PII-Ranha model.

Features

  • PII Detection: Check if text contains any PII
  • PII Masking: Mask detected PII with either aggregated or detailed redaction
  • Health Check: Verify service status
  • Token Chunking: Handles long texts by splitting into 256-token chunks

Run it

  docker run -p 8000:8000 ghcr.io/burgonet-eu/piiserver

Examples

% curl -X POST "http://localhost:8000/check-pii" -i  \
-H "Content-Type: application/json" \
-d '{"text":"Your text here, my name is Jean-Claude Dusse"}'
HTTP/1.1 400 Bad Request
date: Thu, 16 Jan 2025 11:40:49 GMT
server: uvicorn
content-length: 34
content-type: application/json

{"detail":"PII detected in input"}
% curl -X POST "http://localhost:8000/check-pii" -i \
-H "Content-Type: application/json" \
-d '{"text":"Your text here, Lorem ipsum dolor sit amet, consectetur adipiscing elit"}'
HTTP/1.1 200 OK
date: Thu, 16 Jan 2025 11:40:07 GMT
server: uvicorn
content-length: 43
content-type: application/json

{"status":"OK","message":"No PII detected"}

API Endpoints

Check PII

POST /check-pii

  • Request body: {"text": "your text here"}
  • Returns: 200 if no PII detected, 400 if PII detected

Mask PII

POST /mask-pii

  • Request body: {"text": "your text here"}
  • Optional query param: aggregate_redaction=true|false (default: true)
  • Returns: Original and masked text

Health Check

GET /health

  • Returns: Service status

Running the Service

  1. Install dependencies:
pip install fastapi uvicorn transformers torch
  1. Run the server:
python app.py
  1. The service will be available at http://localhost:8000

Testing with curl

Check for PII:

curl -X POST "http://localhost:8000/check-pii" -H "Content-Type: application/json" -d '{"text":"Your text here"}'

Mask PII:

curl -X POST "http://localhost:8000/mask-pii" -H "Content-Type: application/json" -d '{"text":"Your text here"}'

Development

The service uses the PII-Ranha model from Hugging Face.

Author & Enterprise Support

Author: Sébastien Campion

Sébastien Campion - sebastien.campion@foss4.eu

Note: This project is under active development. Please report any issues or feature requests through the issue tracker.

License

This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details.

Releases

No releases published

Packages

No packages published