Restaurant Feedback Sentiment Model

Live Demo Model License: MIT

A scikit-learn text classifier for English restaurant and food-business reviews. It predicts one of three labels: negative, neutral, or positive.

This is the trained model used by the Restaurant Feedback AI app, which also detects aspects, emotions and a draft reply.

Demo of Restaurant Feedback AI analysing a review

Live demo: https://huggingface.co/spaces/Sufiyank02/restaurant-feedback-ai

Code: https://github.com/kazisufiyan-k2/restaurant-feedback-ai

How to use

The pickle is a standard scikit-learn bundle. You do not need any custom classes from the project to load it.

pip install huggingface_hub joblib==1.5.2 scikit-learn==1.8.0 numpy==2.3.5
from huggingface_hub import hf_hub_download
import joblib

bundle = joblib.load(
    hf_hub_download("Sufiyank02/restaurant-feedback-model", "feedback-model.pkl")
)
text = "The pasta was tasty but delivery was late"
label = bundle["model"].predict(bundle["vectorizer"].transform([text]))[0]
print(label)

This basic call uses the text as-is. In a test against this live repo it printed neutral. The live demo can give a different label because it also cleans the text, stacks VADER scores, and can blend in a star rating.

For that full pipeline (cleaning, aspects, emotions, and a suggested reply), open the live demo or use FeedbackAnalyzer in the GitHub repo. You do not need NLTK or vaderSentiment for the basic snippet above.

Files

File What it is
feedback-model.pkl joblib bundle with the vectorizer, base classifier, meta-classifier, labels and bias
feedback-config.json Training metadata plus the cleaning dictionaries, aspect keywords and cue patterns used at inference

The pickle is about 4.3 MB and does not need Git LFS.

How to load

Versions must match training. Do not load this pickle with a different scikit-learn, numpy or joblib version.

import json
import joblib

bundle = joblib.load("feedback-model.pkl")
with open("feedback-config.json", encoding="utf-8") as f:
    config = json.load(f)

vectorizer = bundle["vectorizer"]   # FeatureUnion of word + char TF-IDF
model = bundle["model"]             # LogisticRegression
meta = bundle["meta"]               # LogisticRegression (stacker)
use_stack = bundle["use_stack"]     # True
bias = bundle["bias"]               # (neutral, positive) log-bias
classes = bundle["classes"]         # ["negative", "neutral", "positive"]

Cleaning must stay identical to training (contractions, slang, emoji map and so on in feedback-config.json). The FastAPI app does that in app/analyzer.py. A raw model.predict(vectorizer.transform([text])) call on uncleansed text will not match the API.

The full text pipeline is:

  1. Clean the review the same way as the training notebook.
  2. Base model: TF-IDF features into logistic regression.
  3. If use_stack is true, a meta-classifier takes the base probabilities, VADER scores and log word count.
  4. A small bias term is added on the log-probabilities (neutral 0.0, positive 1.0 in this checkpoint).
  5. The API can then blend the text label with an optional 1 to 5 star rating, and attach aspects and emotions.

Labels

negative, neutral, positive

Model details

  • Architecture: FeatureUnion of two TfidfVectorizers, then LogisticRegression. A second LogisticRegression meta-model stacks those class probabilities with VADER features.
  • Word TF-IDF: word analyzer, n-grams (1, 2), min_df=3, max_features=100000, vocab size 100000.
  • Char TF-IDF: char_wb analyzer, n-grams (3, 4), min_df=5, max_features=60000, vocab size 30459.
  • Base classifier: LogisticRegression (C=1, class_weight=balanced, solver=lbfgs, max_iter=3000) on 130459 features.
  • Meta classifier: LogisticRegression (C=1.0, class_weight=balanced, solver=lbfgs, max_iter=2000) on 8 features (3 class probabilities + 4 VADER scores + log word count).
  • Trained on: 6 Oct 2026.
  • Holdout macro F1: 0.697 (compared with VADER alone at 0.513), as recorded in feedback-config.json. The training set itself is not published in this repo.

Versions (must match training)

Package Version
Python 3.13.9 (3.13.x at runtime)
scikit-learn 1.8.0
numpy 2.3.5
joblib 1.5.2
pandas (training only) 2.3.3

The API also uses VADER (vaderSentiment) and NRCLex for signals around the classifier, not for the pickle itself.

Aspects and emotions (API, not the pickle)

The service can tag these aspects from keywords in the config: taste, delivery, packaging, quantity, price, service, ambience, hygiene.

Emotion tags (joy, trust, anticipation, anger, disgust, fear, sadness, surprise) come from NRCLex, not from the sklearn model.

Limitations

  • English only. Informal restaurant English and some slang are handled. Other languages are not supported.
  • This is a small classical model, not a large language model. Short or sarcastic reviews, mixed sentiment, and rating-vs-text mismatches can be wrong. The API flags some of these for manual review.
  • Holdout macro F1 is 0.697, so errors are expected, especially on the neutral class.
  • Do not use it as the only input to refunds, moderation or other high-impact decisions.
  • The training data is not included here, so third parties cannot fully reproduce the fit, only the inference path.

License

MIT

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support