modernbert-large-unical
Architettura UNICAL: encoder addestrato con statement tuning multi-domanda
(template di statement-tuning, adattati alla forma stato/statement): dato un testo (lo stato) e uno o piu' statement,
restituisce la probabilita' che ogni statement sia vero. Pensato come proxy veloce per sem_filter.
Gli statement condividono lo stato nella stessa sequenza, ma una maschera di attenzione bidirezionale a blocchi li rende indipendenti: il punteggio di uno statement e' identico a quello che si otterrebbe valutandolo da solo.
Uso
Basta transformers: il codice del modello e' incluso nel repository (trust_remote_code=True).
from transformers import AutoModel
model = AutoModel.from_pretrained("stefra/modernbert-large-unical", trust_remote_code=True)
model.predict("The vase is broken.", "The sentence is negative.") # un numero, es. 0.93
model.predict("The vase is broken.", ["The vase is intact.", "It is sad."]) # un array, uno per statement
model.predict(recensioni, "This review is negative.") # un array, uno per testo
model.filter(recensioni, "This review is negative.") # True/False per ogni testo
model.classify(recensioni, ["The sentiment of the review is negative.",
"The sentiment of the review is positive."]) # indice dello statement piu' probabile
Non e' un modello generativo: predict restituisce la probabilita' che ogni statement sia vero. Su GPU il modello
viene caricato in float16; si puo' scegliere con device= e dtype=.
Con il pacchetto unical (codice di training) funziona anche
StatementScorer.from_pretrained("stefra/modernbert-large-unical").
Contenuto
| File | Contenuto |
|---|---|
modeling_unical.py | codice dell'architettura UNICAL, usato da AutoModel |
config.json | configurazione per AutoModel |
backbone/ | encoder fine-tuned (formato transformers) |
head.safetensors | testa vero/falso |
statement_encoder.json | pooling e configurazione del packing usata in training |
tokenizer* | tokenizer |
eval_report.json | metriche per sorgente |
Metriche
Validazione (sorgenti di training)
| sorgente | n | accuracy | F1 | ROC-AUC | Brier | ECE |
|---|---|---|---|---|---|---|
| dpr | 300 | 0.773 | 0.778 | 0.816 | 0.203 | 0.197 |
| massive | 300 | 0.940 | 0.940 | 0.983 | 0.052 | 0.049 |
| mintaka | 150 | 0.907 | 0.863 | 0.963 | 0.076 | 0.059 |
| mnli | 300 | 0.857 | 0.860 | 0.922 | 0.110 | 0.083 |
| piqa | 200 | 0.625 | 0.571 | 0.655 | 0.254 | 0.140 |
| qasc | 150 | 0.853 | 0.761 | 0.911 | 0.107 | 0.067 |
| qqp | 163 | 0.914 | 0.879 | 0.966 | 0.072 | 0.065 |
| race | 247 | 0.733 | 0.680 | 0.810 | 0.198 | 0.145 |
| samsum | 300 | 1.000 | 1.000 | 1.000 | 0.000 | 0.000 |
| sciq | 150 | 0.880 | 0.824 | 0.970 | 0.085 | 0.090 |
| snli | 300 | 0.900 | 0.902 | 0.958 | 0.083 | 0.063 |
| squad | 290 | 0.955 | 0.956 | 0.993 | 0.034 | 0.030 |
| tweet_offensive | 300 | 0.783 | 0.778 | 0.886 | 0.166 | 0.136 |
| winogrande | 300 | 0.850 | 0.850 | 0.927 | 0.119 | 0.098 |
| yelp_polarity | 300 | 0.977 | 0.977 | 0.987 | 0.024 | 0.025 |
| ALL | 3750 | 0.867 | 0.858 | 0.943 | 0.104 | 0.070 |
Held-out (task mai visti in training)
| sorgente | n | accuracy | F1 | ROC-AUC | Brier | ECE |
|---|---|---|---|---|---|---|
| ag_news | 12000 | 0.686 | 0.566 | 0.842 | 0.279 | 0.288 |
| emotion | 12000 | 0.650 | 0.511 | 0.787 | 0.315 | 0.311 |
| rotten_tomatoes | 6396 | 0.843 | 0.842 | 0.913 | 0.136 | 0.118 |
| ALL | 30396 | 0.705 | 0.620 | 0.823 | 0.263 | 0.256 |