Fotini98 commited on
Commit
c566cf9
·
verified ·
1 Parent(s): 9e4608b

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +176 -0
README.md ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ metrics:
5
+ - f1
6
+ base_model:
7
+ - answerdotai/ModernBERT-base
8
+ pipeline_tag: text-classification
9
+ ---
10
+
11
+
12
+ # ModernBERT Food Product Category Classification Model - Baseline
13
+
14
+ ## Model Details
15
+
16
+ ### Model Description
17
+
18
+ This model is finetuned on multi-class food product-category text classification using ModernBERT.
19
+
20
+ - **Developed by:** [DataScienceWFSR](https://huggingface.co/DataScienceWFSR)
21
+ - **Model type:** Text Classification
22
+ - **Language(s) (NLP):** English
23
+ - **Finetuned from model:** [answerdotai/ModernBERT-base](https://huggingface.co/answerdotai/ModernBERT-base)
24
+
25
+ ### Model Sources
26
+
27
+ - **Repository:** [https://github.com/WFSRDataScience/SemEval2025Task9](https://github.com/WFSRDataScience/SemEval2025Task9)
28
+ - **Paper :** [https://arxiv.org/abs/2504.20703](https://arxiv.org/abs/2504.20703)
29
+
30
+
31
+ ## How to Get Started With the Model
32
+
33
+ Use the code below to get started with the model in PyTorch.
34
+
35
+ ```python
36
+ import torch
37
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
38
+ from huggingface_hub import hf_hub_download
39
+ import pandas as pd
40
+
41
+ model, category, augmentation = 'modernbert', 'product-category', 'base'
42
+
43
+ repo_id = f"DataScienceWFSR/{model}-food-{category}-{augmentation}"
44
+ lb_path = hf_hub_download(repo_id=repo_id, filename=f"labelencoder_{category}.pkl")
45
+ lb = pd.read_pickle(lb_path)
46
+ tokenizer = AutoTokenizer.from_pretrained(repo_id)
47
+ model = AutoModelForSequenceClassification.from_pretrained(repo_id)
48
+ model.eval()
49
+
50
+ sample = ('Case Number: 039-94 Date Opened: 10/20/1994 Date Closed: 03/06/1995 Recall Class: 1'
51
+ ' Press Release (Y/N): N Domestic Est. Number: 07188 M Name: PREPARED FOODS Imported '
52
+ 'Product (Y/N): N Foreign Estab. Number: N/A City: SANTA TERESA State: NM Country: USA'
53
+ ' Product: HAM, SLICED Problem: BACTERIA Description: LISTERIA '
54
+ 'Total Pounds Recalled: 3,920 Pounds Recovered: 3,920')
55
+
56
+ inputs = tokenizer(sample, return_tensors="pt")
57
+ with torch.no_grad():
58
+ outputs = model(**inputs)
59
+ predictions = outputs.logits.argmax(dim=-1)
60
+ predicted_label = lb.inverse_transform(predictions.numpy())[0]
61
+ print(f"The predicted label is: {predicted_label}")
62
+ ```
63
+
64
+
65
+ ## Training Details
66
+
67
+ ### Training Data
68
+
69
+ Training and Validation data provided by SemEval-2025 Task 9 organizers : `Food Recall Incidents` dataset (only English) [link](https://github.com/food-hazard-detection-semeval-2025/food-hazard-detection-semeval-2025.github.io/tree/main/data)
70
+
71
+ ### Training Procedure
72
+
73
+ #### Training Hyperparameters
74
+
75
+ - batch_size: `8`
76
+ - epochs: `10`
77
+ - lr_scheduler: `cosine`
78
+
79
+
80
+ ## Evaluation
81
+
82
+ <!-- This section describes the evaluation protocols and provides the results. -->
83
+
84
+ ### Testing Data & Metrics
85
+
86
+ #### Testing Data
87
+
88
+
89
+ Test data: 997 samples ([link](https://github.com/food-hazard-detection-semeval-2025/food-hazard-detection-semeval-2025.github.io/blob/main/data/incidents_test.csv))
90
+
91
+ #### Metrics
92
+
93
+ F<sub>1</sub>-macro
94
+
95
+ ### Results
96
+ F<sub>1</sub>-macro scores for each model in the official test set utilizing the `text` field per category and subtasks scores (ST1 and ST2) rounded to 3 decimals. With bold, we indicated the model's specific results.
97
+
98
+ | Model | hazard-category | product-category | hazard | product | ST1 | ST2 |
99
+ |----------------------|----------------:|-----------------:|-------:|--------:|------:|------:|
100
+ | BERT<sub>base</sub> | 0.747 | 0.757 | 0.581 | 0.170 | 0.753 | 0.382 |
101
+ | BERT<sub>CW</sub> | 0.760 | 0.761 | 0.671 | 0.280 | 0.762 | 0.491 |
102
+ | BERT<sub>SR</sub> | 0.770 | 0.754 | 0.666 | 0.275 | 0.764 | 0.478 |
103
+ | BERT<sub>RW</sub> | 0.752 | 0.757 | 0.651 | 0.275 | 0.756 | 0.467 |
104
+ | DistilBERT<sub>base</sub> | 0.761 | 0.757 | 0.593 | 0.154 | 0.760 | 0.378 |
105
+ | DistilBERT<sub>CW</sub> | 0.766 | 0.753 | 0.635 | 0.246 | 0.763 | 0.449 |
106
+ | DistilBERT<sub>SR</sub> | 0.756 | 0.759 | 0.644 | 0.240 | 0.763 | 0.448 |
107
+ | DistilBERT<sub>RW</sub> | 0.749 | 0.747 | 0.647 | 0.261 | 0.753 | 0.462 |
108
+ | RoBERTa<sub>base</sub> | 0.760 | 0.753 | 0.579 | 0.123 | 0.755 | 0.356 |
109
+ | RoBERTa<sub>CW</sub> | 0.773 | 0.739 | 0.630 | 0.000 | 0.760 | 0.315 |
110
+ | RoBERTa<sub>SR</sub> | 0.777 | 0.755 | 0.637 | 0.000 | 0.767 | 0.319 |
111
+ | RoBERTa<sub>RW</sub> | 0.757 | 0.611 | 0.615 | 0.000 | 0.686 | 0.308 |
112
+ | **ModernBERT<sub>base</sub>** | **0.781** | **0.745** | **0.667** | **0.275** | **0.769** | **0.485** |
113
+ | ModernBERT<sub>CW</sub> | 0.761 | 0.712 | 0.609 | 0.252 | 0.741 | 0.441 |
114
+ | ModernBERT<sub>SR</sub> | 0.790 | 0.728 | 0.591 | 0.253 | 0.761 | 0.434 |
115
+ | ModernBERT<sub>RW</sub> | 0.761 | 0.751 | 0.629 | 0.237 | 0.759 | 0.440 |
116
+
117
+
118
+ ## Technical Specifications
119
+
120
+ ### Compute Infrastructure
121
+
122
+ #### Hardware
123
+
124
+ NVIDIA A100 80GB and NVIDIA GeForce RTX 3070 Ti
125
+
126
+ #### Software
127
+
128
+ | Library | Version | URL |
129
+ |-------------------|--------:|---------------------------------------------------------------------|
130
+ | Transformers | 4.49.0 | https://huggingface.co/docs/transformers/index |
131
+ | PyTorch | 2.6.0 | https://pytorch.org/ |
132
+ | SpaCy | 3.8.4 | https://spacy.io/ |
133
+ | Scikit-learn | 1.6.0 | https://scikit-learn.org/stable/ |
134
+ | Pandas | 2.2.3 | https://pandas.pydata.org/ |
135
+ | Optuna | 4.2.1 | https://optuna.org/ |
136
+ | NumPy | 2.0.2 | https://numpy.org/ |
137
+ | NLP AUG | 1.1.11 | https://nlpaug.readthedocs.io/en/latest/index.html |
138
+ | BeautifulSoup4 | 4.12.3 | https://www.crummy.com/software/BeautifulSoup/bs4/doc/# |
139
+
140
+
141
+ ## Citation
142
+
143
+ **BibTeX:**
144
+
145
+ For the original paper:
146
+ ```
147
+ @inproceedings{brightcookies-semeval2025-task9,
148
+ title="BrightCookies at {S}em{E}val-2025 Task 9: Exploring Data Augmentation for Food Hazard Classification},
149
+ author="Papadopoulou, Foteini and Mutlu, Osman and Özen, Neris and van der Velden, Bas H. M. and Hendrickx, Iris and Hürriyetoğlu, Ali",
150
+ booktitle = "Proceedings of the 19th International Workshop on Semantic Evaluation (SemEval-2025)",
151
+ month = jul,
152
+ year = "2025",
153
+ address = "Vienna, Austria",
154
+ publisher = "Association for Computational Linguistics",
155
+ }
156
+ ```
157
+
158
+ For the SemEval2025 Task9:
159
+ ```
160
+ @inproceedings{semeval2025-task9,
161
+ title = "{S}em{E}val-2025 Task 9: The Food Hazard Detection Challenge",
162
+ author = "Randl, Korbinian and Pavlopoulos, John and Henriksson, Aron and Lindgren, Tony and Bakagianni, Juli",
163
+ booktitle = "Proceedings of the 19th International Workshop on Semantic Evaluation (SemEval-2025)",
164
+ month = jul,
165
+ year = "2025",
166
+ address = "Vienna, Austria",
167
+ publisher = "Association for Computational Linguistics",
168
+ }
169
+ ```
170
+
171
+ ## Model Card Authors and Contact
172
+
173
+ Authors: Foteini Papadopoulou, Osman Mutlu, Neris Özen,
174
+ Bas H.M. van der Velden, Iris Hendrickx, Ali Hürriyetoğlu
175
+
176
+ Contact: ali.hurriyetoglu@wur.nl