Simple, tunable sentiment analysis from sentence embeddings — TensorFlow-free. Python sibling of the R package sentiment.ai.
Project description
sentiment.ai — Python
TensorFlow-free sentiment analysis from sentence embeddings. The Python sibling of
the R package sentiment.ai, sharing the same trained scorer
artifacts and the same public API.
Status: working pre-release (0.1.0). The engine is implemented and verified end-to-end (e5 embed → numpy scoring head → score in
[-1, 1]); the forward pass matches the R package'sscore_json_headto machine epsilon (max diff4.4e-16). The shipped e5 heads are placeholders pending full-data weights — treat scores as indicative until the v1.0 weights land.
Why a Python package: the v2 engine is already Python (sentence-transformers + a tiny
numpy scoring head). The R package reaches it through reticulate; Python calls it
directly — strictly less machinery, no bridge, no TensorFlow, and no xgboost at serve.
Models (provisional bake-off macro-F1, 2026-06-03)
model= |
macro-F1 | dim | notes |
|---|---|---|---|
e5-small (default) |
0.813 | 384 | tiny, fast, ~100 languages, no TF |
e5-base |
0.860 | 768 | best on-device — ties OpenAI, ~100 languages, no TF |
openai |
0.861 | 1536 | best overall, paid API |
en / en.large / multi / multi.large |
legacy | 512 | opt-in, requires TensorFlow |
Numbers are subsample figures and get replaced by full-data results.
Intended API (mirrors R)
import sentimentai as sa
sa.sentiment_score(["I love this", "this is terrible"]) # -> [~+1, ~-1]
sa.sentiment_match(texts, phrases={"positive": [...], "negative": [...]})
sa.embed_text(texts, model="e5-small")
R ↔ Python parity map
R (sentiment.ai) |
Python (sentimentai) |
status |
|---|---|---|
embed_text() |
embed_text() |
done (e5 / openai; legacy TF raises) |
sentiment_score() |
sentiment_score() |
done (mlp / logistic heads) |
sentiment_match() |
sentiment_match() |
done (tunable phrase poles) |
score_json_head() |
_scoring.score() |
done — verified bit-identical to R |
install_sentiment.ai() / init_sentiment.ai() |
ensure_model() |
done (no reticulate dance) |
default_models, model="en.large" |
BACKENDS, model="e5-small" |
done (registry) |
Layout
pypackage/
├── pyproject.toml
├── sentimentai/
│ ├── __init__.py public API re-exports
│ ├── _models.py backend registry (done)
│ ├── embedding.py embed_text() (e5 / openai)
│ ├── sentiment.py sentiment_score / sentiment_match
│ ├── _scoring.py numpy scoring head (verified vs R)
│ ├── install.py ensure_model()
│ └── scoring/ JSON heads shipped in the wheel
└── tests/ parity (vs R golden) + smoke/registry tests
The small JSON scoring heads ship inside the wheel (sentimentai/scoring/); only the
on-device embedder downloads from HuggingFace on first use. No .xgb, no TensorFlow.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sentimentai_py-0.1.0a1.tar.gz.
File metadata
- Download URL: sentimentai_py-0.1.0a1.tar.gz
- Upload date:
- Size: 754.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a42e3dd751895e8e257f3a531bff639c268d06ea88e9233fb9dfc3c01e18386f
|
|
| MD5 |
0569b3023b5a05ef3ac87d4e1bd62cd3
|
|
| BLAKE2b-256 |
27a3a3a45a63392d00d5893a8486e6b4fe8b5c4ed373471e872276b73dd60dac
|
File details
Details for the file sentimentai_py-0.1.0a1-py3-none-any.whl.
File metadata
- Download URL: sentimentai_py-0.1.0a1-py3-none-any.whl
- Upload date:
- Size: 758.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed4162cf088d54f20320fa50f3040538326b7367f2a2dbf3b50c95247572f3f0
|
|
| MD5 |
abbe56700571a0927d5e6c15ebbc3693
|
|
| BLAKE2b-256 |
b11270b25037028a5c0c3471ecb98ef6afb880135c2f10f28ce2407a28e7f61f
|