File size: 4,057 Bytes
5e5f53f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
language: ru
license: apache-2.0
library_name: transformers
pipeline_tag: text-classification
base_model: Aniemore/rubert-large-emotion-russian-cedr-m7
base_model_relation: quantized
datasets:
- Aniemore/cedr-m7
tags:
- text-classification
- emotion-recognition
- russian
- multi-label-classification
- quantized
- compressed-tensors
- int8
- fp8
- int4
metrics:
- roc_auc
- f1
- accuracy
model-index:
- name: rubert-large-emotion-russian-cedr-m7-quantized
  results:
  - task:
      name: Emotion Recognition
      type: text-classification
    dataset:
      name: CEDR-m7 test (int8)
      type: Aniemore/cedr-m7
      args: ru
    metrics:
    - name: ROC AUC macro (int8)
      type: roc_auc
      value: 0.9260
    - name: Macro F1 (int8)
      type: f1
      value: 0.6727
  - task:
      name: Emotion Recognition
      type: text-classification
    dataset:
      name: CEDR-m7 test (fp8)
      type: Aniemore/cedr-m7
      args: ru
    metrics:
    - name: ROC AUC macro (fp8)
      type: roc_auc
      value: 0.9264
    - name: Macro F1 (fp8)
      type: f1
      value: 0.6715
  - task:
      name: Emotion Recognition
      type: text-classification
    dataset:
      name: CEDR-m7 test (int4)
      type: Aniemore/cedr-m7
      args: ru
    metrics:
    - name: ROC AUC macro (int4)
      type: roc_auc
      value: 0.9237
    - name: Macro F1 (int4)
      type: f1
      value: 0.6702
---

# rubert-large-emotion-russian-cedr-m7 · quantized

Quantized builds of [`Aniemore/rubert-large-emotion-russian-cedr-m7`](https://huggingface.co/Aniemore/rubert-large-emotion-russian-cedr-m7) — multi-label emotion recognition for Russian text over seven classes: `anger`, `disgust`, `enthusiasm`, `fear`, `happiness`, `neutral`, `sadness`.

The weights here are the published original, quantized. They were not retrained and they are not a different model.

## Variants

| subfolder | scheme | weights | ROC AUC (macro) | macro-F1 | WA | UA |
|---|---|---:|---:|---:|---:|---:|
| _(original repo)_ | fp32 | 1629 MiB | 0.9258 | 0.6724 | 0.8395 | 0.6610 |
| `int8` | W8A16 | 774 MiB | 0.9260 | 0.6727 | 0.8385 | 0.6605 |
| `fp8` | W8A16-float | 766 MiB | 0.9264 | 0.6715 | 0.8401 | 0.6608 |
| `int4` | W4A16_ASYM | 631 MiB | 0.9237 | 0.6702 | 0.8454 | 0.6671 |

<img src="assets/quality.svg" alt="Quality after quantization" width="760">

<img src="assets/size.svg" alt="Weights on disk" width="760">

ROC AUC is listed first because the head is multi-label: macro-F1 depends on the decision threshold, which is 0.5 here because that is what the head was trained under, while ROC AUC does not.

### How much this actually saves

Only `Linear` layers are quantized. In a BERT classifier the embedding matrix is not one of them, and on the smaller models it is most of the checkpoint &mdash; so the saving here scales with the encoder rather than with the parameter count. The large model compresses well; `rubert-tiny` barely moves, and the table above says so rather than quoting a ratio from the layers that did shrink.

## Usage

```python
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer

repo = "Aniemore/rubert-large-emotion-russian-cedr-m7-quantized"
model = AutoModelForSequenceClassification.from_pretrained(
    repo, subfolder="int8").eval()          # or "fp8", "int4"
tok = AutoTokenizer.from_pretrained(repo, subfolder="int8")

x = tok("мне сегодня очень грустно", return_tensors="pt")
with torch.no_grad():
    # multi-label: sigmoid per class, not softmax over classes
    probs = model(**x).logits.sigmoid()[0]
print({model.config.id2label[i]: round(p.item(), 3) for i, p in enumerate(probs)})
```

## Limitations

- Weight-only, round-to-nearest, no calibration.
- Scored on the CEDR-m7 test split only. CEDR is written text; performance on transcribed speech, which carries no punctuation and no casing, is not measured here.
- Inherited from [`ai-forever/ruBert-large`](https://huggingface.co/ai-forever/ruBert-large); the licence follows the base model.