Compact English Sentiment Toolkit

Small, CPU-friendly models and datasets for English sentiment and embeddings — nothing here needs a GPU.

On provenance The weights and data in these repos are unmodified mirrors of upstream work by their original authors, re-hosted for reproducibility and convenience. Every repo links back to its source and preserves the upstream license. The cards, benchmarks and notes are mine; the models are not.

Models

RepoTaskSizeLicense
distilbert-sst2-sentiment Binary sentiment classification 268 MB Apache-2.0
all-MiniLM-L6-v2 Sentence embeddings, 384-d 92 MB Apache-2.0
bert-tiny 4.4M-param encoder for CI & edge 17 MB MIT

Datasets

RepoTaskRowsLicense
rotten-tomatoes-sentiment Binary sentiment 10,662 research use
go-emotions-simplified Multi-label emotion, 28 classes 54,263 Apache-2.0

Quickstart

The pieces are chosen to fit together. Classify sentiment, then score it on matching data — this run reproduces 89.7% on the first 300 test rows:

from transformers import pipeline
from datasets import load_dataset

clf = pipeline("sentiment-analysis", model="priyaganesh2050/distilbert-sst2-sentiment")
test = load_dataset("priyaganesh2050/rotten-tomatoes-sentiment", split="test")

sample = test.select(range(300))
pred = [1 if r["label"] == "POSITIVE" else 0 for r in clf(sample["text"], batch_size=32)]
acc = sum(p == g for p, g in zip(pred, sample["label"])) / len(pred)
print(f"accuracy: {acc:.3f}")   # 0.897

Semantic search over the same reviews, on CPU:

from sentence_transformers import SentenceTransformer

enc = SentenceTransformer("priyaganesh2050/all-MiniLM-L6-v2")
corpus = enc.encode(test["text"][:2000], normalize_embeddings=True)
query = enc.encode("beautifully shot but boring", normalize_embeddings=True)

for i in (corpus @ query).argsort()[-5:][::-1]:
    print(round(float(corpus[i] @ query), 3), test["text"][i][:80])

Need something small enough to fine-tune inside a CI job? bert-tiny is 17 MB and trains on the Rotten Tomatoes split in under a minute on a laptop CPU.

Choosing from this set