Team Ai
Modelpublic

Mitchins/deberta-v3-small-literary-explicitness

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
0likes109downloads
Model Card

Literary Content Classifier - DeBERTa v3 Small (v2.0)

An improved fine-tuned DeBERTa-v3-small model for sophisticated literary content analysis across 7 categories of explicitness. This v2.0 model features significant improvements over the original, including focal loss training, extended epochs, and data quality enhancements.

๐Ÿš€ Key Improvements in v2.0

  • โ€”+4.5% accuracy improvement (81.8% vs 77.3%)
  • โ€”+6.4% macro F1 improvement (0.754 vs 0.709)
  • โ€”+21% improvement on violent content (F1: 0.581 vs 0.478)
  • โ€”+19% improvement on suggestive content (F1: 0.476 vs 0.400)
  • โ€”Focal loss training for better minority class performance
  • โ€”Clean dataset with cross-split contamination resolved
  • โ€”Extended training (4.79 epochs vs 1.1 epochs)

Model Description

This model provides nuanced classification of textual content across 7 categories, enabling sophisticated analysis for digital humanities, content curation, and literary research applications.

Categories

IDCategoryDescriptionF1 Score
0EXPLICIT-DISCLAIMERContent warnings and age restriction notices0.977
1EXPLICIT-OFFENSIVEProfanity, crude language, offensive content0.813
2EXPLICIT-SEXUALGraphic sexual content and detailed intimate scenes0.930
3EXPLICIT-VIOLENTViolent or disturbing content0.581
4NON-EXPLICITClean, family-friendly content0.851
5SEXUAL-REFERENCEMentions of sexual topics without graphic description0.652
6SUGGESTIVEMild innuendo or romantic themes without explicit detail0.476

Performance Metrics

Overall Performance

  • โ€”Accuracy: 81.8%
  • โ€”Macro F1: 0.754
  • โ€”Weighted F1: 0.816

Detailed Results (Test Set)

                     precision    recall  f1-score   support
EXPLICIT-DISCLAIMER     0.95      1.00      0.98        19
EXPLICIT-OFFENSIVE      0.82      0.88      0.81       414
EXPLICIT-SEXUAL         0.93      0.91      0.93       514
EXPLICIT-VIOLENT        0.44      0.62      0.58        24
NON-EXPLICIT            0.77      0.87      0.85       683
SEXUAL-REFERENCE        0.63      0.73      0.65       212
SUGGESTIVE              0.37      0.46      0.48       134

            accuracy                        0.82      2000
           macro avg    0.65      0.78      0.75      2000
        weighted avg    0.75      0.82      0.82      2000

Training Details

Model Architecture

  • โ€”Base Model: microsoft/deberta-v3-small
  • โ€”Parameters: 141.9M (6 layers, 768 hidden, 12 attention heads)
  • โ€”Vocabulary: 128,100 tokens
  • โ€”Max Sequence Length: 512 tokens

Training Configuration

  • โ€”Training Method: Focal Loss (ฮณ=2.0) for class imbalance
  • โ€”Epochs: 4.79 (early stopped)
  • โ€”Learning Rate: 5e-5 with cosine schedule
  • โ€”Batch Size: 16 (effective 32 with gradient accumulation)
  • โ€”Warmup Steps: 1,000
  • โ€”Weight Decay: 0.01
  • โ€”Early Stopping: Patience 5 on macro F1

Dataset

  • โ€”Total Samples: 119,023 (after deduplication)
  • โ€”Training: 83,316 samples
  • โ€”Validation: 17,853 samples
  • โ€”Test: 17,854 samples
  • โ€”Data Quality: Cross-split contamination eliminated (2,127 duplicates removed)

Training Environment

  • โ€”Framework: PyTorch + Transformers
  • โ€”Hardware: Apple Silicon (MPS)
  • โ€”Training Time: ~13.7 hours

Usage

python
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline

# Load model and tokenizer
model_id = "your-username/deberta-v3-small-explicit-classifier-v2"
model = AutoModelForSequenceClassification.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)

# Create classification pipeline
classifier = pipeline(
    "text-classification", 
    model=model, 
    tokenizer=tokenizer,
    return_all_scores=True,
    truncation=True
)

# Single classification
text = "His hand lingered on hers as he helped her from the carriage."
result = classifier(text)
print(f"Top prediction: {result[0]['label']} ({result[0]['score']:.3f})")

# All class probabilities
for class_result in result:
    print(f"{class_result['label']}: {class_result['score']:.3f}")

Recommended Thresholds (F1-Optimized)

For applications requiring specific precision/recall trade-offs:

ClassOptimal ThresholdPrecisionRecallF1
EXPLICIT-DISCLAIMER0.9950.9501.0000.974
EXPLICIT-OFFENSIVE0.6260.8190.8290.824
EXPLICIT-SEXUAL0.4560.9270.9110.919
EXPLICIT-VIOLENT0.1050.4410.6250.517
NON-EXPLICIT0.1030.7680.8740.818
SEXUAL-REFERENCE0.3550.6290.7260.674
SUGGESTIVE0.5300.3700.4550.408

Model Files

  • โ€”model.safetensors: Model weights in SafeTensors format
  • โ€”config.json: Model configuration with proper label mappings
  • โ€”tokenizer.json, spm.model: SentencePiece tokenizer files
  • โ€”label_mapping.json: Label ID to name mapping reference

Limitations & Considerations

  1. 1.Challenging Distinctions: SUGGESTIVE vs SEXUAL-REFERENCE categories remain difficult to distinguish due to conceptual overlap
  2. 2.Minority Classes: EXPLICIT-VIOLENT and SUGGESTIVE classes have lower F1 scores due to limited training data
  3. 3.Context Dependency: Short text snippets may lack sufficient context for accurate classification
  4. 4.Domain Specificity: Optimized for literary and review content; performance may vary on other text types
  5. 5.Language: English text only

Evaluation Artifacts

The model includes comprehensive evaluation materials:

  • โ€”Confusion matrix visualization
  • โ€”Per-class precision-recall curves
  • โ€”ROC curves for all categories
  • โ€”Calibration analysis
  • โ€”Recommended decision thresholds

Ethical Use

This model is designed for:

  • โ€”Academic research and digital humanities
  • โ€”Content curation and library science applications
  • โ€”Literary analysis and publishing workflows
  • โ€”Educational content assessment

Important: This model should be used responsibly with human oversight for content moderation decisions.

Citation

bibtex
@misc{literary-explicit-classifier-v2-2025,
  title={Literary Content Analysis: Improved Multi-Class Classification with Focal Loss},
  author={Explicit Content Research Team},
  year={2025},
  note={DeBERTa-v3-small fine-tuned for literary explicitness detection}
}

License

This model is released under the Apache 2.0 license.