This is the code for the multimodal model that tackles the problem of fake news detection. It obtained the first place in the MULTI-Fake-DetectiVE competition proposed in the workshop EVALITA 2023.
The research paper regarding this work will be available soon!
The task proposed asks to classify a piece of information composed of a text and one or more images in four classes:
First of all, the texts in the dataset were of arbitrary length. Since the NLP models like BERT present a limit to how long a text can be, a way to process longer texts was found in literature and implemented. The text was transformed in tokens, then divided in pieces that could be processed by BERT and the [CLS] tokens of the result of the single pieces were averaged to find a final representation for the text.
Several tests were conducted in order to find the best model. In the end what worked out best was to re-implement as base an existing model called FND-CLIP, enhanced with some original extensions. The base model includes 3 flows of information:
The embeddings are then processed by some FC layers, weighted by Squeeze-and-excitation layers and then summed to be finally classified by a classifier.
The extensions applied are:
The metrics used are Accuracy, Precision, Recall, F1-score, F1-weighted. The main metric used is the F1-weighted since the dataset was not balanced. The extensions were used by themselves and combined. The best performance between all the tested combinations was obtained with the combination A1, C, D.
The overall best performance was however obtained by a weighed ensemble between the combinations:
The table of these results is presented below:
| Model | F1-weighted |
|---|---|
| A2, B | 0.581 |
| A1, E, D | 0.596 |
| A1, C, D | 0.606 |
| weighted ensemble | 0.653 |
The weighted ensemble model won the first place in the competition. The table is taken from the official website and here reported:
| Rank | TEAM-RUN | Weighted Avg. F1-Score |
|---|---|---|
| 1 | Polito-P1 | 0.512 |
| 2 | extremITA-camoscio_lora | 0.507 |
| 3 | AIMH-MYPRIMARYRUN | 0.488 |
| 4 | Baseline-SVM_TEXT | 0.479 |
| 5 | Baseline-SVM_MULTI | 0.463 |
| 6 | Baseline-MLP_TEXT | 0.448 |
| 7 | Baseline-MLP_IMAGE | 0.402 |
| 8 | HIJLI-JU-CLEF-Multi | 0.393 |
| 9 | Baseline-SVM_IMAGE | 0.386 |
| 10 | Baseline-MLP_MULTI | 0.374 |
Unfortunately, due to copyright, I cannot share the dataset.
If you have your own dataset you can train the models inside the directory models. For example the model a1_c_d.py.
To train it:
python a1_c_d.py loss learning_rate save_path weight_decay tsvpath mediapath pretrained_bert_path
where:
To test the model, go in the evaluation directory and run the evaluation:
python eval_model.py tsvpath mediapath model_path model_type
where:
To test the ensemble model:
python eval_ensemble.py tsvpath mediapath path1 path2 path3
where:
9 commits
Python
100.0%
This is the code for the multimodal model that tackles the problem of fake news detection. It obtained the first place in the MULTI-Fake-DetectiVE competition proposed in the workshop EVALITA 2023.
The research paper regarding this work will be available soon!
The task proposed asks to classify a piece of information composed of a text and one or more images in four classes:
First of all, the texts in the dataset were of arbitrary length. Since the NLP models like BERT present a limit to how long a text can be, a way to process longer texts was found in literature and implemented. The text was transformed in tokens, then divided in pieces that could be processed by BERT and the [CLS] tokens of the result of the single pieces were averaged to find a final representation for the text.
Several tests were conducted in order to find the best model. In the end what worked out best was to re-implement as base an existing model called FND-CLIP, enhanced with some original extensions. The base model includes 3 flows of information:
The embeddings are then processed by some FC layers, weighted by Squeeze-and-excitation layers and then summed to be finally classified by a classifier.
The extensions applied are:
The metrics used are Accuracy, Precision, Recall, F1-score, F1-weighted. The main metric used is the F1-weighted since the dataset was not balanced. The extensions were used by themselves and combined. The best performance between all the tested combinations was obtained with the combination A1, C, D.
The overall best performance was however obtained by a weighed ensemble between the combinations:
The table of these results is presented below:
| Model | F1-weighted |
|---|---|
| A2, B | 0.581 |
| A1, E, D | 0.596 |
| A1, C, D | 0.606 |
| weighted ensemble | 0.653 |
The weighted ensemble model won the first place in the competition. The table is taken from the official website and here reported:
| Rank | TEAM-RUN | Weighted Avg. F1-Score |
|---|---|---|
| 1 | Polito-P1 | 0.512 |
| 2 | extremITA-camoscio_lora | 0.507 |
| 3 | AIMH-MYPRIMARYRUN | 0.488 |
| 4 | Baseline-SVM_TEXT | 0.479 |
| 5 | Baseline-SVM_MULTI | 0.463 |
| 6 | Baseline-MLP_TEXT | 0.448 |
| 7 | Baseline-MLP_IMAGE | 0.402 |
| 8 | HIJLI-JU-CLEF-Multi | 0.393 |
| 9 | Baseline-SVM_IMAGE | 0.386 |
| 10 | Baseline-MLP_MULTI | 0.374 |
Unfortunately, due to copyright, I cannot share the dataset.
If you have your own dataset you can train the models inside the directory models. For example the model a1_c_d.py.
To train it:
python a1_c_d.py loss learning_rate save_path weight_decay tsvpath mediapath pretrained_bert_path
where:
To test the model, go in the evaluation directory and run the evaluation:
python eval_model.py tsvpath mediapath model_path model_type
where:
To test the ensemble model:
python eval_ensemble.py tsvpath mediapath path1 path2 path3
where:
9 commits
Python
100.0%