CoolFace
Modelpublic

nie3e/plutchik-emotions-polish-poc

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes18downloads
Model Card

plutchik-emotions-polish-poc

This model is a fine-tuned version of sdadas/polish-gpt2-small on a synthetically annotated WiktorS/polish-news dataset. It achieves the following results on the evaluation set: Every list contains results for threshold [0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]

  • —Loss: 0.4958
  • —Hamming Accuracy: [0.8251, 0.8363, 0.8424, 0.8461, 0.8471, 0.848, 0.8464]
  • —F1 Macro: [0.5061, 0.4948, 0.4802, 0.4641, 0.4376, 0.4023, 0.3423]
  • —Precision Macro: [0.4873, 0.5201, 0.5486, 0.5752, 0.5986, 0.6279, 0.6586]
  • —Recall Macro: [0.5270, 0.4738, 0.4304, 0.3929, 0.3494, 0.3008, 0.2362]

Model description

Trained from sdadas/polish-gpt2-small as a Proof of Concept.

Intended uses & limitations

Detecting emotions described in Robert_Plutchik#Theory_of_emotion

Labels:

0: joy
1: trust
2: anticipation
3: surprise
4: fear
5: sadness
6: disgust
7: anger

How to use

<details><summary>Transformers AutoModel</summary>

py
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch

device = "cuda" if torch.cuda.is_available() else "cpu"
checkpoint = "nie3e/plutchik-emotions-polish-poc"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSequenceClassification.from_pretrained(
    checkpoint, problem_type="multi_label_classification"
).to(device)

text = "To jest model wykrywający super emocje w tekście! :D"

input_ids = tokenizer(text, return_tensors="pt").to(device)
logits = model(**input_ids)["logits"].to("cpu")

threshold = 0.3
predicted_class_ids = torch.arange(
    0, logits.shape[-1]
)[torch.sigmoid(logits).squeeze(dim=0) > threshold]

percent = torch.sigmoid(logits).squeeze(dim=0)

id2class = model.config.id2label
print([id2class[c] for c in predicted_class_ids.tolist()])
print({id2class[i]: f"{(p*100):.2f}%" for i, p in enumerate(percent.tolist())})
['joy', 'anticipation']
{'joy': '91.15%', 'trust': '2.06%', 'anticipation': '61.14%', 'surprise': '23.00%', 'fear': '1.93%', 'sadness': '0.40%', 'disgust': '3.02%', 'anger': '2.54%'}

</details>

<details><summary>Transformers Pipeline</summary>

py
from transformers import pipeline
import torch

device = "cuda" if torch.cuda.is_available() else "cpu"

pipe = pipeline(
    "text-classification",
    "nie3e/plutchik-emotions-polish-poc",
    top_k=-1,
    device=device
)
text = "To jest model wykrywający super emocje w tekście! :D"

result = pipe(text)
print(result)
[[{'label': 'joy', 'score': 0.9111796617507935}, {'label': 'anticipation', 'score': 0.6109178066253662}, {'label': 'surprise', 'score': 0.23231014609336853}, {'label': 'disgust', 'score': 0.030675798654556274}, {'label': 'anger', 'score': 0.025565214455127716}, {'label': 'trust', 'score': 0.02096424251794815}, {'label': 'fear', 'score': 0.019419347867369652}]]

</details>

<details><summary>vLLM OpenAI serving (recommended)</summary>

bash
docker run --gpus 1 --ipc=host -p 8000:8000 vllm/vllm-openai:v0.9.2 --model nie3e/plutchik-emotions-polish-poc

using curl:

bash
curl -X 'POST' \
  'http://127.0.0.1:8000/classify' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "nie3e/plutchik-emotions-polish-poc",
  "input": ["To jest model wykrywający super emocje w tekście! :D"]
}'

result:

json
{
	"id": "classify-2cea66aa49b84b239277ad8cdb8ad662",
	"object": "list",
	"created": 1756143116,
	"model": "nie3e/plutchik-emotions-polish-poc",
	"data": [
		{
			"index": 0,
			"label": "joy",
			"probs": [
				0.8406059741973877,
				0.0017006286652758718,
				0.12716063857078553,
				0.024033185094594957,
				0.0015728245489299298,
				0.00032968190498650074,
				0.0025133665185421707,
				0.002083654049783945
			],
			"num_classes": 8
		}
	],
	"usage": {
		"prompt_tokens": 12,
		"total_tokens": 12,
		"completion_tokens": 0,
		"prompt_tokens_details": null
	}
}

using python:

py
import requests

response = requests.post(
    f"http://127.0.0.1:8000/classify",
    headers={"Content-Type": "application/json"},
    json={
        "model": "nie3e/plutchik-emotions-polish-poc",
        "input": ["To jest model wykrywający super emocje w tekście! :D"]
    }
)

