CoolFace
Apppublic

hirann/gdpr-auditor

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

๐Ÿ”’ GDPR Compliance Auditor โ€” OpenEnv Environment

GDPR Auditor is an OpenEnv-compatible RL environment where AI agents act as autonomous compliance officers, auditing privacy policies for GDPR/CCPA violations, detecting dark patterns, and identifying policy contradictions.


The Problem It Solves

Every company needs compliance auditing to avoid massive fines:

  • โ€”GDPR fines up to โ‚ฌ20 million or 4% of global revenue
  • โ€”CCPA fines up to $7,500 per violation
  • โ€”Average human compliance auditor cost: $100,000+/year

The Agent's Job

  1. 1.Review privacy policy documents (single or multi-document)
  2. 2.Map data practices to stated purposes
  3. 3.Identify contradictions, missing clauses, and dark patterns
  4. 4.Report compliance violations with severity levels

Tasks & Grading

TaskDifficultyDescriptionHidden Issues
easy_clause_existenceEasyVerify mandatory GDPR clauses are present2
medium_purpose_mappingMediumMatch practices to purposes, find mismatches3
hard_dark_patternsHardFind contradictions within a single document5
elite_multi_doc_reasoningEliteCross-document contradiction detection6

Reward Function

R = base_score + severity_bonus + multi_doc_bonus + exploration_bonus
  • โ€”Base Score: issues_found / total_issues
  • โ€”Severity Bonus: +0.25 for critical findings, +0.15 for high
  • โ€”Multi-Document Bonus: +0.2 for elite task (cross-doc findings)
  • โ€”Exploration Bonus: +0.02 per step (max 0.1)

All rewards are clamped to [0.0, 1.0].


API Endpoints

EndpointMethodDescription
/healthGETHealth check โ†’ {"status": "ok"}
/reset?task=easyGETReset environment for a task
/stepPOSTSubmit a finding โ†’ {"message": "..."}
/stateGETGet current episode state

Example Usage

bash
# Reset environment
curl "http://localhost:7860/reset?task=easy"

# Submit a compliance finding
curl -X POST "http://localhost:7860/step" \
  -H "Content-Type: application/json" \
  -d '{"message": "Missing Right to be Forgotten clause"}'

# Get current state
curl "http://localhost:7860/state"

Action / Observation Spaces

Observation (returned by reset/step)

json
{
  "task_id": "easy_clause_existence",
  "task_name": "Clause Existence Check",
  "difficulty": "easy",
  "step": 0,
  "documents": [{"id": "...", "title": "...", "content": "...", "doc_type": "policy"}],
  "data_practices": [{"id": "...", "category": "...", "purpose": "...", "data_type": "...", "shared_with_third_parties": false}],
  "compliance_requirements": ["Right to be Forgotten", "Data Portability", "Contact Information"],
  "flagged_issues": [],
  "echoed_message": "Review the privacy policy..."
}

Action (sent to /step)

json
{"message": "Missing Right to be Forgotten clause"}

Reward (returned from /step)

json
{
  "value": 0.52,
  "reason": "Found 1/2 issues",
  "issues_found": 1,
  "total_issues": 2
}

Setup & Local Development

Prerequisites

  • โ€”Python 3.10+
  • โ€”uv or pip

Install & Run

bash
# Install dependencies
pip install -e .

# Start the server
python main.py
# โ†’ Server at http://localhost:7860

Run Inference

bash
export API_BASE_URL="https://router.huggingface.co/v1"
export MODEL_NAME="Qwen/Qwen2.5-72B-Instruct"
export HF_TOKEN="your-token-here"
export SERVER_URL="http://localhost:7860"

python inference.py

Docker

bash
docker build -t gdpr-auditor .
docker run -p 7860:7860 gdpr-auditor

Project Structure

โ”œโ”€โ”€ models.py          # Pydantic typed models (Observation, Action, Reward)
โ”œโ”€โ”€ env/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ core.py        # GDPRAuditorEnvironment with 4 tasks + graders
โ”œโ”€โ”€ main.py            # FastAPI server with all endpoints
โ”œโ”€โ”€ inference.py       # Baseline inference script (OpenAI client)
โ”œโ”€โ”€ openenv.yaml       # OpenEnv manifest with task definitions
โ”œโ”€โ”€ pyproject.toml     # Dependencies
โ”œโ”€โ”€ Dockerfile         # Container configuration
โ””โ”€โ”€ README.md          # This file

Environment Variables

Copy .env.example to .env and add your Hugging Face token:

bash
cp .env.example .env
# Then edit .env with your HF_TOKEN
VariableDescriptionDefault
API_BASE_URLLLM API endpointhttps://router.huggingface.co/v1
MODEL_NAMEModel identifierQwen/Qwen2.5-72B-Instruct
HF_TOKENHugging Face / API key(required)
SERVER_URLEnvironment server URLhttp://localhost:7860

License

MIT