esp32-ai
A 28.9 million parameter language model runs on an $8 ESP32-S3 microcontroller entirely on-device, generating simple stories at about 9.5 tokens per second.
It demonstrates a clean, reproducible pipeline with class imbalance handled through weighted loss and macro-F1 selection, and an honest baseline that confirms transformer gains on minority classes.
Fine-tuning a transformer to classify the sentiment of financial-news tweets as Bearish, Bullish, or Neutral, and benchmarking it against a classical TF-IDF + Logistic Regression baseline. Fine-tuning runs on Apple-Silicon GPU (MPS).
Given a short financial statement (e.g. "$AAPL smashes revenue estimates, guidance raised"), predict market sentiment. This is a 3-class, imbalanced text classification task (65% of tweets are Neutral), so the project reports macro-F1 alongside accuracy so the minority classes actually count.
| Model | Accuracy | Macro-F1 |
|---|---|---|
| TF-IDF + Logistic Regression (baseline) | 0.812 | 0.755 |
| Fine-tuned DistilBERT | 0.851 | 0.818 |
Fine-tuning lifts macro-F1 by +6.3 points — the gain concentrates on the minority Bearish/Bullish classes, where the transformer's contextual understanding beats bag-of-words. Per-class DistilBERT F1: Bearish 0.76, Bullish 0.81, Neutral 0.89.
Live inference examples (src/predict.py):
"Tesla shares tumble after disappointing quarterly earnings" -> Bearish (98%)
"$AAPL smashes revenue estimates, guidance raised next quarter" -> Bullish (98%)
"The Federal Reserve will announce its rate decision Wednesday" -> Neutral (98%)
src/data.py) — 9,543 train / 2,388 validation tweets; light
cleaning that keeps $TICKERS and % since they carry sentiment signal.src/baseline.py) — TF-IDF (1–2 grams) + Logistic Regression with
balanced class weights. A strong baseline so the transformer has something real
to beat.src/train.py) — DistilBERT with a class-weighted
cross-entropy loss to handle imbalance; best checkpoint selected by macro-F1;
3 epochs, lr 2e-5, on MPS.src/evaluate.py) — classification report, confusion matrix, and
a baseline-vs-transformer comparison chart.src/predict.py) — sentiment + class probabilities for any text.reports/figures/)01_class_distribution.png | class imbalance in the training set |
02_tweet_length.png | tweet-length distribution |
03_confusion_matrix.png | DistilBERT errors by class |
04_model_comparison.png | baseline vs. fine-tuned m |
Similar projects matched by category, topics, and programming language.
A 28.9 million parameter language model runs on an $8 ESP32-S3 microcontroller entirely on-device, generating simple stories at about 9.5 tokens per second.
Deltafin is a research project that runs the 2.8-trillion-parameter Mixture-of-Experts model Kimi K3 on a single Apple Silicon Mac (e.g., M1 Max with 64 GB) at about 16 seconds per token, using exact, reproducible inference with local or streaming expert loading.

A comprehensive guide for building and configuring a high-end local machine to run state-of-the-art LLMs, with detailed hardware choices, BIOS tuning, and Docker-based model serving.