CoolFace
Modelpublic

PL-RnD/privacy-moderation-small

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
1likes36downloads
README.md100 linesDownload Raw Back to root
1---2license: apache-2.03language:4- en5base_model:6- google-bert/bert-base-uncased7metrics:8- accuracy9- f110- precision11pipeline_tag: text-classification12tags:13- privacy14---15 16<a href="https://www.buymeacoffee.com/privacymoderation"><img src="https://img.buymeacoffee.com/button-api/?text=Support / Buy me a coffee&emoji=☕&slug=privacymoderation&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff" /></a>17 18# Privacy Moderation Small19 20This is a BERT Small model fine-tuned to detect privacy violations in text, such as sharing of personally identifiable information (PII) or sensitive data. It is trained on a dataset of labeled examples of privacy violations and non-violations.21 22 23## Performance24 25This small model achieves the following performance metrics on a held-out test set:26| Metric     | Value   |27|------------|---------|28| Accuracy   | `0.9554`  |29| F1 Score   | `0.9533`  |30| Precision  | `0.9678`  |31| Recall     | `0.9393`  |32 33These metrics indicate that the model is effective at identifying privacy violations while minimizing false positives.34 35## Limitations36 37- The model was trained on a dataset of nearly 1 million examples in varying topics and styles, but may not generalize to all contexts38- It limited to English text39- This current iteration used a dataset where each example is between 20 and 120 words in length, so performance on much longer texts is untested (e.g. full documents may require chunking)40- The model may not detect all types of privacy violations, especially if they are subtle or context-dependent41 42## How to Use43 44You can use this model for text classification tasks related to privacy moderation. Here's an example of how to use it with the Hugging Face Transformers library:45 46```python47from transformers import AutoModelForSequenceClassification, AutoTokenizer48import torch49import numpy as np50import pandas as pd51 52# Load the model and tokenizer53model_name = "PL-RnD/privacy-moderation-small"54tokenizer = AutoTokenizer.from_pretrained(model_name)55model = AutoModelForSequenceClassification.from_pretrained(model_name)56# Example text57texts = [58    "Here is my credit card number: 1234-5678-9012-3456",59    "This is a regular message without sensitive information.",60    "For homeowners insurance, select deductibles from $500 to $2,500. Higher deductibles lower premiums.",61    "Solidarity: My enrollment includes my kid's braces at $4,000 total—family strained. Push for orthodontic expansions. Email blast to reps starting now.",62]63# Tokenize the input64inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True)65# Get model predictions66with torch.no_grad():67    outputs = model(**inputs)68 69logits = outputs.logits70predictions = torch.argmax(logits, dim=-1)71# Convert predictions to labels72labels = ["non-violation", "violation"]73predicted_labels = [labels[pred] for pred in predictions.numpy()]74# Display results75df = pd.DataFrame({"text": texts, "label": predicted_labels})76print(df)77```78 79This will output a DataFrame with the original texts and their predicted labels (either "violation" or "non-violation"). Example output:80 81```82                                                text          label830  Here is my credit card number: 1234-5678-9012-...      violation841  This is a regular message without sensitive in...  non-violation852  For homeowners insurance, select deductibles f...  non-violation863  Solidarity: My enrollment includes my kid's br...      violation87```88 89## Intended Use90This model is intended to flag privacy concerns that a privacy conscious person would expect to keep private, such as: addresses, phone numbers, e-mails, passwords, health details, relationship drama, financial numbers, political opinions, or sexual preferences.91 92The motivating use-case for this model is to reside client-side (or in a trusted/internal environment) to review user-generated text content before it is sent to a server or third-party service, in order to prevent accidental sharing of sensitive information. For example:93- Filter and act as an A:B router for public vs private LLMS (i.e. like using this with Pipelines in Open-WebUI). If the text is flagged as a privacy violation, it can be routed to a local/private LLM instance instead of a public one.94- Block or warn users when they attempt to share sensitive information in chat applications95- Load the model in a browser using libraries like ONNX.js or TensorFlow.js to perform client-side moderation96 97---98 99> "Ultimately, arguing that you don't care about the right to privacy because you have nothing to hide is no different than saying you don't care about free speech because you have nothing to say." - Edward Snowden100