File size: 8,606 Bytes
5d873a0
e4b10fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
856de3e
 
 
 
 
 
 
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
e4b10fc
856de3e
5d873a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
856de3e
e9d73b7
5d873a0
 
 
 
e9d73b7
 
 
 
5d873a0
 
 
 
 
 
 
 
 
 
 
 
 
856de3e
5d873a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
de117f7
856de3e
5d873a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
856de3e
 
 
 
5d873a0
 
 
 
 
 
 
 
 
 
 
856de3e
 
 
 
5d873a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
---
base_model:
- dbmdz/bert-base-italian-xxl-uncased
datasets:
- sapienzanlp/ami
language:
- it
library_name: transformers
license: cc-by-nc-sa-4.0
metrics:
- accuracy
- f1
- recall
- precision
pipeline_tag: text-classification
tags:
- misogyny
- italian
model-index:
- name: misogyny-detection-it
  results:
  - task:
      type: classification
    dataset:
      name: sapienzanlp/ami
      type: text-classification
    metrics:
    - type: loss
      value: 0.2205
      name: test_loss
      verified: false
    - type: accuracy
      value: 0.9412
      name: test_accuracy
      verified: false
    - type: f1
      value: 0.942
      name: test_f1
      verified: false
    - type: precision
      value: 0.9291
      name: test_precision
      verified: false
    - type: recall
      value: 0.9553
      name: test_recall
      verified: false
    - type: runtime
      value: 13.0069
      name: test_runtime
      verified: false
    - type: samples_per_second
      value: 223.573
      name: test_samples_per_second
      verified: false
    - type: steps_per_second
      value: 6.996
      name: test_steps_per_second
      verified: false
    - type: epoch
      value: 5
      name: epoch
      verified: false
---

# Model Card for Misogyny Detection in Italian

This model is a fine-tuned version of `dbmdz/bert-base-italian-xxl-uncased` for the task of misogyny detection in Italian text. It identifies whether a given text contains misogynistic content (label `1`) or not (label `0`). The model has been trained and evaluated on the **AMI (Automatic Misogyny Identification)** dataset.

## Model Details

### Model Description

<!-- Provide a longer summary of what this model is. -->

- **Developed by:** Lorenzo Maiuri
- **Funded by:** No funds
- **Shared by:** Lorenzo Maiuri
- **Model type:** Text Classification
- **Language(s):** Italian (`it`)
- **License:** CC BY-NC-SA 4.0
- **Fine-tuned from model:** [dbmdz/bert-base-italian-xxl-uncased](https://huggingface.co/dbmdz/bert-base-italian-xxl-uncased)

This model is specifically designed for detecting misogynistic content in Italian, making it useful for tasks in moderation, social media analysis, or sociolinguistic studies.

### Model Sources

<!-- Provide the basic links for the model. -->

- **Repository:** [Hugging Face Model Repository](https://huggingface.co/maiurilorenzo/misogyny-detection-it)
- **Dataset:** [AMI (Automatic Misogyny Identification)](https://huggingface.co/datasets/sapienzanlp/ami)
- **Kaggle Notebook:** [Link to Kaggle Notebook](https://www.kaggle.com/code/lorenzomaiuri/misogyny-detection-it)
- **Demo:** [Misogyny Detection IT Space](https://huggingface.co/spaces/maiurilorenzo/misogyny-detection-it-space)

## Uses

<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
### Try It Out

You can try this model interactively using the [Misogyny Detection IT Space](https://huggingface.co/spaces/maiurilorenzo/misogyny-detection-it-space).  
Simply enter a text prompt, and the model will classify it as 'Misogynistic' or 'Non-Misogynistic' along with a confidence score

### Direct Use

This model can be used as-is for binary text classification to detect misogyny in Italian. For example:

```python
from transformers import pipeline

classifier = pipeline("text-classification", model="maiurilorenzo/misogyny-detection-it")
output = classifier("Questo è un esempio di testo misogino.")
print(output)
```

### Downstream Use

<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->

The model can be fine-tuned further on related datasets for similar tasks, such as hate speech detection, sentiment analysis, or offensive language detection.

### Out-of-Scope Use

<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->

- The model is not intended for use in tasks outside of text classification.
- Avoid applying the model to non-Italian texts, as it may produce unreliable results.
- Misuse for harmful, malicious, or discriminatory purposes is strictly prohibited.

## Bias, Risks, and Limitations

<!-- This section is meant to convey both technical and sociotechnical limitations. -->

The model inherits potential biases present in the AMI dataset. It may overfit to linguistic patterns commonly associated with misogyny in the training data and fail to generalize to less explicit forms of misogyny or more nuanced cultural contexts.

### Recommendations

<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->

- Use the model in conjunction with human moderation for critical tasks.
- Regularly evaluate the model on updated or domain-specific datasets to ensure continued accuracy and fairness.

## How to Get Started with the Model

Use the code below to get started with the model:

```python
from transformers import pipeline

classifier = pipeline("text-classification", model="maiurilorenzo/misogyny-detection-it")
output = classifier("Esempio di testo italiano.")
print(output)
```

## Training Details

### Training Data

<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->

The model was fine-tuned using the AMI (Automatic Misogyny Identification) dataset, which contains labeled examples of misogynistic and non-misogynistic texts in Italian.

- Dataset license: CC BY-NC-SA 4.0
- The training set was balanced by splitting misogynistic and non-misogynistic examples into training and validation sets.

### Training Procedure

<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->

- **Kaggle Notebook:** [Link to Kaggle Notebook](https://www.kaggle.com/code/lorenzomaiuri/misogyny-detection-it)

#### Preprocessing

The text was tokenized using the BERT tokenizer, with a maximum sequence length of 128 tokens. Labels were mapped to the `labels` field as required by the Transformers library.

#### Training Hyperparameters

- Learning Rate: 2e-5
- Batch Size: 32
- Epochs: 5
- Evaluation Strategy: Per epoch
- Metric for Best Model: F1-score
- Optimizer: AdamW with weight decay 0.01

#### Speeds, Sizes, Times

<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->

Total Training Time: Approximately 15 minutes
Hardware Used: RTX 2060

## Evaluation

<!-- This section describes the evaluation protocols and provides the results. -->

### Testing Data, Factors & Metrics

#### Testing Data

<!-- This should link to a Dataset Card if possible. -->

The model was evaluated on the test split of the AMI dataset, which is balanced and contains examples of both misogynistic and non-misogynistic content.

#### Factors

<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->

The evaluation considers factors such as:

- Lexical variations
- Explicit vs. implicit misogyny
- Variations in Italian regional language

#### Metrics

<!-- These are the evaluation metrics being used, ideally with a description of why. -->

The following metrics were computed for evaluation:
- Accuracy
- F1-score
- Precision
- Recall

### Results

- Accuracy: 0.9412
- F1-score: 0.9420
- Precision: 0.9291
- Recall: 0.9553

#### Summary

The model achieves strong performance on explicit misogyny detection, with potential for improvement in detecting more subtle or implicit forms of misogyny.

## Environmental Impact

<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->

Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).

- **Hardware Type:** Tesla P100
- **Hours used:** 0.2
- **Cloud Provider:** Kaggle
- **Carbon Emitted:** 0.03

## Citation

<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->

If you use this model, please cite it as follows:
```
@misc{misogyny-detection-it,
  author = {Lorenzo Maiuri},
  title = {Misogyny Detection in Italian},
  year = {2024},
  publisher = {Hugging Face Hub},
  license = {CC BY-NC-SA 4.0}
}
```