Twitter Image and Text Data Analysis for Preserving Ethical Practices in Social Media
Presented by
Devtanu Misra (510519009)
Anish De (510519010)
Ahel Das Chatterjee (510519028)
Malay Gain (510519033)
Sounak Majumder (510519068)
Sayak Rana (510519108)
Under guidance of
Prof. Jaya Sil
2
Contents
Topic | Page No. |
Introduction | 3 |
Motivation/Objective | 4 |
Related Work | 5 |
Proposed Work | 6 |
Dataset Preparation | 8 |
Image Preprocessing | 12 |
Training(Transformers vs LSTM) | 20 |
Experimental Analysis | 24 |
Conclusion | 29 |
Future Work | 30 |
Reference | 31 |
3
Introduction
4
Motivation/Objective
5
Related Work
6
Proposed Work
7
Proposed Work - Flowchart
8
Twitter APIs
Get comments -
"https://api.twitter.com/2/tweets/search/recent?query=conversation_id:1295468508697026562
&tweet.fields=in_reply_to_user_id,author_id,created_at,conversation_id"
Get media files -
"https://api.twitter.com/2/tweets?ids=1579762797462032386&expansions=attachments.media_keys
&media.fields=duration_ms,height,media_key,preview_image_url,public_metrics,type,url,width,alt_text"
Get conversation id -
"https://api.twitter.com/2/tweets?ids=1225917697675886593&
tweet.fields=author_id,conversation_id,created_at,in_reply_to_user_id,referenced_tweets&
expansions=author_id,in_reply_to_user_id,referenced_tweets.id&user.fields=name,username"
9
Twitter APIs - Flowchart
10
Dataset Preparation
Here’s how we prepared our dataset:
11
Dataset Preparation
Here’s how we prepared our dataset:
12
Image Preprocessing
13
Image OCR
Tesseract-Architecture
14
Image OCR Algorithm
15
Sample Image Input:
Sample OCR Output from Model:
16
Image Captioning
Image Captioning -Architecture
17
Sample Image Input:
Sample Output from Model:
a man in a white dog is standing on the water
18
19
Sample Image Input:
Sample Output from Model:
a man in a suit with a microphone
20
Transformers
A transformer is a deep learning model that adopts the mechanism of self-attention, differentially weighting the significance of each part of the input data.
Advantages of Transformers over CNN
21
BERT Model
BERT is basically an Encoder stack of transformer architecture. A transformer architecture is an encoder-decoder network that uses self-attention on the encoder side and attention on the decoder side.
22
Roberta Model
It essentially includes fine-tuning the original BERT model along with data and inputs manipulation.
In many ways this is a better version of the BERT model. The key points of difference are as follows:
a. Dynamic Masking: BERT uses static masking i.e. the same part of the sentence is masked in each Epoch. In contrast, RoBERTa uses dynamic masking, wherein for different Epochs different part of the sentences are masked. This makes the model more robust.
b. Remove NSP Task: It was observed that the NSP task is not very useful for pre-training the BERT model. Therefore, the RoBERTa only with the MLM task.
c. More data Points: BERT is pre-trained on “Toronto BookCorpus” and “English Wikipedia datasets” i.e. as a total of 16 GB of data. In contrast, in addition to these two datasets, RoBERTa was also trained on other datasets like CC-News (Common Crawl-News), Open WebText etc. The total size of these datasets is around 160 GB.
23
Transformers vs LSTM
24
Experimental Data - Sentiment
| XLM-Roberta | Deberta | Bert Multilingual | MS Macro Electra Base | LSTM |
Accuracy | 0.7419 | 0.7215 | 0.6624 | 0.6695 | 0.5551 |
F1 | 0.7411 | 0.7215 | 0.6621 | 0.6695 | 0.5509 |
Precision | 0.7419 | 0.7215 | 0.6624 | 0.6695 | 0.5633 |
Recall | 0.7419 | 0.7215 | 0.6624 | 0.6695 | 0.5551 |
Table: Experimental Data showing Accuracy, F1, precision and recall for sentiment model
25
AOC ROC & Confusion Matrix - Sentiment
26
Experimental Data - Profane
| XLM-Roberta | Deberta | Bert Multilingual | MS Macro Electra Base | LSTM |
Accuracy | 0.8253 | 0.8322 | 0.8220 | 0.8035 | 0.7144 |
F1 | 0.8391 | 0.8455 | 0.8649 | 0.8183 | 0.7380 |
Precision | 0.8006 | 0.8015 | 0.8094 | 0.7786 | 0.7013 |
Recall | 0.8814 | 0.8946 | 0.8785 | 0.8623 | 0.7788 |
Table: Experimental Data showing Accuracy, F1, precision and recall for profane model
27
Experimental Data - Hate Speech
| XLM-Roberta | Deberta | Bert Multilingual | MS Macro Electra Base | LSTM |
Accuracy | 0.8567 | 0.8430 | 0.8529 | 0.8276 | 0.6944 |
F1 | 0.8651 | 0.8566 | 0.8649 | 0.8415 | 0.7170 |
Precision | 0.8242 | 0.7981 | 0.8094 | 0.7882 | 0.6734 |
Recall | 0.9103 | 0.9242 | 0.9285 | 0.9025 | 0.7667 |
Table: Experimental Data showing Accuracy, F1, precision and recall for hate speech model
28
Experimental Data - Targeted Insult
| XLM-Roberta | Deberta | Bert Multilingual | MS Macro Electra Base | LSTM |
Accuracy | 0.7193 | 0.7458 | 0.7360 | 0.7021 | 0.6944 |
F1 | 0.7248 | 0.7630 | 0.7594 | 0.7290 | 0.7170 |
Precision | 0.7140 | 0.7332 | 0.7151 | 0.6853 | 0.6734 |
Recall | 0.7360 | 0.7953 | 0.8094 | 0.7788 | 0.7667 |
Table: Experimental Data showing Accuracy, F1, precision and recall for targeted insult model
29
Conclusion
According to the work done till now, we found -
-> Most of the texts are non-hatred.
-> Accuracy can be improved using a larger size dataset.
-> Accuracy can also be improved using a balanced dataset.
-> Image captioning can be improved using more images and training for long hours.
-> Looking forward to incorporate all these things in the next semester.
30
Future Work
31
References
32