MatteoFasulo nielsr HF Staff commited on
Commit
f3198da
·
verified ·
1 Parent(s): aa5eeb5

Improve model card: Add pipeline tag, update license, and enrich content (#1)

Browse files

- Improve model card: Add pipeline tag, update license, and enrich content (f5573777834ebbcc0f3bfe9a2fa9be7a13e80bce)
- Update README.md (49bd37b3867e1b1978f38f70f0a1e1940782d81f)


Co-authored-by: Niels Rogge <[email protected]>

Files changed (1) hide show
  1. README.md +144 -16
README.md CHANGED
@@ -1,26 +1,31 @@
1
  ---
 
 
 
 
2
  library_name: transformers
3
- tags:
4
- - generated_from_trainer
5
  metrics:
6
  - accuracy
7
  - f1
 
 
 
 
 
 
 
 
8
  model-index:
9
  - name: mdeberta-v3-base-subjectivity-sentiment-german
10
  results: []
11
- license: mit
12
- language:
13
- - de
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-german
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.5653
26
  - Macro F1: 0.7777
@@ -31,17 +36,120 @@ It achieves the following results on the evaluation set:
31
  - Subj R: 0.7356
32
  - Accuracy: 0.7943
33
 
 
 
 
34
  ## Model description
35
 
36
- More information needed
 
 
37
 
38
  ## Intended uses & limitations
39
 
40
- More information needed
 
 
 
 
 
 
 
 
 
 
41
 
42
  ## Training and evaluation data
43
 
44
- More information needed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  ## Training procedure
47
 
@@ -67,10 +175,30 @@ The following hyperparameters were used during training:
67
  | No log | 5.0 | 250 | 0.5520 | 0.7813 | 0.7821 | 0.7806 | 0.7168 | 0.7209 | 0.7126 | 0.8004 |
68
  | No log | 6.0 | 300 | 0.5653 | 0.7777 | 0.7751 | 0.7811 | 0.7171 | 0.6995 | 0.7356 | 0.7943 |
69
 
70
-
71
  ### Framework versions
72
 
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
+ - de
6
  library_name: transformers
7
+ license: cc-by-4.0
 
8
  metrics:
9
  - accuracy
10
  - f1
11
+ pipeline_tag: text-classification
12
+ tags:
13
+ - generated_from_trainer
14
+ - subjectivity
15
+ - sentiment
16
+ - multilingual
17
+ - zero-shot
18
+ - deberta-v3
19
  model-index:
20
  - name: mdeberta-v3-base-subjectivity-sentiment-german
21
  results: []
22
+ datasets:
23
+ - MatteoFasulo/clef2025_checkthat_task1_subjectivity
 
 
 
24
  ---
25
 
 
 
 
26
  # mdeberta-v3-base-subjectivity-sentiment-german
27
 
28
+ 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).
29
  It achieves the following results on the evaluation set:
30
  - Loss: 0.5653
31
  - Macro F1: 0.7777
 
36
  - Subj R: 0.7356
37
  - Accuracy: 0.7943
38
 
