Views
No views yet
Aniemore/wavlm-bert-base-s-emotion-russian-resd — speech emotion recognition for Russian over seven classes: anger, disgust, enthusiasm, fear, happiness, neutral, sadness.| subfolder | scheme | weights | vs fp32 | macro-F1 | UA | WA |
|---|---|---|---|---|---|---|
| (original repo) | fp32 | 1887 MiB | 1.0x | 0.7368 | 0.7406 | 0.7429 |
int8 | W8A16 | 792 MiB | 2.4x smaller | 0.7331 | 0.7361 | 0.7393 |
fp8 | W8A16-float | 781 MiB | 2.4x smaller | 0.7368 | 0.7406 | 0.7429 |
int4 | W4A16_ASYM | 609 MiB | 3.1x smaller | 0.7318 | 0.7351 | 0.7393 |
subfolder=. Only that subfolder is downloaded.1import torch, librosa
2from transformers import AutoModelForAudioClassification, AutoFeatureExtractor
3
4repo = "Aniemore/wavlm-bert-base-s-emotion-russian-resd-quantized"
5model = AutoModelForAudioClassification.from_pretrained(
6 repo, subfolder="int8").eval() # or "fp8", "int4"
7fe = AutoFeatureExtractor.from_pretrained(repo, subfolder="int8")
8
9# Resample to 16 kHz. Do not skip it: RESD itself ships at 44.1 kHz,
10# and handing the model 44.1 kHz audio while telling the extractor it
11# is 16 kHz stretches time 2.8x and silently changes the answer.
12wav, _ = librosa.load("clip.wav", sr=16000, mono=True)
13x = fe(wav, sampling_rate=16000, return_tensors="pt", padding=True)
14with torch.no_grad():
15 probs = model(**x).logits.softmax(-1)[0]
16print({model.config.id2label[i]: round(p.item(), 3) for i, p in enumerate(probs)})1# torchaudio
2import torchaudio
3wav, sr = torchaudio.load("clip.wav")
4wav = torchaudio.functional.resample(wav, sr, 16000).mean(0).numpy()
5
6# torchcodec, the newer decoder
7from torchcodec.decoders import AudioDecoder
8wav = AudioDecoder("clip.wav", sample_rate=16000).get_all_samples().data.mean(0).numpy()
9
10# straight from the dataset, which resamples on the column
11from datasets import load_dataset, Audio
12ds = load_dataset("Aniemore/resd", split="test")
13ds = ds.cast_column("speech", Audio(sampling_rate=16000))
14wav = ds[0]["speech"]["array"]nn.Linear inside the encoder blocks — that is where 98.6% of the weight mass sits. Left in fp32: the convolutional feature extractor, the positional convolution, the layer norms, the projector and the classifier. The classifier is seven rows wide, so quantizing it would save nothing and put rounding error straight onto the logits.int8 — W8A16, 8-bit integer weights, group size 128, symmetric. Activations are not quantized.fp8 — W8A16-float, 8-bit float8_e4m3 weights, per output channel, symmetric. Activations are not quantized.int4 — W4A16_ASYM, 4-bit integer weights, group size 128, asymmetric. Activations are not quantized.compressed-tensors; transformers loads it directly, no extra package.compressed-tensors-aware runtimes keep the weights packed and dequantize per tile inside the kernel. Memory drops roughly with the table above, and W4A16 hits the Marlin path on Ampere and newer.transformers decompresses to the compute dtype while loading, so the resident model is the size fp32 or bf16 would be. Load with dtype=torch.bfloat16 if you want the memory back on this path.