1 precision recall f1-score support
2
3 no-recl (0) 0.9635 0.8648 0.9114 244
4 recl (1) 0.5658 0.8431 0.6772 51
5
6 accuracy 0.8610 295
7 macro avg 0.7646 0.8539 0.7943 295
8weighted avg 0.8947 0.8610 0.8709 295
1 precision recall f1-score support
2
3 no-recl (0) 0.9255 0.9672 0.9459 244
4 recl (1) 0.8000 0.6275 0.7033 51
5
6 accuracy 0.9085 295
7 macro avg 0.8627 0.7973 0.8246 295
8weighted avg 0.9038 0.9085 0.9040 295
1 precision recall f1-score support
2
3 no-recl (0) 0.9602 0.8893 0.9234 244
4 recl (1) 0.6087 0.8235 0.7000 51
5
6 accuracy 0.8780 295
7 macro avg 0.7844 0.8564 0.8117 295
8weighted avg 0.8994 0.8780 0.8848 295
1from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoConfig
2import torch, numpy as np
3
4repo = "SimoneAstarita/Pride-large-try-sweep-20251008-202520-t00"
5tok = AutoTokenizer.from_pretrained(repo)
6cfg = AutoConfig.from_pretrained(repo)
7model = AutoModelForSequenceClassification.from_pretrained(repo)
8
9texts = ["example text ..."]
10langs = ["en"]
11
12mode = "best_global" # or "0.5", "by_lang"
13
14enc = tok(texts, truncation=True, padding=True, max_length=256, return_tensors="pt")
15with torch.no_grad():
16 logits = model(**enc).logits
17probs = torch.softmax(logits, dim=-1)[:, 1].cpu().numpy()
18
19if mode == "0.5":
20 th = 0.5
21 preds = (probs >= th).astype(int)
22elif mode == "best_global":
23 th = getattr(cfg, "best_threshold_global", 0.5)
24 preds = (probs >= th).astype(int)
25elif mode == "by_lang":
26 th_by_lang = getattr(cfg, "thresholds_by_lang", {})
27 preds = np.zeros_like(probs, dtype=int)
28 for lg in np.unique(langs):
29 t = th_by_lang.get(lg, getattr(cfg, "best_threshold_global", 0.5))
30 preds[np.array(langs) == lg] = (probs[np.array(langs) == lg] >= t).astype(int)
31print(list(zip(texts, preds, probs)))
32
33### Files
34reports.json — all metrics (macro/weighted/accuracy) for @0.5, @best_global, and @best_by_lang.
35config.json — stores thresholds: default_threshold, best_threshold_global, thresholds_by_lang.
36report_0.5.txt, report_best.txt — readable classification reports.
37postprocessing.json — duplicate threshold info for external tools.