39
+ The full code and materials for this project are available on the [GitHub repository](https://github.com/MatteoFasulo/clef2025-checkthat).
40
+ You can also explore related models and interactive demos on the [AI Wizards @ CLEF 2025 - CheckThat! Lab - Task 1 Subjectivity collection on Hugging Face Hub](https://huggingface.co/collections/MatteoFasulo/clef-2025-checkthat-lab-task-1-subjectivity-6878f0199d302acdfe2ceddb).
41
+
42
  ## Model description
43
 
44
+ This model identifies whether a sentence is **subjective** (e.g., opinion-laden) or **objective**. It was developed as part of AI Wizards' participation in the CLEF 2025 CheckThat! Lab Task 1: Subjectivity Detection in News Articles.
45
+
46
+ The primary strategy employed enhances transformer-based classifiers by integrating sentiment scores, derived from an auxiliary model, with sentence representations. This approach aims to improve upon standard fine-tuning, especially boosting the subjective F1 score. This sentiment-augmented architecture was explored with `mDeBERTaV3-base` (the base for this model), ModernBERT-base (English), and Llama3.2-1B. To address class imbalance, prevalent across languages, decision threshold calibration optimized on the development set was employed.
47
 
48
  ## Intended uses & limitations
49
 
50
+ This model is intended for classifying the subjectivity of sentences in news articles. It serves as a key component in combating misinformation, improving fact-checking pipelines, and supporting journalists by helping to distinguish facts from opinions.
51
+
52
+ **Intended Uses:**
53
+ * Classifying sentences in news articles as subjective or objective.
54
+ * Supporting information veracity analysis and fact-checking processes.
55
+ * Aiding journalistic workflows in content assessment.
56
+
57
+ **Limitations:**
58
+ * While designed for multilingual and zero-shot settings, performance may vary across languages, especially those not explicitly included in the training datasets.
59
+ * The effectiveness relies on the quality of the sentiment scores derived from the auxiliary model.
60
+ * Tuned specifically for subjectivity detection in news articles; performance on other text domains or tasks may not be optimal without further fine-tuning.
61
 
62
  ## Training and evaluation data
63
 
64
+ This model was trained and evaluated as part of the CLEF 2025 CheckThat! Lab Task 1: Subjectivity Detection in News Articles.
65
+
66
+ Training and development datasets were provided for Arabic, German, English, Italian, and Bulgarian. The final evaluation included additional unseen languages such as Greek, Romanian, Polish, and Ukrainian to assess the model's generalization capabilities.
67
+
68
+ The training process incorporated decision threshold calibration to address class imbalance issues prevalent across these language datasets, optimizing performance on the development set.
69
+
70
+ ## How to use
71
+
72
+ You can use this model for text classification with the `transformers` library:
73
+
74
+ ```python
75
+ import torch
76
+ import torch.nn as nn
77
+ from transformers import DebertaV2Model, DebertaV2Config, AutoTokenizer, PreTrainedModel, pipeline, AutoModelForSequenceClassification
78
+ from transformers.models.deberta.modeling_deberta import ContextPooler
79
+
80
+ sent_pipe = pipeline(
81
+ "sentiment-analysis",
82
+ model="cardiffnlp/twitter-xlm-roberta-base-sentiment",
83
+ tokenizer="cardiffnlp/twitter-xlm-roberta-base-sentiment",
84
+ top_k=None, # return all 3 sentiment scores
85
+ )
86
+
87
+ class CustomModel(PreTrainedModel):
88
+ config_class = DebertaV2Config
89
+ def __init__(self, config, sentiment_dim=3, num_labels=2, *args, **kwargs):
90
+ super().__init__(config, *args, **kwargs)
91
+ self.deberta = DebertaV2Model(config)
92
+ self.pooler = ContextPooler(config)
93
+ output_dim = self.pooler.output_dim
94
+ self.dropout = nn.Dropout(0.1)
95
+ self.classifier = nn.Linear(output_dim + sentiment_dim, num_labels)
96
+
97
+ def forward(self, input_ids, positive, neutral, negative, token_type_ids=None, attention_mask=None, labels=None):
98
+ outputs = self.deberta(input_ids=input_ids, attention_mask=attention_mask)
99
+ encoder_layer = outputs[0]
100
+ pooled_output = self.pooler(encoder_layer)
101
+ sentiment_features = torch.stack((positive, neutral, negative), dim=1).to(pooled_output.dtype)
102
+ combined_features = torch.cat((pooled_output, sentiment_features), dim=1)
103
+ logits = self.classifier(self.dropout(combined_features))
104
+ return {'logits': logits}
105
+
106
+ model_name = "MatteoFasulo/mdeberta-v3-base-subjectivity-sentiment-german"
107
+ tokenizer = AutoTokenizer.from_pretrained("microsoft/mdeberta-v3-base")
108
+ config = DebertaV2Config.from_pretrained(
109
+ model_name,
110
+ num_labels=2,
111
+ id2label={0: 'OBJ', 1: 'SUBJ'},
112
+ label2id={'OBJ': 0, 'SUBJ': 1},
113
+ output_attentions=False,
114
+ output_hidden_states=False
115
+ )
116
+ model = CustomModel(config=config, sentiment_dim=3, num_labels=2).from_pretrained(model_name)
117
+
118
+ def classify_subjectivity(text: str):
119
+ # get full sentiment distribution
120
+ dist = sent_pipe(text)[0]
121
+ pos = next(d["score"] for d in dist if d["label"] == "positive")
122
+ neu = next(d["score"] for d in dist if d["label"] == "neutral")
123
+ neg = next(d["score"] for d in dist if d["label"] == "negative")
124
+
125
+ # tokenize the text
126
+ inputs = tokenizer(text, padding=True, truncation=True, max_length=256, return_tensors='pt')
127
+
128
+ # feeding in the three sentiment scores
129
+ with torch.no_grad():
130
+ outputs = model(
131
+ input_ids=inputs["input_ids"],
132
+ attention_mask=inputs["attention_mask"],
133
+ positive=torch.tensor(pos).unsqueeze(0).float(),
134
+ neutral=torch.tensor(neu).unsqueeze(0).float(),
135
+ negative=torch.tensor(neg).unsqueeze(0).float()
136
+ )
137
+
138
+ # compute probabilities and pick the top label
139
+ probs = torch.softmax(outputs.get('logits')[0], dim=-1)
140
+ label = model.config.id2label[int(probs.argmax())]
141
+ score = probs.max().item()
142
+
143
+ return {"label": label, "score": score}
144
+
145
+ examples = [
146
+ "Die angegebenen Fehlerquoten können daher nur für symptomatische Patienten gelten.",
147
+ ]
148
+ for text in examples:
149
+ result = classify_subjectivity(text)
150
+ print(f"Text: {text}")
151
+ print(f"→ Subjectivity: {result['label']} (score={result['score']:.2f})\n")
152
+ ```
153
 
154
  ## Training procedure
155
 
 
175
  | No log | 5.0 | 250 | 0.5520 | 0.7813 | 0.7821 | 0.7806 | 0.7168 | 0.7209 | 0.7126 | 0.8004 |
176
  | No log | 6.0 | 300 | 0.5653 | 0.7777 | 0.7751 | 0.7811 | 0.7171 | 0.6995 | 0.7356 | 0.7943 |
177
 
 
178
  ### Framework versions
179
 
180
  - Transformers 4.49.0
181
  - Pytorch 2.5.1+cu121
182
  - Datasets 3.3.1
183
+ - Tokenizers 0.21.0
184
+
185
+ ## Code
186
+
187
+ The official code and materials for this submission are available on GitHub:
188
+ [https://github.com/MatteoFasulo/clef2025-checkthat](https://github.com/MatteoFasulo/clef2025-checkthat)
189
+
190
+ ## Citation
191
+
192
+ If you find our work helpful or inspiring, please feel free to cite it:
193
+
194
+ ```bibtex
195
+ @misc{fasulo2025aiwizardscheckthat2025,
196
+ title={AI Wizards at CheckThat! 2025: Enhancing Transformer-Based Embeddings with Sentiment for Subjectivity Detection in News Articles},
197
+ author={Matteo Fasulo and Luca Babboni and Luca Tedeschini},
198
+ year={2025},
199
+ eprint={2507.11764},
200
+ archivePrefix={arXiv},
201
+ primaryClass={cs.CL},
202
+ url={https://arxiv.org/abs/2507.11764},
203
+ }
204
+ ```