CoolFace
Modelpublic

CodeHima/TOSRobertaV2

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes11downloads
Model Card

TOSRobertaV2: Terms of Service Fairness Classifier

Model Description

TOSRobertaV2 is a fine-tuned RoBERTa-large model designed to classify clauses in Terms of Service (ToS) documents based on their fairness level. The model categorizes clauses into three classes: clearly fair, potentially unfair, and clearly unfair.

Intended Use

This model is intended for:

  • —Analyzing Terms of Service documents for potential unfair clauses
  • —Assisting legal professionals in reviewing contracts
  • —Helping consumers understand the fairness of agreements they're entering into
  • —Supporting researchers studying fairness in legal documents

Training Data

The model was trained on the CodeHima/TOS_DatasetV3, which contains labeled clauses from various Terms of Service documents.

Training Procedure

  • —Base model: RoBERTa-large
  • —Training type: Fine-tuning
  • —Number of epochs: 5
  • —Optimizer: AdamW
  • —Learning rate: 2e-5
  • —Batch size: 8
  • —Weight decay: 0.01
  • —Training loss: 0.3851972973652529

Evaluation Results

Validation Set Performance

  • —Accuracy: 0.86
  • —F1 Score: 0.8588
  • —Precision: 0.8598
  • —Recall: 0.8600

Test Set Performance

  • —Accuracy: 0.8651

Training Progress

EpochTraining LossValidation LossAccuracyF1PrecisionRecall
10.53910.4939730.7980950.79970.80560.79810
20.46210.4899700.8314290.83200.83300.83143
30.39540.6748490.8219050.82500.83490.82191
40.37830.7174950.8600000.85880.85980.86000
50.15420.8810500.8476190.84900.85140.84762

Limitations

  • —The model's performance may vary on ToS documents from domains or industries not well-represented in the training data.
  • —It may struggle with highly complex or ambiguous clauses.
  • —The model's understanding of "fairness" is based on the training data and may not capture all nuances of legal fairness.

Ethical Considerations

  • —This model should not be used as a substitute for professional legal advice.
  • —There may be biases present in the training data that could influence the model's judgments.
  • —Users should be aware that the concept of "fairness" in legal documents can be subjective and context-dependent.

How to Use

You can use this model directly with the Hugging Face transformers library:

python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

tokenizer = AutoTokenizer.from_pretrained("CodeHima/TOSRobertaV2")
model = AutoModelForSequenceClassification.from_pretrained("CodeHima/TOSRobertaV2")

text = "Your clause here"
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=512)

with torch.no_grad():
    logits = model(**inputs).logits

probabilities = torch.softmax(logits, dim=1)
predicted_class = torch.argmax(probabilities, dim=1).item()

classes = ['clearly fair', 'potentially unfair', 'clearly unfair']
print(f"Predicted class: {classes[predicted_class]}")
print(f"Probabilities: {probabilities[0].tolist()}")

Citation

If you use this model in your research, please cite:

@misc{TOSRobertaV2,
  author = {CodeHima},
  title = {TOSRobertaV2: Terms of Service Fairness Classifier},
  year = {2024},
  publisher = {Hugging Face},
  journal = {Hugging Face Model Hub},
  howpublished = {\url{https://huggingface.co/CodeHima/TOSRobertaV2}}
}

License

This model is released under the MIT license.