Tweet Noise Classifier
Training an ALBERT model to separate signal from noise on Twitter
Separating useful tweets from noise
On Twitter, now X, thousands of posts can stream around a trending topic. Many come from bots, marketing accounts or people using the same phrase in an unrelated conversation. I wanted to train a model that could separate the posts worth analysing from the noise around them.
I built the full workflow for my computer engineering graduation project: collect the posts, label examples, train the classifier, store the records and serve predictions through an application.
Collecting and labelling the data
The first version experimented with Selenium to collect rendered search
results. Later versions used snscrape and Tweepy as platform access changed.
The collector normalized the text and metadata before writing records to
Firestore.
I built a desktop annotation interface with Flet so I could read each tweet and mark it as signal or noise. That forced the label definition to be concrete. A signal tweet had to contribute to the topic being studied; repeating a phrase, including a hashtag or linking to unrelated marketing material was not enough.
The interface kept collection and annotation separate. I could inspect the dataset, correct labels and continue a session without rerunning the collector. Pandas handled cleaning and the transformations between stored records and the training data.
Training the classifier
I fine-tuned albert-xxlarge-v2 as a binary text classifier with PyTorch and
Hugging Face. The training flow tokenized the labelled examples, constructed
the batches, optimized the classification head and saved checkpoints so I could
compare runs and load the selected weights later.
ALBERT was a useful choice for the project because it gave me a transformer language representation while using parameter sharing to reduce the model's memory footprint. The task also gave me direct experience with the full gap between a pretrained tokenizer and a model that has learned a specific label definition from my own dataset.
Serving and batch inference
The Flask service loads the tokenizer and trained checkpoint once, switches the model to evaluation mode and disables gradients. Incoming text is tokenized, passed through the classifier and returned as the signal or noise class.
The batch path reads unclassified records from Firestore, sends them through
the model and writes the result back to the same record. A bert_tagged field
prevents already processed rows from being selected again during an ordinary
run.
This was an early project, but it covered the complete machine learning loop I wanted to learn: acquiring data, defining labels, building an annotation tool, fine-tuning a transformer, saving and loading checkpoints, and putting the model behind an API another application could call.
Built with
- ALBERT-xxlarge-v2
- text classification
- supervised fine-tuning
- human annotation
- checkpoint inference
- snscrape
- Tweepy
- Flet
