roberta-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/roberta-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/roberta-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 | 396 | 0.889 | 0.888 | 0.945 | 0.094 | 0.072 |
| massive | 600 | 0.923 | 0.925 | 0.974 | 0.061 | 0.050 |
| mintaka | 300 | 0.903 | 0.866 | 0.966 | 0.071 | 0.042 |
| mnli | 600 | 0.863 | 0.863 | 0.940 | 0.097 | 0.036 |
| piqa | 400 | 0.565 | 0.605 | 0.572 | 0.249 | 0.067 |
| qasc | 300 | 0.780 | 0.515 | 0.794 | 0.148 | 0.046 |
| qqp | 338 | 0.888 | 0.843 | 0.956 | 0.086 | 0.054 |
| race | 485 | 0.736 | 0.704 | 0.815 | 0.183 | 0.098 |
| samsum | 600 | 1.000 | 1.000 | 1.000 | 0.000 | 0.001 |
| sciq | 300 | 0.803 | 0.712 | 0.889 | 0.128 | 0.072 |
| snli | 598 | 0.890 | 0.890 | 0.946 | 0.088 | 0.056 |
| squad | 590 | 0.927 | 0.929 | 0.974 | 0.056 | 0.041 |
| tweet_offensive | 600 | 0.830 | 0.835 | 0.880 | 0.143 | 0.103 |
| winogrande | 600 | 0.862 | 0.857 | 0.936 | 0.110 | 0.082 |
| yelp_polarity | 600 | 0.977 | 0.977 | 0.998 | 0.018 | 0.015 |
| ALL | 7307 | 0.867 | 0.858 | 0.946 | 0.096 | 0.043 |
Held-out (task mai visti in training)
| sorgente | n | accuracy | F1 | ROC-AUC | Brier | ECE |
|---|---|---|---|---|---|---|
| ag_news | 12000 | 0.769 | 0.752 | 0.862 | 0.182 | 0.142 |
| emotion | 12000 | 0.605 | 0.399 | 0.741 | 0.337 | 0.333 |
| rotten_tomatoes | 6396 | 0.835 | 0.826 | 0.910 | 0.139 | 0.119 |
| ALL | 30396 | 0.718 | 0.659 | 0.823 | 0.234 | 0.210 |