Text Classification
Transformers
Safetensors
English
deberta-v2
Generated from Trainer
subjectivity-detection
news
checkthat2025
mdeberta-v3
Instructions to use AIWizards/mdeberta-v3-base-subjectivity-sentiment-english 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-english 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-english")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("AIWizards/mdeberta-v3-base-subjectivity-sentiment-english") model = AutoModel.from_pretrained("AIWizards/mdeberta-v3-base-subjectivity-sentiment-english") - Notebooks
- Google Colab
- Kaggle
Improve model card: Add pipeline tag, update license, and enrich content
#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-english
|
| 10 |
results: []
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
- en
|
| 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-english
|
| 22 |
|
| 23 |
-
This model is a fine-tuned version of [microsoft/mdeberta-v3-base](https://huggingface.co/microsoft/mdeberta-v3-base)
|
|
|
|
| 24 |
It achieves the following results on the evaluation set:
|
| 25 |
- Loss: 0.6011
|
| 26 |
- Macro F1: 0.7727
|
|
@@ -33,15 +38,28 @@ 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 |
-
|
|
|
|
|
|
|
| 45 |
|
| 46 |
## Training procedure
|
| 47 |
|
|
@@ -73,4 +91,112 @@ 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 |
+
- en
|
| 6 |
library_name: transformers
|
| 7 |
+
license: cc-by-4.0
|
|
|
|
| 8 |
metrics:
|
| 9 |
- accuracy
|
| 10 |
- f1
|
| 11 |
+
tags:
|
| 12 |
+
- generated_from_trainer
|
| 13 |
+
- subjectivity-detection
|
| 14 |
+
- news
|
| 15 |
+
- checkthat2025
|
| 16 |
+
- mdeberta-v3
|
| 17 |
+
pipeline_tag: text-classification
|
| 18 |
model-index:
|
| 19 |
- name: mdeberta-v3-base-subjectivity-sentiment-english
|
| 20 |
results: []
|
| 21 |
+
datasets:
|
| 22 |
+
- MatteoFasulo/clef2025_checkthat_task1_subjectivity
|
|
|
|
|
|
|
|
|
|
| 23 |
---
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
# mdeberta-v3-base-subjectivity-sentiment-english
|
| 26 |
|
| 27 |
+
This model is a fine-tuned version of [microsoft/mdeberta-v3-base](https://huggingface.co/microsoft/mdeberta-v3-base) for subjectivity detection in news articles. It was developed as part of AI Wizards' participation in the CLEF 2025 CheckThat! Lab Task 1.
|
| 28 |
+
|
| 29 |
It achieves the following results on the evaluation set:
|
| 30 |
- Loss: 0.6011
|
| 31 |
- Macro F1: 0.7727
|
|
|
|
| 38 |
|
| 39 |
## Model description
|
| 40 |
|
| 41 |
+
This model is a transformer-based classifier designed to classify sentences as subjective (opinion-laden) or objective within news articles. It was presented in the paper "[AI Wizards at CheckThat! 2025: Enhancing Transformer-Based Embeddings with Sentiment for Subjectivity Detection in News Articles](https://arxiv.org/abs/2507.11764)".
|
| 42 |
+
|
| 43 |
+
A key innovation of this model is its sentiment-augmented architecture. It enhances standard transformer-based embeddings (specifically, mDeBERTaV3-base) by integrating sentiment scores, derived from an auxiliary model, with sentence representations. This approach aims to significantly improve performance compared to standard fine-tuning, particularly boosting the subjective F1 score. Additionally, the training framework employs decision threshold calibration to effectively address class imbalance, which is prevalent across languages.
|
| 44 |
|
| 45 |
## Intended uses & limitations
|
| 46 |
|
| 47 |
+
This model is intended for subjectivity detection in news articles, classifying sentences as subjective (opinion-laden) or objective. This functionality is a key component in combating misinformation, improving fact-checking pipelines, and supporting journalists in content analysis.
|
| 48 |
+
|
| 49 |
+
**Intended Uses:**
|
| 50 |
+
* Classifying English news sentences as subjective or objective.
|
| 51 |
+
* Assisting in fact-checking, media analysis, and news aggregation by distinguishing between factual and opinionated content.
|
| 52 |
+
|
| 53 |
+
**Limitations:**
|
| 54 |
+
* This specific model (`mdeberta-v3-base-subjectivity-sentiment-english`) is primarily optimized for and evaluated on **English** news articles. While the broader research explored multilingual and zero-shot settings, performance on other languages might vary.
|
| 55 |
+
* The system's initial performance for multilingual settings in the official challenge was affected by a submission mistake, which has since been corrected in internal evaluations, indicating better actual performance than initially reported in some cases.
|
| 56 |
+
* As with any trained model, potential biases present in the training data could be reflected in its predictions.
|
| 57 |
|
| 58 |
## Training and evaluation data
|
| 59 |
|
| 60 |
+
The model was trained and developed using datasets provided for the CLEF 2025 CheckThat! Lab Task 1: Subjectivity Detection in News Articles. These datasets included text in Arabic, German, English, Italian, and Bulgarian for training/development. For this specific English model, the English training and development datasets were utilized.
|
| 61 |
+
|
| 62 |
+
The training strategy involved enhancing transformer-based classifiers by integrating sentiment scores, derived from an auxiliary model, with sentence representations. This approach aimed to improve the detection of subjective sentences. To address class imbalance prevalent across languages, decision threshold calibration was employed, optimized on the development set. Final evaluation included additional unseen languages (e.g., Greek, Romanian, Polish, Ukrainian) to assess generalization capabilities for other models in the AI Wizards' participation.
|
| 63 |
|
| 64 |
## Training procedure
|
| 65 |
|
|
|
|
| 91 |
- Transformers 4.49.0
|
| 92 |
- Pytorch 2.5.1+cu121
|
| 93 |
- Datasets 3.3.1
|
| 94 |
+
- Tokenizers 0.21.0
|
| 95 |
+
|
| 96 |
+
## How to use
|
| 97 |
+
|
| 98 |
+
You can use this model directly with the `transformers` pipeline for text classification:
|
| 99 |
+
|
| 100 |
+
```python
|
| 101 |
+
import torch
|
| 102 |
+
import torch.nn as nn
|
| 103 |
+
from transformers import DebertaV2Model, DebertaV2Config, AutoTokenizer, PreTrainedModel, pipeline, AutoModelForSequenceClassification
|
| 104 |
+
from transformers.models.deberta.modeling_deberta import ContextPooler
|
| 105 |
+
|
| 106 |
+
sent_pipe = pipeline(
|
| 107 |
+
"sentiment-analysis",
|
| 108 |
+
model="cardiffnlp/twitter-xlm-roberta-base-sentiment",
|
| 109 |
+
tokenizer="cardiffnlp/twitter-xlm-roberta-base-sentiment",
|
| 110 |
+
top_k=None, # return all 3 sentiment scores
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
class CustomModel(PreTrainedModel):
|
| 114 |
+
config_class = DebertaV2Config
|
| 115 |
+
def __init__(self, config, sentiment_dim=3, num_labels=2, *args, **kwargs):
|
| 116 |
+
super().__init__(config, *args, **kwargs)
|
| 117 |
+
self.deberta = DebertaV2Model(config)
|
| 118 |
+
self.pooler = ContextPooler(config)
|
| 119 |
+
output_dim = self.pooler.output_dim
|
| 120 |
+
self.dropout = nn.Dropout(0.1)
|
| 121 |
+
self.classifier = nn.Linear(output_dim + sentiment_dim, num_labels)
|
| 122 |
+
|
| 123 |
+
def forward(self, input_ids, positive, neutral, negative, token_type_ids=None, attention_mask=None, labels=None):
|
| 124 |
+
outputs = self.deberta(input_ids=input_ids, attention_mask=attention_mask)
|
| 125 |
+
encoder_layer = outputs[0]
|
| 126 |
+
pooled_output = self.pooler(encoder_layer)
|
| 127 |
+
sentiment_features = torch.stack((positive, neutral, negative), dim=1).to(pooled_output.dtype)
|
| 128 |
+
combined_features = torch.cat((pooled_output, sentiment_features), dim=1)
|
| 129 |
+
logits = self.classifier(self.dropout(combined_features))
|
| 130 |
+
return {'logits': logits}
|
| 131 |
+
|
| 132 |
+
model_name = "MatteoFasulo/mdeberta-v3-base-subjectivity-sentiment-english"
|
| 133 |
+
tokenizer = AutoTokenizer.from_pretrained("microsoft/mdeberta-v3-base")
|
| 134 |
+
config = DebertaV2Config.from_pretrained(
|
| 135 |
+
model_name,
|
| 136 |
+
num_labels=2,
|
| 137 |
+
id2label={0: 'OBJ', 1: 'SUBJ'},
|
| 138 |
+
label2id={'OBJ': 0, 'SUBJ': 1},
|
| 139 |
+
output_attentions=False,
|
| 140 |
+
output_hidden_states=False
|
| 141 |
+
)
|
| 142 |
+
model = CustomModel(config=config, sentiment_dim=3, num_labels=2).from_pretrained(model_name)
|
| 143 |
+
|
| 144 |
+
def classify_subjectivity(text: str):
|
| 145 |
+
# get full sentiment distribution
|
| 146 |
+
dist = sent_pipe(text)[0]
|
| 147 |
+
pos = next(d["score"] for d in dist if d["label"] == "positive")
|
| 148 |
+
neu = next(d["score"] for d in dist if d["label"] == "neutral")
|
| 149 |
+
neg = next(d["score"] for d in dist if d["label"] == "negative")
|
| 150 |
+
|
| 151 |
+
# tokenize the text
|
| 152 |
+
inputs = tokenizer(text, padding=True, truncation=True, max_length=256, return_tensors='pt')
|
| 153 |
+
|
| 154 |
+
# feeding in the three sentiment scores
|
| 155 |
+
with torch.no_grad():
|
| 156 |
+
outputs = model(
|
| 157 |
+
input_ids=inputs["input_ids"],
|
| 158 |
+
attention_mask=inputs["attention_mask"],
|
| 159 |
+
positive=torch.tensor(pos).unsqueeze(0).float(),
|
| 160 |
+
neutral=torch.tensor(neu).unsqueeze(0).float(),
|
| 161 |
+
negative=torch.tensor(neg).unsqueeze(0).float()
|
| 162 |
+
)
|
| 163 |
+
|
| 164 |
+
# compute probabilities and pick the top label
|
| 165 |
+
probs = torch.softmax(outputs.get('logits')[0], dim=-1)
|
| 166 |
+
label = model.config.id2label[int(probs.argmax())]
|
| 167 |
+
score = probs.max().item()
|
| 168 |
+
|
| 169 |
+
return {"label": label, "score": score}
|
| 170 |
+
|
| 171 |
+
examples = [
|
| 172 |
+
"The company reported a 10% increase in revenue for the last quarter.",
|
| 173 |
+
"And it could even be used to gather intelligence on Russian operations.",
|
| 174 |
+
"Dramatic pictures the next day show the charred and hollowed out relic of a once impressive and key Russian vessel.",
|
| 175 |
+
"Demands upon the public credit for social service are most difficult to resist."
|
| 176 |
+
]
|
| 177 |
+
for text in examples:
|
| 178 |
+
result = classify_subjectivity(text)
|
| 179 |
+
print(f"Text: {text}")
|
| 180 |
+
print(f"→ Subjectivity: {result['label']} (score={result['score']:.2f})\n")
|
| 181 |
+
```
|
| 182 |
+
|
| 183 |
+
## Code
|
| 184 |
+
|
| 185 |
+
The official code and materials for this project are available on GitHub:
|
| 186 |
+
[https://github.com/MatteoFasulo/clef2025-checkthat](https://github.com/MatteoFasulo/clef2025-checkthat)
|
| 187 |
+
|
| 188 |
+
## Citation
|
| 189 |
+
|
| 190 |
+
If you find our work helpful or inspiring, please feel free to cite it:
|
| 191 |
+
|
| 192 |
+
```bibtex
|
| 193 |
+
@misc{fasulo2025aiwizardscheckthat2025,
|
| 194 |
+
title={AI Wizards at CheckThat! 2025: Enhancing Transformer-Based Embeddings with Sentiment for Subjectivity Detection in News Articles},
|
| 195 |
+
author={Matteo Fasulo and Luca Babboni and Luca Tedeschini},
|
| 196 |
+
year={2025},
|
| 197 |
+
eprint={2507.11764},
|
| 198 |
+
archivePrefix={arXiv},
|
| 199 |
+
primaryClass={cs.CL},
|
| 200 |
+
url={https://arxiv.org/abs/2507.11764},
|
| 201 |
+
}
|
| 202 |
+
```
|