A Framework for Fast Polarity Labelling of Massive Data Streams

Huilin Wu, Mian Lu, Zheng Zhao, Shuhao Zhang · DOI

Abstract: Many of the existing sentiment analysis techniques are based on supervised learning, and they demand the availability of valuable training datasets to train their models. When dataset freshness is critical, the annotating of high speed unlabelled data streams becomes critical but remains an open problem. In this paper, we propose PLStream, a novel Apache Flink-based framework for fast polarity labelling of massive data streams, like Twitter tweets or online product reviews. We address the associated implementation challenges and propose a list of techniques including both algorithmic improvements and system optimizations. A thorough empirical validation with two real-world workloads demonstrates that PLStream is able to generate high quality labels (almost 80% accuracy) in the presence of high-speed continuous unlabelled data streams (almost 16,000 tuples/sec) without any manual efforts.

Introduction

Sentiment analysis is a cornerstone of modern business intelligence, but it faces a significant "data hunger" problem. Most state-of-the-art models rely on supervised learning, requiring massive amounts of human-labeled data. In the fast-paced world of social media and live reviews, data moves too quickly for manual annotation, and "freshness" is critical—a model trained on outdated slang may fail to capture current trends.

Existing semi-supervised approaches often rely on "self-learning" loops that retrain models offline. However, these methods suffer from exponential growth in training time as data accumulates, making them unsuitable for infinite data streams. PLStream addresses this by enabling simultaneous learning and labelling at "stream speed" without requiring manual training phases.

The PLStream Framework

PLStream is a high-performance framework built on Apache Flink designed to label the sentiment (polarity) of massive data streams in real-time. It treats every incoming data point as both a training and testing sample through a three-stage pipeline:

  1. Preprocessing: Noise such as usernames, hashtags, and stopwords are filtered, and data is batched for efficiency.
  2. Incremental Word Embedding: Unlike batch-heavy models like BERT, PLStream utilizes an incremental version of Word2Vec. This allows the model to update its internal vocabulary and semantic understanding on the fly as new terms appear in the stream.
  3. Similarity-Based Labelling: The system calculates the Word Centroid Distance (WCD) by averaging the vectors of words in a sentence and comparing them to a reference table of known positive and negative words using cosine similarity.
Architecture of the PLStream framework

Key Innovations

  • Temporal Trend Detection (TTD): The system tracks shifts in sentiment over time. For instance, if a specific event triggers a surge in positive sentiment, the system adjusts its weights to account for this "temporal semantic aggregation."
  • Hybrid Model Management: To handle parallel processing, the authors developed a hybrid strategy where individual threads maintain local models that are periodically merged, ensuring global consistency without the massive overhead of constant database locking.

Experimental Evaluation

The framework was evaluated using two massive datasets: Sentiment140 (1.6 million tweets) and Yelp Review Polarity (560,000 reviews). While these datasets include labels, PLStream ignored them during the learning phase, using them only to verify unsupervised prediction accuracy.

Insights on Stream Processing

  • The Curse of Dimensionality: In traditional NLP, higher vector dimensions are often preferred. However, for stream labelling, high dimensionality ($d=500$) actually degraded performance. Lower dimensions ($d=20$) were more effective, preventing data sparsity and ensuring reliable similarity calculations.
  • Freshness vs. Complexity: The authors argue that a "good enough" model that updates every second is more valuable for high-speed streams than a "perfect" model requiring static batch training.
  • Contextual Minimums: Accuracy drops significantly for texts shorter than 30 words, highlighting a fundamental limit where insufficient "signal" exists for word embeddings to latch onto.

Performance Results

PLStream achieved an average accuracy of 79.2% on Yelp reviews and 68.8% on Sentiment140. On a 48-core setup, the system sustained a throughput of nearly 16,000 tuples per second for Sentiment140 and over 7,000 for Yelp (which contains longer texts).

Throughput comparison between PLStream and self-learning methods

As shown in the figure above, traditional self-learning methods experience a sharp decline in throughput as the number of processed tuples increases, whereas PLStream maintains a stable, high-performance output even as the stream continues.

Conclusion

PLStream provides a robust solution for real-time sentiment analysis of massive data streams. While it excels in speed and unsupervised accuracy, it faces challenges with very short texts and requires manual hyperparameter tuning. Future work will focus on "Auto-ML" techniques to automatically tune parameters in real-time and improve linear scalability across larger hardware clusters.

Summary updated

BibTeX
@misc{wu2022framework,
  author = {Huilin Wu and Mian Lu and Zheng Zhao and Shuhao Zhang},
  title = {{A Framework for Fast Polarity Labelling of Massive Data Streams}},
  year = {2022},
  eprint = {2203.12368},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2203.12368},
}
Figure