Skip to main content
Back

ELECTRA Hits 91% Accuracy Analyzing Iran-Israel War Comments Without Sharing Private Data

A team fine-tuned six transformer models on 19,000 YouTube comments about the Iran-Israel-USA war, then wrapped the winner in federated learning to keep raw user data on-device.

Pro

  • ELECTRA hit 91.32% accuracy on 19,000 YouTube comments about the Iran-Israel-USA conflict, edging out BERT, RoBERTa, XLNet, DistilBERT, and ModernBERT.
  • Federated ELECTRA reached 89.59% accuracy with two clients, dropping to 85.27% at six clients as data fragmented.
  • LDA surfaced ten discussion topics, led by War Media Narratives and Propaganda at 15.8% of comments.
  • Geopolitical and political controversy topics skewed heavily negative; leadership, religion, and peace threads skewed positive.
  • SHAP analysis confirmed the model relies on emotionally loaded words rather than spurious tokens like country names.
  • Code and dataset are on GitHub; the paper is on arXiv.

Analyzing what the internet thinks about a live geopolitical crisis usually means scraping millions of comments into a central server, which is a privacy nightmare and a legal minefield. A new arXiv paper proposes a workaround: run the sentiment classifier across distributed clients so raw comments never leave the device, and combine it with topic modeling to understand what people are actually arguing about. The authors apply the pipeline to roughly 19,000 YouTube comments collected from BBC, CNN, Fox News, WION, Sky News, Firstpost, and Al Jazeera coverage of the Iran-Israel-USA conflict.

Why centralized sentiment mining breaks down

Public opinion during international conflicts shifts hourly, and social media is the richest signal available. But the raw training data remained on the local clients and were never shared with the central server is not how most sentiment studies work. They pool everything centrally, which conflicts with privacy regulations and user expectations. The paper argues that federated learning has recently attracted significant attention in sentiment analysis as it enables decentralized model training while preserving data privacy across multiple clients, and shows it can hold up on a messy, multilingual, politically charged corpus.

The pipeline, end to end

The workflow stitches together several standard NLP components with a federated wrapper on top:

  1. Scraping and cleaning: comments collected between March 1 and 7, translated to English, emojis converted to text descriptions, stopwords removed (keeping negations), lemmatized, and deduplicated.
  2. Auto-labeling with VADER: a lexicon-based tool that outputs a compound score from -1 to +1. Scores at or above 0.05 are positive, at or below -0.05 negative, everything else neutral.
  3. Manual validation: a random sample of the dataset was chosen for cross-checking purposes. The sample contained approximately 20% of the original dataset to catch VADER's mistakes on sarcasm and political idioms.
  4. Topic extraction with LDA: Latent Dirichlet Allocation configured for 10 topics, each described by a keyword group.
  5. Transformer bake-off: BERT, RoBERTa, XLNet, DistilBERT, ModernBERT, and ELECTRA fine-tuned on the labeled comments.
  6. Federated training: the winning model is redistributed across simulated clients using FedAvg.
LDA topic distribution across ten geopolitical themes

Why ELECTRA won the bake-off

ELECTRA is trained differently from BERT. Instead of masking tokens and asking the model to fill them in, a small generator swaps in plausible-but-wrong tokens, and the main model (the discriminator) learns to spot which tokens were replaced. That signal comes from every token in the sequence rather than the ~15% that get masked, which is why the paper describes it as more sample-efficient. On this dataset, ELECTRA achieved the best overall performance, obtaining an accuracy of 91.32%, a Macro F1-score of 90.96%, and a Weighted F1-score of 91.29%. This shows that ELECTRA is slightly more effective in determining the sentiment polarity of the sentences in the dataset compared to the performance of the other models. The gap over the runners-up is narrow though. ModernBERT hit 90.84%, XLNet 90.73%, and BERT 90.68%, so architecture choice matters less than the pretraining recipe here.

How much accuracy federation costs you

The interesting result is what happens when you split the training data across clients. The findings indicate that a two client configuration was the most successful with an accuracy of 89.59% and Macro F1-score of 89.30% and a Weighted F1-score of 89.57%. Going wider hurts: four clients drop to 86.88%, and six clients slide to 85.27%. The reduction in the performance level may be due to the splitting of the dataset into multiple clients, which could affect the capacity of the model to learn all the patterns during the training phase. That's the honest tradeoff. Privacy costs roughly two accuracy points at two clients and six points at six clients on a ~19k dataset.

What the topics reveal

The LDA output is more interesting than the classifier numbers. The most prominent topic is War Media Narratives and Propaganda, which accounts for 15.8% of the comments, meaning people are talking about the coverage as much as the war itself. Sentiment splits sharply by topic. Iran-US geopolitical tensions produced 1,467 negative comments versus 772 positive. Trump and political controversies drew 1,400 negative. On the flip side, political leadership discussions skewed positive with 1,038 favorable comments, and religion/peace threads showed 605 positive versus 357 negative.

Sentiment distribution across ten topics

SHAP for sanity-checking the classifier

The authors run SHAP on the trained ELECTRA to see which tokens are driving predictions. Negative predictions lean on words like hell, disgrace, kill, disappointed, and sad. Positive predictions hinge on love, awesome, welcome, and great. Neutral predictions come from descriptive vocabulary: world, news, president, state. This is basically a sniff test to confirm the model isn't latching onto spurious tokens like country names, and it passes.

What's shipped and what's not

Code and data are available in a GitHub repository. The authors are upfront about the limitations: labels came from VADER with only partial manual review, the federated setup is simulated rather than deployed across real devices, and the corpus is YouTube-only. If you're working on privacy-conscious opinion mining, the value here is the recipe more than the numbers. Swap in your own topic model, pick a transformer that fits your latency budget, and use FedAvg with a small client count when you want to keep raw text off a central server. It's a reasonable template for any application where the data is sensitive but the sentiment signal is what you actually need.