Text Classification
Transformers
Safetensors
Italian
deberta-v2
Generated from Trainer
subjectivity-detection
sentiment-analysis
Instructions to use AIWizards/mdeberta-v3-base-subjectivity-sentiment-italian with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AIWizards/mdeberta-v3-base-subjectivity-sentiment-italian with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="AIWizards/mdeberta-v3-base-subjectivity-sentiment-italian")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("AIWizards/mdeberta-v3-base-subjectivity-sentiment-italian") model = AutoModel.from_pretrained("AIWizards/mdeberta-v3-base-subjectivity-sentiment-italian") - Notebooks
- Google Colab
- Kaggle
Improve model card: Add pipeline tag, update license, GitHub link, and usage example
#1
by nielsr HF Staff - opened
README.md
CHANGED
|
@@ -1,26 +1,31 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
library_name: transformers
|
| 3 |
-
|
| 4 |
-
- generated_from_trainer
|
| 5 |
metrics:
|
| 6 |
- accuracy
|
| 7 |
- f1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
model-index:
|
| 9 |
- name: mdeberta-v3-base-subjectivity-sentiment-italian
|
| 10 |
results: []
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
- it
|
| 14 |
-
base_model:
|
| 15 |
-
- microsoft/mdeberta-v3-base
|
| 16 |
---
|
| 17 |
|
| 18 |
-
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
| 19 |
-
should probably proofread and complete it, then remove this comment. -->
|
| 20 |
-
|
| 21 |
# mdeberta-v3-base-subjectivity-sentiment-italian
|
| 22 |
|
| 23 |
-
This model is a fine-tuned version of [microsoft/mdeberta-v3-base](https://huggingface.co/microsoft/mdeberta-v3-base) on the [CheckThat! Lab Task 1 Subjectivity Detection at CLEF 2025](arxiv.org/abs/2507.11764).
|
|
|
|
|
|
|
| 24 |
It achieves the following results on the evaluation set:
|
| 25 |
- Loss: 0.6602
|
| 26 |
- Macro F1: 0.7437
|
|
@@ -33,16 +38,101 @@ It achieves the following results on the evaluation set:
|
|
| 33 |
|
| 34 |
## Model description
|
| 35 |
|
| 36 |
-
|
| 37 |
|
| 38 |
## Intended uses & limitations
|
| 39 |
|
| 40 |
-
|
| 41 |
|
| 42 |
## Training and evaluation data
|
| 43 |
|
| 44 |
More information needed
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
## Training procedure
|
| 47 |
|
| 48 |
### Training hyperparameters
|
|
@@ -59,12 +149,12 @@ The following hyperparameters were used during training:
|
|
| 59 |
### Training results
|
| 60 |
|
| 61 |
| Training Loss | Epoch | Step | Validation Loss | Macro F1 | Macro P | Macro R | Subj F1 | Subj P | Subj R | Accuracy |
|
| 62 |
-
|:-------------:|:-----:|:----:|:---------------:|:--------:|:-------:|:-------:|:-------:|:------:|:------:|:--------:|
|
| 63 |
-
| No log | 1.0 | 101 | 0.6392 | 0.7244 | 0.7284 | 0.7208 | 0.5913 | 0.6071 | 0.5763 | 0.7886 |
|
| 64 |
-
| No log | 2.0 | 202 | 0.5375 | 0.6731 | 0.7018 | 0.7579 | 0.6064 | 0.4548 | 0.9096 | 0.6867 |
|
| 65 |
-
| No log | 3.0 | 303 | 0.5731 | 0.7453 | 0.7373 | 0.7563 | 0.6349 | 0.5970 | 0.6780 | 0.7931 |
|
| 66 |
-
| No log | 4.0 | 404 | 0.5788 | 0.7522 | 0.7405 | 0.7752 | 0.6534 | 0.5848 | 0.7401 | 0.7916 |
|
| 67 |
-
| 0.4395 | 5.0 | 505 | 0.6922 | 0.7491 | 0.7400 | 0.7628 | 0.6423 | 0.5971 | 0.6949 | 0.7946 |
|
| 68 |
| 0.4395 | 6.0 | 606 | 0.6602 | 0.7437 | 0.7322 | 0.7690 | 0.6437 | 0.5696 | 0.7401 | 0.7826 |
|
| 69 |
|
| 70 |
|
|
@@ -73,4 +163,25 @@ The following hyperparameters were used during training:
|
|
| 73 |
- Transformers 4.49.0
|
| 74 |
- Pytorch 2.5.1+cu121
|
| 75 |
- Datasets 3.3.1
|
| 76 |
-
- Tokenizers 0.21.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model:
|
| 3 |
+
- microsoft/mdeberta-v3-base
|
| 4 |
+
language:
|
| 5 |
+
- it
|
| 6 |
library_name: transformers
|
| 7 |
+
license: cc-by-4.0
|
|
|
|
| 8 |
metrics:
|
| 9 |
- accuracy
|
| 10 |
- f1
|
| 11 |
+
tags:
|
| 12 |
+
- generated_from_trainer
|
| 13 |
+
- deberta-v2
|
| 14 |
+
- subjectivity-detection
|
| 15 |
+
- sentiment-analysis
|
| 16 |
+
pipeline_tag: text-classification
|
| 17 |
model-index:
|
| 18 |
- name: mdeberta-v3-base-subjectivity-sentiment-italian
|
| 19 |
results: []
|
| 20 |
+
datasets:
|
| 21 |
+
- MatteoFasulo/clef2025_checkthat_task1_subjectivity
|
|
|
|
|
|
|
|
|
|
| 22 |
---
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
# mdeberta-v3-base-subjectivity-sentiment-italian
|
| 25 |
|
| 26 |
+
This model is a fine-tuned version of [microsoft/mdeberta-v3-base](https://huggingface.co/microsoft/mdeberta-v3-base) on the [CheckThat! Lab Task 1 Subjectivity Detection at CLEF 2025](https://arxiv.org/abs/2507.11764).
|
| 27 |
+
For the official code and materials, please refer to the [GitHub repository](https://github.com/MatteoFasulo/clef2025-checkthat).
|
| 28 |
+
|
| 29 |
It achieves the following results on the evaluation set:
|
| 30 |
- Loss: 0.6602
|
| 31 |
- Macro F1: 0.7437
|
|
|
|
| 38 |
|
| 39 |
## Model description
|
| 40 |
|
| 41 |
+
This model, `mdeberta-v3-base-subjectivity-sentiment-italian`, is part of the AI Wizards' submission to the CLEF 2025 CheckThat! Lab Task 1: Subjectivity Detection in News Articles. Its primary goal is to classify sentences as subjective or objective. A key innovation in its development involved enhancing transformer-based classifiers, specifically `mDeBERTaV3-base`, by integrating sentiment scores derived from an auxiliary model with sentence representations. This sentiment-augmented architecture, combined with decision threshold calibration to address class imbalance, consistently boosted performance, especially the subjective F1 score.
|
| 42 |
|
| 43 |
## Intended uses & limitations
|
| 44 |
|
| 45 |
+
This model is intended for identifying whether a sentence is subjective (opinion-laden) or objective in news articles, which is crucial for combating misinformation, improving fact-checking pipelines, and supporting journalists. It has been evaluated in monolingual (Italian, Arabic, German, English, Bulgarian), zero-shot (Greek, Polish, Romanian, Ukrainian), and multilingual settings. While the sentiment augmentation consistently improved performance, users should be aware that the model's effectiveness may vary across languages and specific domains not covered in the training data. The model was trained with specific hyperparameters and decision threshold calibration for class imbalance, which are critical for its reported performance.
|
| 46 |
|
| 47 |
## Training and evaluation data
|
| 48 |
|
| 49 |
More information needed
|
| 50 |
|
| 51 |
+
## How to use
|
| 52 |
+
|
| 53 |
+
You can use this model with the `transformers` library for text classification:
|
| 54 |
+
|
| 55 |
+
```python
|
| 56 |
+
import torch
|
| 57 |
+
import torch.nn as nn
|
| 58 |
+
from transformers import DebertaV2Model, DebertaV2Config, AutoTokenizer, PreTrainedModel, pipeline, AutoModelForSequenceClassification
|
| 59 |
+
from transformers.models.deberta.modeling_deberta import ContextPooler
|
| 60 |
+
|
| 61 |
+
sent_pipe = pipeline(
|
| 62 |
+
"sentiment-analysis",
|
| 63 |
+
model="cardiffnlp/twitter-xlm-roberta-base-sentiment",
|
| 64 |
+
tokenizer="cardiffnlp/twitter-xlm-roberta-base-sentiment",
|
| 65 |
+
top_k=None, # return all 3 sentiment scores
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
class CustomModel(PreTrainedModel):
|
| 69 |
+
config_class = DebertaV2Config
|
| 70 |
+
def __init__(self, config, sentiment_dim=3, num_labels=2, *args, **kwargs):
|
| 71 |
+
super().__init__(config, *args, **kwargs)
|
| 72 |
+
self.deberta = DebertaV2Model(config)
|
| 73 |
+
self.pooler = ContextPooler(config)
|
| 74 |
+
output_dim = self.pooler.output_dim
|
| 75 |
+
self.dropout = nn.Dropout(0.1)
|
| 76 |
+
self.classifier = nn.Linear(output_dim + sentiment_dim, num_labels)
|
| 77 |
+
|
| 78 |
+
def forward(self, input_ids, positive, neutral, negative, token_type_ids=None, attention_mask=None, labels=None):
|
| 79 |
+
outputs = self.deberta(input_ids=input_ids, attention_mask=attention_mask)
|
| 80 |
+
encoder_layer = outputs[0]
|
| 81 |
+
pooled_output = self.pooler(encoder_layer)
|
| 82 |
+
sentiment_features = torch.stack((positive, neutral, negative), dim=1).to(pooled_output.dtype)
|
| 83 |
+
combined_features = torch.cat((pooled_output, sentiment_features), dim=1)
|
| 84 |
+
logits = self.classifier(self.dropout(combined_features))
|
| 85 |
+
return {'logits': logits}
|
| 86 |
+
|
| 87 |
+
model_name = "MatteoFasulo/mdeberta-v3-base-subjectivity-sentiment-italian"
|
| 88 |
+
tokenizer = AutoTokenizer.from_pretrained("microsoft/mdeberta-v3-base")
|
| 89 |
+
config = DebertaV2Config.from_pretrained(
|
| 90 |
+
model_name,
|
| 91 |
+
num_labels=2,
|
| 92 |
+
id2label={0: 'OBJ', 1: 'SUBJ'},
|
| 93 |
+
label2id={'OBJ': 0, 'SUBJ': 1},
|
| 94 |
+
output_attentions=False,
|
| 95 |
+
output_hidden_states=False
|
| 96 |
+
)
|
| 97 |
+
model = CustomModel(config=config, sentiment_dim=3, num_labels=2).from_pretrained(model_name)
|
| 98 |
+
|
| 99 |
+
def classify_subjectivity(text: str):
|
| 100 |
+
# get full sentiment distribution
|
| 101 |
+
dist = sent_pipe(text)[0]
|
| 102 |
+
pos = next(d["score"] for d in dist if d["label"] == "positive")
|
| 103 |
+
neu = next(d["score"] for d in dist if d["label"] == "neutral")
|
| 104 |
+
neg = next(d["score"] for d in dist if d["label"] == "negative")
|
| 105 |
+
|
| 106 |
+
# tokenize the text
|
| 107 |
+
inputs = tokenizer(text, padding=True, truncation=True, max_length=256, return_tensors='pt')
|
| 108 |
+
|
| 109 |
+
# feeding in the three sentiment scores
|
| 110 |
+
with torch.no_grad():
|
| 111 |
+
outputs = model(
|
| 112 |
+
input_ids=inputs["input_ids"],
|
| 113 |
+
attention_mask=inputs["attention_mask"],
|
| 114 |
+
positive=torch.tensor(pos).unsqueeze(0).float(),
|
| 115 |
+
neutral=torch.tensor(neu).unsqueeze(0).float(),
|
| 116 |
+
negative=torch.tensor(neg).unsqueeze(0).float()
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
# compute probabilities and pick the top label
|
| 120 |
+
probs = torch.softmax(outputs.get('logits')[0], dim=-1)
|
| 121 |
+
label = model.config.id2label[int(probs.argmax())]
|
| 122 |
+
score = probs.max().item()
|
| 123 |
+
|
| 124 |
+
return {"label": label, "score": score}
|
| 125 |
+
|
| 126 |
+
examples = [
|
| 127 |
+
"Per quanto riguarda le motivazioni, è importante chiedersi se l’intervento è realmente mirato a risolvere un complesso, a modificare un aspetto del corpo con cui non si riesce a convivere serenamente, oppure se è frutto di una moda passeggera o dell’influenza tossica del web che spesso induce a volere cose di cui non si ha assolutamente bisogno.",
|
| 128 |
+
"Un roulette di tensioni in cui alla fine spunta un match point per Sinner.",
|
| 129 |
+
]
|
| 130 |
+
for text in examples:
|
| 131 |
+
result = classify_subjectivity(text)
|
| 132 |
+
print(f"Text: {text}")
|
| 133 |
+
print(f"→ Subjectivity: {result['label']} (score={result['score']:.2f})\n")
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
## Training procedure
|
| 137 |
|
| 138 |
### Training hyperparameters
|
|
|
|
| 149 |
### Training results
|
| 150 |
|
| 151 |
| Training Loss | Epoch | Step | Validation Loss | Macro F1 | Macro P | Macro R | Subj F1 | Subj P | Subj R | Accuracy |
|
| 152 |
+
|:-------------:|:-----:|:----:|:---------------:|:--------:|:-------:|:-------:|:-------:|:------:|:------:|:--------:|\
|
| 153 |
+
| No log | 1.0 | 101 | 0.6392 | 0.7244 | 0.7284 | 0.7208 | 0.5913 | 0.6071 | 0.5763 | 0.7886 |\
|
| 154 |
+
| No log | 2.0 | 202 | 0.5375 | 0.6731 | 0.7018 | 0.7579 | 0.6064 | 0.4548 | 0.9096 | 0.6867 |\
|
| 155 |
+
| No log | 3.0 | 303 | 0.5731 | 0.7453 | 0.7373 | 0.7563 | 0.6349 | 0.5970 | 0.6780 | 0.7931 |\
|
| 156 |
+
| No log | 4.0 | 404 | 0.5788 | 0.7522 | 0.7405 | 0.7752 | 0.6534 | 0.5848 | 0.7401 | 0.7916 |\
|
| 157 |
+
| 0.4395 | 5.0 | 505 | 0.6922 | 0.7491 | 0.7400 | 0.7628 | 0.6423 | 0.5971 | 0.6949 | 0.7946 |\
|
| 158 |
| 0.4395 | 6.0 | 606 | 0.6602 | 0.7437 | 0.7322 | 0.7690 | 0.6437 | 0.5696 | 0.7401 | 0.7826 |
|
| 159 |
|
| 160 |
|
|
|
|
| 163 |
- Transformers 4.49.0
|
| 164 |
- Pytorch 2.5.1+cu121
|
| 165 |
- Datasets 3.3.1
|
| 166 |
+
- Tokenizers 0.21.0
|
| 167 |
+
|
| 168 |
+
## Code
|
| 169 |
+
|
| 170 |
+
The official code and materials for this submission are available on GitHub:
|
| 171 |
+
[https://github.com/MatteoFasulo/clef2025-checkthat](https://github.com/MatteoFasulo/clef2025-checkthat)
|
| 172 |
+
|
| 173 |
+
## Citation
|
| 174 |
+
|
| 175 |
+
If you find our work helpful or inspiring, please feel free to cite it:
|
| 176 |
+
|
| 177 |
+
```bibtex
|
| 178 |
+
@misc{fasulo2025aiwizardscheckthat2025,
|
| 179 |
+
title={AI Wizards at CheckThat! 2025: Enhancing Transformer-Based Embeddings with Sentiment for Subjectivity Detection in News Articles},
|
| 180 |
+
author={Matteo Fasulo and Luca Babboni and Luca Tedeschini},
|
| 181 |
+
year={2025},
|
| 182 |
+
eprint={2507.11764},
|
| 183 |
+
archivePrefix={arXiv},
|
| 184 |
+
primaryClass={cs.CL},
|
| 185 |
+
url={https://arxiv.org/abs/2507.11764},
|
| 186 |
+
}
|
| 187 |
+
```
|