File size: 5,518 Bytes
957be10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2f2f05c
957be10
2b8afdf
 
957be10
 
 
2b8afdf
 
957be10
 
 
 
 
 
 
 
 
 
58d4c89
957be10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58d4c89
 
957be10
 
 
 
 
 
 
58d4c89
957be10
 
 
 
 
 
 
 
 
 
 
 
 
ec2cbf5
957be10
 
 
 
 
 
ec2cbf5
957be10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
---
widget:
- text: A family hiking in the mountains
  example_title: Safe
- text: A child playing with a puppy
  example_title: Safe
- text: A couple kissing passionately in bed
  example_title: Nsfw
- text: A woman naked
  example_title: Nsfw
- text: A man killing people
  example_title: Nsfw
- text: A mass shooting
  example_title: Nsfw
base_model: distilbert-base-uncased
license: apache-2.0
language:
- en
metrics:
- f1
- accuracy
- precision
- recall
pipeline_tag: text-classification
tags:
- Transformers
- ' PyTorch'
- safety
- innapropriate
- distilbert
- DiffGuard
datasets:
- eliasalbouzidi/NSFW-Safe-Dataset
model-index:
- name: NSFW-Safe-Dataset
  results:
  - task:
      name: Text Classification
      type: text-classification
    dataset:
      name: NSFW-Safe-Dataset
      type: .
    metrics:
    - name: F1
      type: f1
      value: 0.974
    - name: Accuracy
      type: accuracy
      value: 0.98
---

# Model Card

<!-- Provide a quick summary of what the model is/does. -->
old outdated simple filter im working on a new one I have no clue why 16 people downloaded this

This model is designed to categorize text into two classes: "safe", or "nsfw" (not safe for work) For my Ai Video Generator Sterling AI
If you Want to use it for other things it may be suitable for content moderation and filtering applications.

The model was trained using a dataset containing 190,000 labeled text samples, distributed among the two classes of "safe" and "nsfw".

And finetuned to block stuff I block on Sterling Ai

The model is based on the Distilbert-base model. 

In terms of performance, the model has achieved a score of 0.974 for F1 (40K exemples).

To improve the performance of the model, it is necessary to preprocess the input text. You can refer to the preprocess function in the app.py file in the following space: <https://huggingface.co/spaces/eliasalbouzidi/distilbert-nsfw-text-classifier>.
### Model Description

The model can be used directly to classify text into one of the two classes. It takes in a string of text as input and outputs a probability distribution over the two classes. The class with the highest probability is selected as the predicted class.


- **Origional Moddel Developed by:** Elias Al Bouzidi, Massine El Khader, Abdellah Oumida, Mohammed Sbaihi, Eliott Binard
- **Model type:** 60M
- **Language (NLP):** English
- **License:** apache-2.0

## Technical Paper:

A more detailed technical overview of the model and the dataset can be found [here](https://arxiv.org/pdf/2412.00064).

### Uses

The model can be integrated into larger systems for content moderation or filtering.
### Training Data
The training data for finetuning the text classification model consists of a large corpus of text labeled with one of the two classes: "safe" and "nsfw". The dataset contains a total of 190,000 examples, which are distributed as follows:

117,000 examples labeled as "safe"

63,000 examples labeled as "nsfw"

It was assembled by scraping data from the web and utilizing existing open-source datasets. A significant portion of the dataset consists of descriptions for images and scenes. The primary objective was to prevent diffusers from generating NSFW content but it can be used for other moderation purposes.

You can access the dataset : https://huggingface.co/datasets/eliasalbouzidi/NSFW-Safe-Dataset
### Training Info
I did not want to share any of the training I did to modify this its a mess I do not want to explain or put here
### Out-of-Scope Use

It should not be used for any illegal activities.

## Bias, Risks, and Limitations

The model may exhibit biases based on the training data used. It may not perform well on text that is written in languages other than English. It may also struggle with sarcasm, irony, or other forms of figurative language. The model may produce false positives or false negatives, which could lead to incorrect categorization of text.
This Moddel is relitiveley small so expect Some stuff to slip through the cracks. (not pun intended) and posably rewording may bypass it.
### Recommendations


Users should be aware of the limitations and biases of the model and use it accordingly. They should also be prepared to handle false positives and false negatives. It is recommended to fine-tune the model for specific downstream tasks and to evaluate its performance on relevant datasets.



### Load model directly
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification

tokenizer = AutoTokenizer.from_pretrained("eliasalbouzidi/distilbert-nsfw-text-classifier")

model = AutoModelForSequenceClassification.from_pretrained("Sterling-Ai/SterlingAI-Video-Prompt-Filter")

```
### Use a pipeline 
```python
from transformers import pipeline

pipe = pipeline("text-classification", model="Sterling-Ai/SterlingAI-Video-Prompt-Filter")
```

## Citation

If you find our work useful, please consider citing us!

```bibtex
@misc{khader2025diffguardtextbasedsafetychecker,
      title={DiffGuard: Text-Based Safety Checker for Diffusion Models}, 
      author={Massine El Khader and Elias Al Bouzidi and Abdellah Oumida and Mohammed Sbaihi and Eliott Binard and Jean-Philippe Poli and Wassila Ouerdane and Boussad Addad and Katarzyna Kapusta},
      year={2025},
      eprint={2412.00064},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2412.00064}, 
}
```


## Contact
Please reach out to eliasalbouzidi@gmail.com if you have any questions or feedback.