The problem
A restaurant with a few branches collects hundreds of reviews a year on Google, Zomato and Swiggy. The owner reads the newest few, and the star average moves too slowly to say what changed, or where.
Stars also hide the reason. A four-star review can carry the complaint that matters (great food, a forty-minute wait), and a one-star review can still praise the coffee. Reading every sentence, and knowing what each one is about, turns a pile of reviews into a short list of things to fix at each branch.
The data
159 reviews I wrote for Kaveri Kitchen, a South Indian vegetarian chain I made up, with branches in Adyar, Anna Nagar, Velachery and OMR. They run from 1 December 2025 to 22 November 2026, each with a branch, a date, a star rating (3.7 on average) and a made-up reviewer.
They are written to read like the real thing: short and long, mixed feelings in one review, Indian English, a little sarcasm and a few Tamil words such as semma and romba. The restaurant, the reviewers and the reviews are made up.
I planted patterns for the model to find: filter coffee praised everywhere, service at Velachery slowing through the summer until a new manager arrives in September, no parking at Anna Nagar, a spacious but pricey branch on OMR that opened in December 2025, and a price rise across the chain in July.
The model
DistilBERT fine-tuned on SST-2. DistilBERT is a smaller, faster version of BERT, with about 66 million parameters; this copy was trained on the Stanford Sentiment Treebank's film-review sentences to say positive or negative. The browser runs an 8-bit version of about 65 MB through transformers.js, in a background worker.
Sentences, then clauses. Each review is split into sentences, and again where the opinion turns: before "but", "although" or "except", and at a semicolon. "The food was great but the service was slow" is two opinions, and the model reads each one on its own. The 159 reviews make 358 pieces.
Aspects from a keyword list. I wrote 156 words and phrases for six aspects, from dosa and filter coffee to valet and queue. A piece can be about several aspects at once; one that names none still counts in the overall share.
Shares. A piece counts as positive when the model gives it at least 50%. An aspect's share at a branch, or in a month, is its positive pieces over all its pieces there. Where stars and words disagree comes from the same scores: four- and five-star reviews with a negative piece, and one- and two-star reviews with a positive one.
Why a general model and a keyword list, rather than training my own? Every step stays visible and checkable, and it needs no labelled data to start. With a client's labelled reviews I would fine-tune, as described below.
The pipeline
- 01Split
Each review into sentences, and sentences where the opinion turns.
- 02Tag
Each piece gets the aspects its words name, from a list of 156 terms.
- 03Load
DistilBERT downloads once, about 65 MB, when you press Read the reviews, then stays cached.
- 04Read
The 358 pieces go to the model in batches of 16, shortest first so each batch pads less.
- 05Add up
Positive shares by aspect, by branch and aspect, and by month.
- 06Compare
Pieces that disagree with their review's stars are pulled out, strongest first.
Results
Computed when this page was built from the model's score for every piece, saved by tools/review-sentiment/score.mjs on 23 November 2026; it runs the same 8-bit model file in Node, so the demo in your browser can differ by a sentence or two where a score sits near 50%. The weakest branch and aspect with at least five mentions is Anna Nagar on parking: 4% positive in 24. Of the four- and five-star reviews, 46 hold a complaint; of the one- and two-star reviews, 12 hold praise.
For a client
For a real restaurant I would pull reviews from Google Business Profile, Zomato and Swiggy every day, so the dashboard is never more than a day old.
I would label a few hundred of the client's own reviews, Tanglish included, and fine-tune the model on them, with a neutral class for plain facts. The keyword list would grow from what their guests actually write, and once there is enough data each aspect could get its own classifier.
Then the useful part: an alert when an aspect slips at a branch (waiting time at Velachery, say), a weekly summary for each branch manager, and draft replies to the worst reviews for a person to approve.
Stack
| Part | What it does here | Licence |
|---|---|---|
| DistilBERT SST-2 | Reads each piece and says positive or negative | Apache 2.0 |
| transformers.js | Runs the model in a background worker | Apache 2.0 |
| ONNX Runtime Web | The engine under transformers.js, on WebAssembly | MIT |
| My review code | Sentence and clause splitting, the aspect list, the shares and the disagreements, in TypeScript with unit tests | Mine |
| Preact | The interactive demo | MIT |
| Astro | The page, built as static HTML | MIT |
Privacy
The model downloads once from Hugging Face's public host and stays cached in your browser. After that the sample reviews, and anything you paste, are read on your device: nothing is uploaded.
Limits
- DistilBERT has no neutral label, so a plain fact still comes out positive or negative, often confidently: "Free basement parking and a lift straight up to the restaurant." reads as 74% negative.
- Sarcasm fools it: "Fantastic, forty minutes for two plain dosas." reads as 99% positive.
- It learnt from English film reviews, so Tamil words mean little to it: "Saapadu was nalla, especially the vatha kuzhambu." reads as 63% negative.
- A piece that names two aspects gives both the same score, and the keyword list misses an aspect described in words it does not know.
- The reviews are made up and few: a share built on five mentions moves a lot with one review.