print(response.json())
{'id': 'classify-003f1db547504a5398ee76907f6f5e30',
 'object': 'list',
 'created': 1756143205,
 'model': 'nie3e/plutchik-emotions-polish-poc',
 'data': [{'index': 0,
   'label': 'joy',
   'probs': [0.8406059741973877,
    0.0017006286652758718,
    0.12716063857078552,
    0.024033185094594955,
    0.0015728245489299297,
    0.00032968190498650074,
    0.0025133665185421705,
    0.002083654049783945],
   'num_classes': 8}],
 'usage': {'prompt_tokens': 12,
  'total_tokens': 12,
  'completion_tokens': 0,
  'prompt_tokens_details': None}}

</details>

Training and evaluation data

Dataset: WiktorS/polish-news

LLM used for annotation: bartowski/mistralai_Mistral-Small-3.2-24B-Instruct-2506-GGUF Q8

Training procedure

Training hyperparameters

The following hyperparameters were used during training:

  • —learning_rate: 2e-05
  • —trainbatchsize: 2
  • —evalbatchsize: 4
  • —seed: 42
  • —distributed_type: multi-GPU
  • —num_devices: 2
  • —gradientaccumulationsteps: 16
  • —totaltrainbatch_size: 64
  • —totalevalbatch_size: 8
  • —optimizer: Use OptimizerNames.ADAMWTORCH with betas=(0.9,0.999) and epsilon=1e-08 and optimizerargs=No additional optimizer arguments
  • —lrschedulertype: linear
  • —lrschedulerwarmup_ratio: 0.1
  • —num_epochs: 10

Training results

Training LossEpochStepValidation LossHamming Accuracy 0.30F1 Macro 0.30Precision Macro 0.30Recall Macro 0.30Hamming Accuracy 0.40F1 Macro 0.40Precision Macro 0.40Recall Macro 0.40Hamming Accuracy 0.50F1 Macro 0.50Precision Macro 0.50Recall Macro 0.50Hamming Accuracy 0.60F1 Macro 0.60Precision Macro 0.60Recall Macro 0.60Hamming Accuracy 0.70F1 Macro 0.70Precision Macro 0.70Recall Macro 0.70Hamming Accuracy 0.80F1 Macro 0.80Precision Macro 0.80Recall Macro 0.80Hamming Accuracy 0.90F1 Macro 0.90Precision Macro 0.90Recall Macro 0.90
No log000.64310.33170.29390.18830.80020.47590.26550.19510.58070.62690.21230.20690.34770.740.14670.24700.16570.79960.05830.25440.04590.81790.01190.15330.00640.8190.00.00.0
0.35021.033100.34540.83580.51130.53920.51810.85310.46100.62320.39620.85160.36760.69010.27850.84780.27940.74320.19600.83970.19380.79960.12520.83190.11390.78410.06730.82260.03620.56390.0192
0.33732.066200.33970.83470.54000.51970.57600.84910.50840.57760.46890.85530.46250.64280.37630.85270.39620.68390.29050.84660.30050.74130.19630.83880.20980.80040.12450.82730.09030.76070.0487
0.31583.099300.33650.84060.53420.53440.54830.85330.49930.59040.44840.85780.45080.65130.35950.85510.38590.70910.27950.84910.30600.74990.20220.84040.20670.82810.12400.82850.09410.81200.0517
0.29044.0132400.34520.83810.53780.53130.55950.85110.51260.58740.46800.85790.47990.64450.39470.85570.41480.68000.31100.85180.34850.72240.23960.84490.26430.78100.16710.83410.14550.81690.0844
0.26485.0165500.35840.83550.53040.52090.54670.84980.50950.57440.46410.85490.47710.62260.39290.85440.42660.66310.32110.84880.35190.68300.24280.84360.27510.72730.17460.83550.18240.78650.1055
0.23796.0198600.38280.8330.51290.50870.51890.84670.50090.56210.45520.85070.46520.60050.38370.85350.42840.65660.32300.85050.37790.68100.26570.84530.30580.70550.19910.83780.21420.73940.1279
0.21467.0231700.41610.82770.51380.49230.54170.84150.50690.53790.48490.84730.48400.56910.42910.84940.45260.59590.37270.84920.41420.61940.31790.84790.36550.65610.25940.84180.27680.68680.1781
0.19078.0264800.45340.82890.52070.50130.54530.83910.50250.52990.48350.84530.48360.55870.43270.84910.45960.58550.38580.84950.42870.61350.33640.84820.38360.63330.28140.84480.31450.67410.2112
0.16949.0297900.47250.82670.51180.49290.53440.83770.50020.52560.48040.84330.48350.55300.43410.84790.46350.58280.39020.84920.43650.61030.34630.84920.39720.63870.29450.84610.32890.66470.2244
0.155810.0331000.49580.82510.50610.48730.52700.83630.49480.52010.47380.84240.48020.54860.43040.84610.46410.57520.39290.84710.43760.59860.34940.8480.40230.62790.30080.84640.34230.65860.2362

Framework versions

  • —Transformers 4.54.1
  • —Pytorch 2.7.1+cu128
  • —Datasets 4.0.0
  • —Tokenizers 0.21.4