metadata
language:
- en
license: mit
library_name: transformers
tags:
- dark-pattern
- dark-pattern-classification
- BERT
- dark-pattern-detection
metrics:
- accuracy
pipeline_tag: text-classification
Model Card for Model ID
This modelcard aims to be a base template for new models. It has been generated using this raw template.
Model Details
Model Description
- Developed by: [Adarsh Maurya]
- Model type: [Safetensors-F32]
- License: [Other]
- Finetuned from model: [google-bert/bert-base-uncased]
Model Sources [optional]
- Repository: [https://github.com/4darsh-Dev/CogniGaurd]
- Paper [optional]: [More Information Needed]
- Demo: [https://huggingface.co/spaces/4darsh-Dev/dark_pattern_detector_app]
Uses
- For Detection of Text Based Dark Patterns.
- It has been to classify dark patterns in 7 Categories( Urgency, Scarcity, Misdirection, Social-Proof, Obstruction, Sneaking, Forced Action) + Not Dark Pattern.
Direct Use
Usage
This model can be loaded and used with the Transformers library:
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model_name = "your-username/your-model-name"
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Example usage
text = "Only 2 items left in stock!"
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
predictions = outputs.logits.argmax(-1)
How to Get Started with the Model
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
class DarkPatternDetector:
def __init__(self, model_name):
self.label_dict = {
0: "Urgency", 1: "Not Dark Pattern", 2: "Scarcity", 3: "Misdirection",
4: "Social Proof", 5: "Obstruction", 6: "Sneaking", 7: "Forced Action"
}
self.device = 'cuda' if torch.cuda.is_available() else 'cpu'
print(f"Using device: {self.device}")
self.model = AutoModelForSequenceClassification.from_pretrained(model_name).to(self.device)
self.tokenizer = AutoTokenizer.from_pretrained(model_name)
def predict(self, text):
inputs = self.tokenizer(text, return_tensors="pt", truncation=True, padding=True).to(self.device)
with torch.no_grad():
outputs = self.model(**inputs)
probabilities = torch.nn.functional.softmax(outputs.logits, dim=1)
predicted_label = torch.argmax(probabilities, dim=1).item()
return self.label_dict[predicted_label]
# Usage
if __name__ == "__main__":
# Replace with your Hugging Face model name
model_name = "your-username/your-model-name"
detector = DarkPatternDetector(model_name)
# Example usage
texts_to_predict = [
"Only 2 items left in stock!",
"This offer ends in 10 minutes!",
"Join now and get 50% off!",
"By clicking 'Accept', you agree to our terms and conditions."
]
for text in texts_to_predict:
result = detector.predict(text)
print(f"Text: '{text}'\nPredicted Dark Pattern: {result}\n")
Training Details
Training Data
[More Information Needed]
Training Process
- The model was fine-tuned for 5 epochs on a dataset of 5,000 examples.
- We used the AdamW optimizer with a learning rate of 2e-5.
- The maximum sequence length was set to 256 tokens.
- Training was performed using mixed precision (FP16) for efficiency.
Training Hyperparameters
- Training regime: [More Information Needed]
Speeds, Sizes, Times [optional]
[More Information Needed]
Evaluation
Testing Data, Factors & Metrics
Testing Data
[More Information Needed]
Metrics
[More Information Needed]
Results
Metric Score
0 Accuracy 0.811881 1 Precision 0.808871 2 Recall 0.811881 3 F1-Score 0.796837
Summary
Technical Specifications [optional]
Model Architecture and Objective
[More Information Needed]
Compute Infrastructure
Hardware
- GPU: NVIDIA Tesla P100 (16GB VRAM)
- Platform: Kaggle Notebooks
Software
- Python 3.10
- PyTorch 1.13.1
- Transformers library 4.29.2
- CUDA 11.6
Citation [optional]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
Glossary [optional]
[More Information Needed]
More Information [optional]
[More Information Needed]
Model Card Authors [optional]
[More Information Needed]
Model Card Contact
[More Information Needed]