1 precision recall f1-score support
2
3 no-recl (0) 0.9399 0.8130 0.8719 385
4 recl (1) 0.3793 0.6875 0.4889 64
5
6 accuracy 0.7951 449
7 macro avg 0.6596 0.7502 0.6804 449
8weighted avg 0.8600 0.7951 0.8173 449
1 precision recall f1-score support
2
3 no-recl (0) 0.9121 0.9429 0.9272 385
4 recl (1) 0.5686 0.4531 0.5043 64
5
6 accuracy 0.8731 449
7 macro avg 0.7403 0.6980 0.7158 449
8weighted avg 0.8631 0.8731 0.8669 449
1 precision recall f1-score support
2
3 no-recl (0) 0.9266 0.8857 0.9057 385
4 recl (1) 0.4568 0.5781 0.5103 64
5
6 accuracy 0.8419 449
7 macro avg 0.6917 0.7319 0.7080 449
8weighted avg 0.8597 0.8419 0.8494 449
1from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoConfig
2import torch, numpy as np
3
4repo = "SimoneAstarita/october-finetuning-more-variables-sweep-20251012-195029-t04"
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)))
reports.json: all metrics (macro/weighted/accuracy) for @0.5, @best_global, and @best_by_lang.
config.json: stores thresholds: default_threshold, best_threshold_global, thresholds_by_lang.
postprocessing.json: duplicate threshold info for external tools.