Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 15 min read How-to mediumAdept

Getting Started with Sentiment Analysis on Twitter

Twitter sentiment analysis can be done with an off-the-shelf model instead of manual labeling, and two routes are shown: code and no-code. Developers can pull tweets with Tweepy and classify them through the Hugging Face Inference API using cardiffnlp/twitter-roberta-base-sentiment-latest, then chart the results with pandas, Matplotlib and WordCloud. A sample run on 1,000 tweets mentioning Notion came out 50% positive and 8.2% negative. Non-coders can build a Zapier workflow that triggers on Twitter mentions, calls the Inference API and writes the results to Google Sheets.

Related posts

  • Supercharged Customer Service with Machine Learning

    Hugging Face mediumAdept

    A walkthrough of building a classifier that flags very unsatisfied customer messages by framing the problem as 5-class sentiment text classification. Covers choosing a dataset on the Hugging Face Hub, settling on English Amazon Reviews Multi (1-5 star labels, 200k training examples) over GLUE, Amazon polarity, Tweet eval and Yelp, and choosing a pretrained model by checking GLUE/SuperGLUE leaderboards, landing on microsoft/deberta-v3-base. It then shows code to load and tokenize the data with Datasets and Transformers and fine-tune the model, pushing checkpoints to the Hub.

  • Data-Centric Machine Learning: Building Shopify Inbox’s Message Classification Model

    Shopify Engineering mediumAdept

    Shopify Inbox's message classifier improved from ~70% to ~90% accuracy, and from ~35% to ~80% high-confidence coverage, by investing in better training data rather than model tweaks. The v1 prototype used Universal Sentence Encoder embeddings with UMAP/HDBSCAN clustering and semi-supervised labeling on 40,000 examples. For v2, the team fine-tuned DistilBERT on 20,000 human-labeled messages. Those labels came from a 45-topic taxonomy built with support advisors and domain experts, refined through inter-annotator agreement exercises, and scrubbed of personal information with Presidio and Faker. Model predictions were then used to surface underrepresented topics for further annotation.

  • Opinion Classification with Kili and HuggingFace AutoTrain

    Hugging Face mediumAdept

    Kili's annotation platform and Hugging Face AutoTrain combine into an active-learning pipeline that classifies about 40,000 Google Play reviews of the Medium app into Subscription, Content, Interface and User Experience, then applies sentiment analysis to the classified reviews. The walkthrough covers creating a Kili labeling project through the web UI and the Python API, uploading data in batches of at most 100, and flagging changed samples between dataset versions for re-review. It then exports the labels to CSV and trains a model with AutoTrain and a second one without it.

  • SetFitABSA: Few-Shot Aspect Based Sentiment Analysis using SetFit

    Hugging Face mediumAdept

    SetFitABSA performs few-shot aspect-based sentiment analysis in three stages: spaCy extracts noun and noun-compound aspect candidates, one SetFit model classifies each candidate as aspect or non-aspect, and a second SetFit model assigns a sentiment polarity to each aspect. Both classifiers turn token-level labeling into sentence classification by prefixing the candidate to the full sentence ("aspect_candidate:sentence"), so no prompts are needed. On SemEval-2014 Laptop and Restaurant data, the two 110M-parameter MPNet models beat fine-tuned T5 and GPT2 when training data is scarce and match or beat 7B Llama-2-chat with in-context learning. A full model trains in about 10 minutes on a free Colab T4 through the setfit library's AbsaTrainer and AbsaModel APIs.

  • Sentiment Analysis on Encrypted Data with Homomorphic Encryption

    Hugging Face mediumAdept

    Sentiment classification can run on encrypted text by computing a transformer (RoBERTa) hidden representation on the client, then running a quantized XGBoost classifier under fully homomorphic encryption with Concrete-ML. On the Twitter airline sentiment dataset the transformer-embedding + XGBoost model reaches 85% accuracy (above the transformer alone at 80%), and FHE predictions match clear-text probabilities exactly. Compilation takes about 9 seconds and FHE inference about 4.4 seconds per example on a 16-core CPU. Deployment uses Concrete-ML's FHEModelDev API to export client/server artifacts, demonstrated in a Hugging Face Space with a Gradio client and a FastAPI server.

The quest for software engineering knowledge.

Look:
Layout: