CoolFace
Modelpublic

CodeHima/TOSRoberta-base

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes9downloads
README.md121 linesDownload Raw Back to root
1---2license: mit3datasets:4- CodeHima/TOS_DatasetV35language:6- en7metrics:8- accuracy9- precision10base_model: FacebookAI/roberta-base11pipeline_tag: text-classification12---13# TOSRoberta-base14 15## Model Overview16 17**Model Name:** TOSRoberta-base  18**Model Type:** Sequence Classification  19**Base Model:** [RoBERTa-base](https://huggingface.co/roberta-base)  20**Language:** English  21**Task:** Classification of unfairness levels in Terms of Service (ToS) documents22 23**Model Card Version:** 1.0  24**Author:** CodeHima25 26## Model Description27 28The `TOSRoberta-base` model is a fine-tuned version of `RoBERTa-base` for classifying clauses in Terms of Service (ToS) documents into three categories:29- **Clearly Fair**30- **Potentially Unfair**31- **Clearly Unfair**32 33This model has been fine-tuned on a custom dataset labeled with the above categories to help identify unfair practices in ToS documents.34 35## Intended Use36 37### Primary Use Case38The primary use case of this model is to classify text from Terms of Service documents into different levels of fairness. It can be particularly useful for legal analysts, researchers, and consumer protection agencies to quickly identify potentially unfair clauses in ToS documents.39 40### Limitations41- **Dataset Bias:** The model has been trained on a specific dataset, which may introduce biases. It may not generalize well to all types of ToS documents.42- **Context Understanding:** The model may struggle with clauses that require deep contextual or legal understanding.43 44## Performance45 46### Training Configuration47- **Batch Size:** 32 (training), 16 (evaluation)48- **Learning Rate:** 1e-549- **Epochs:** 1050- **Optimizer:** AdamW51- **Scheduler:** Linear with warmup52- **Training Framework:** PyTorch using Hugging Face's `transformers` library53- **Mixed Precision Training:** Enabled (fp16)54- **Resource:** Trained on a single NVIDIA T4 GPU (15 GB VRAM)55 56### Training Metrics57 58| Epoch | Training Loss | Validation Loss | Accuracy | F1   | Precision | Recall |59|-------|---------------|-----------------|----------|------|-----------|--------|60| 1     | 0.668100      | 0.620207        | 0.740000 | 0.727| 0.728     | 0.740  |61| 2     | 0.439800      | 0.463925        | 0.824762 | 0.821| 0.826     | 0.825  |62| 3     | 0.373500      | 0.432604        | 0.831429 | 0.832| 0.834     | 0.831  |63| 4     | 0.342800      | 0.402661        | 0.854286 | 0.854| 0.853     | 0.854  |64| 5     | 0.283800      | 0.434868        | 0.829524 | 0.832| 0.840     | 0.830  |65| 6     | 0.218000      | 0.437268        | 0.859048 | 0.859| 0.859     | 0.859  |66| 7     | 0.266800      | 0.508120        | 0.820952 | 0.824| 0.834     | 0.821  |67| 8     | 0.139600      | 0.486364        | 0.855238 | 0.856| 0.856     | 0.855  |68| 9     | 0.085000      | 0.530111        | 0.844762 | 0.846| 0.850     | 0.845  |69| 10    | 0.103600      | 0.528026        | 0.842857 | 0.844| 0.847     | 0.843  |70 71**Final Validation Accuracy:** 85.90%  72**Final Test Accuracy:** 85.65%73 74### Evaluation Metrics75- **Accuracy:** 85.65%76- **F1 Score:** 85.60%77- **Precision:** 85.61%78- **Recall:** 85.65%79 80## Dataset81 82The model was trained on the `CodeHima/TOS_DatasetV3`, which includes labeled clauses from ToS documents. The dataset is split into training, validation, and test sets to ensure reliable performance evaluation.83 84**Dataset Labels:**85- `clearly_fair`86- `potentially_unfair`87- `clearly_unfair`88 89## How to Use90 91Here’s how you can use the model with the Hugging Face `transformers` library:92 93```python94from transformers import RobertaTokenizer, RobertaForSequenceClassification95 96# Load the model97model = RobertaForSequenceClassification.from_pretrained('CodeHima/TOSRoberta-base')98tokenizer = RobertaTokenizer.from_pretrained('CodeHima/TOSRoberta-base')99 100# Predict the unfairness level of a clause101text = "Insert clause text here."102inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=128)103outputs = model(**inputs)104predicted_class = outputs.logits.argmax(-1).item()105 106# Map the predicted class to the corresponding label107label_mapping = {0: 'clearly_fair', 1: 'potentially_unfair', 2: 'clearly_unfair'}108predicted_label = label_mapping[predicted_class]109print(f"Predicted Label: {predicted_label}")110```111 112## Ethical Considerations113 114- **Bias:** The model's predictions may reflect biases present in the training data.115- **Fair Use:** Ensure the model is used responsibly, especially in legal contexts where human oversight is critical.116 117## Conclusion118 119The `TOSRoberta-base` model is a reliable tool for identifying unfair clauses in Terms of Service documents. While it performs well, it should be used in conjunction with expert analysis, particularly in legally sensitive contexts.120 121**Model Repository:** [CodeHima/TOSRoberta-base](https://huggingface.co/CodeHima/TOSRoberta-base)