1 precision recall f1-score support
2
3 no-recl (0) 0.9263 0.9143 0.9203 385
4 recl (1) 0.5217 0.5625 0.5414 64
5
6 accuracy 0.8641 449
7 macro avg 0.7240 0.7384 0.7308 449
8weighted avg 0.8686 0.8641 0.8663 449
1 precision recall f1-score support
2
3 no-recl (0) 0.9223 0.9558 0.9388 385
4 recl (1) 0.6600 0.5156 0.5789 64
5
6 accuracy 0.8931 449
7 macro avg 0.7912 0.7357 0.7589 449
8weighted avg 0.8849 0.8931 0.8875 449
1 precision recall f1-score support
2
3 no-recl (0) 0.9291 0.9195 0.9243 385
4 recl (1) 0.5441 0.5781 0.5606 64
5
6 accuracy 0.8708 449
7 macro avg 0.7366 0.7488 0.7424 449
8weighted avg 0.8743 0.8708 0.8724 449
1from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoConfig
2import torch, numpy as np
3
4repo = "SimoneAstarita/trilingual-no-bio-20251014-t03"
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.