Sentiment analysis with machine learning: the options

Machine learning approaches to sentiment at a glance
ApproachTraining data neededContext and negationRunning cost
Classic classifiersA fair amountWeakestLowest
Neural networks with word embeddingsA fair amountBetterMore computing than classic models
Fine-tuned transformersLess, thanks to pre-trainingStrongHigher than classic models
LLM promptingLittleStrongOften highest per text

Sentiment analysis with machine learning means training or using a model that predicts sentiment from text, rather than relying only on hand-written rules. There are four broad families. Each has trade-offs in the data it needs, how well it understands context, how easy it is to explain and what it costs to run.

1. Classic classifiers

Text is turned into word or phrase counts, often weighted with TF-IDF so common words count less. An algorithm such as Naive Bayes, logistic regression or a support vector machine learns which features predict positive or negative. These models are fast, cheap and fairly explainable: you can see which words push a prediction. They struggle with word order, negation across a sentence and phrasing they have not seen.

2. Neural networks with word embeddings

Words are represented as embeddings, and networks such as recurrent networks (including LSTMs) or convolutional networks read sequences of words. They capture some word order and similarity between words, so "slow service" and "waited ages" end up close. They need more labelled data and computing than classic models and have largely been overtaken by transformers.

3. Fine-tuned transformers

Transformer models, the BERT family being a well-known example, are pre-trained on very large amounts of text to learn how language works, then fine-tuned on a smaller labelled sentiment data set. They read each word in the context of the whole sentence, handle negation and longer phrases better, and multilingual versions cover many languages. They need a labelled data set for fine-tuning and more computing than classic models.

Free review snapshot

Want this done for your own reviews?

No commitment. We use your details only to send your snapshot and follow up. Privacy policy

4. Large language model prompting

A large language model is given instructions and perhaps a few examples, and asked to label sentiment. No fine-tuning is required, and it can explain its label and handle nuance. Downsides: outputs can change with prompt wording or model version, cost per text can be higher, and consistency at scale needs testing. Some teams use an LLM to help label training data and then fine-tune a smaller model.

LLM pitfalls

Prompting an LLM to analyse reviews: what goes wrong.

Prompting an llm to analyse reviews what goes wrong

Trade-offs at a glance

  • Training data needed: classic and neural need a fair amount; transformers need less thanks to pre-training; LLM prompting needs little.
  • Context and negation: weakest in classic, better in neural, strong in transformers and LLMs.
  • Explainability: highest in classic; lower in neural and transformer models; LLMs can give reasons, but those reasons may not reflect how the label was actually produced.
  • Running cost: lowest for classic; higher for transformers; often highest per text for large LLMs.
  • Consistency: high for trained models; needs checking for prompted LLMs.

Labelled data is the hidden cost

Every supervised approach needs examples labelled by people, and evaluating any approach needs a labelled test set from your own data. Write clear labelling rules, such as how to label mixed reviews, and have two people label a sample to check they agree.

Overall versus aspect sentiment

All four approaches can be applied per review or per topic. For customer reviews, per-topic sentiment is usually what you need. That requires the model to find topics too, either as a separate classifier or in one combined step.

Aspect-based

Aspect-based sentiment: sentiment per theme, not per review.

Aspect based sentiment sentiment per theme not per review

How to compare approaches fairly

  1. Build a test set of a few hundred of your own texts, labelled by people.
  2. Include hard cases: mixed, sarcastic, short, other languages.
  3. Measure precision and recall per class, not just overall accuracy.
  4. Check performance per language and per topic.
  5. Repeat after model or prompt changes.
Accuracy

Sentiment analysis accuracy: what to expect.

Sentiment analysis accuracy what to expect

Which to choose

For a business using customer feedback, the method matters less than the taxonomy, per-topic sentiment, quality checks and links to the original text. If you are building yourself, a fine-tuned multilingual transformer or a carefully tested LLM pipeline are common choices today. If you are buying, ask how the vendor tests on data like yours.

Build vs buy

DIY review analysis with LLMs: what breaks.

Diy review analysis with llms what breaks

Common mistakes

  • Choosing by headline accuracy from a different data set.
  • No labelled test set from your own data.
  • Ignoring languages and code-mixing.
  • Overall sentiment only.
  • Not re-testing after changes.

Common questions

Is deep learning always better?

Usually better at context, but not always worth the cost for simple, consistent text.

How much labelled data is needed?

It depends on the method and task; transformers and LLMs need far less than training from scratch.

Can we mix approaches?

Yes, for example rules for obvious cases and a model for the rest.

Where is the plain-language overview?

See the guide to sentiment analysis in NLP.

Checklist

  • Approach shortlisted.
  • Own labelled test set.
  • Hard cases included.
  • Per-class and per-language results.
  • Per-topic sentiment.
  • Re-tested after changes.

In short

Classic classifiers are cheap and explainable, neural networks capture more context, fine-tuned transformers handle context and languages well, and LLM prompting needs little training data. Test all of them on your own labelled data.

Doing this with Falcon

Falcon applies these ideas to Google Maps reviews of your locations and Google Play reviews of your app. A multilingual model classifies each review into themes, sub-themes and specific issues from a taxonomy built from your own reviews, with sentiment for each mention and the exact quote that supports every label. Texts under three words are marked unclear and low-confidence labels are flagged for checking, so you can see where the model is unsure rather than trusting every number blindly.