CoolFace
Modelpublic

AsifZaman1912/kotodama-distilbert-emotion

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes9downloads
Model Card

Kotodama — DistilBERT emotion classifier

distilbert-base-uncased fine-tuned on dair-ai/emotion with class-weighted cross-entropy, for the Kotodama project.

Why macro-F1 rather than accuracy

The dataset is heavily imbalanced — joy is 9.4x the size of surprise. A model that predicted only joy would score 33.5% accuracy while being useless. The headline metric is therefore macro-F1, which weights the rarest class exactly as heavily as the most common one, and training used class weights inversely proportional to class frequency.

Results (held-out test split)

ModelMacro-F1AccuracyWeighted-F1
TF-IDF + Logistic Regression (baseline)0.83280.88150.8842
This model0.89510.92800.9298
gain+0.0623

The gain is concentrated in the minority classes — exactly the ones a raw-accuracy comparison would let a model ignore.

EmotionPrecisionRecallF1Support
surprise0.6890.9390.79566
love0.7640.9560.849159
fear0.9200.8710.894224
anger0.9140.9270.921275
joy0.9800.9180.948695
sadness0.9740.9540.963581

Labels

Index order matters — it is the order of the model's logits.

012345
sadnessjoyloveangerfearsurprise

Usage

python
from transformers import pipeline

classifier = pipeline("text-classification", model="AsifZaman1912/kotodama-distilbert-emotion", top_k=None)
classifier("i cannot believe this actually happened")

Training

SettingValue
Base modeldistilbert-base-uncased
Epochs4
Best epoch4 (selected on validation macro-F1)
Batch size32
Learning rate3e-05
Max length128
Class-weighted lossTrue

Checkpoint selection was on validation macro-F1, never validation loss: with a weighted objective the two can disagree, and loss favours models that have conceded the minority classes. The test split was used exactly once, for the numbers above.

ONNX

onnx/model.onnx is an fp32 export. onnx/model.int8.onnx is dynamically quantized — 4x smaller and faster, but it measures -0.0078 macro-F1 against fp32, so fp32 remains the serving default.