sprakbanken-se/superlim-2
Viewer • Updated • 500k • 1.51k • 10
Chunk1e/swedish-grammaticality-modernbert-large)
A fine-tuned AI-Sweden-Models/ModernBERT-large (395.83M parameters) regression model that scores the grammatical correctness of Swedish text on a continuous scale in [0, 1] (higher = more grammatical).
Built for the AI Sweden Master's Thesis Selection Task — Swedish Grammaticality Scoring.
Chunk1e/swedish-grammaticality-scoringimport torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model_id = "Chunk1e/swedish-grammaticality-modernbert-large"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id).eval()
texts = [
"Kommunen har beslutat att bygga en ny förskola i stadsdelen, och arbetet beräknas vara klart till hösten nästa år.",
"I norröna tid fanns det svält i Oslo och många människor dog inte hade fisk tillgång från England.",
]
enc = tokenizer(texts, padding=True, truncation=True, max_length=512, return_tensors="pt")
with torch.inference_mode():
scores = torch.sigmoid(model(**enc).logits.squeeze(-1)).tolist()
print(scores)
Measured on NVIDIA GeForce RTX 4070 SUPER (BF16) and Intel Core i5-13600KF CPU:
| Benchmark | N | Spearman | ROC-AUC | MAE | Throughput |
|---|---|---|---|---|---|
Starter Test (evaluate.py end-to-end incl. load) |
120 | 0.856 | 0.981 | 0.063 | 816 samples/min (8.8s GPU; 5.65s CPU excl. Python cold start) |
| DaLAJ Dev (real human L2 Swedish) | 4,536 | 0.758 | 0.938 | 0.104 | 78,605 samples/min (GPU) |
| DaLAJ Test (strictly blind human L2 Swedish) | 4,223 | 0.767 | 0.942 | 0.100 | 79,453 samples/min (GPU) |
| Graded Val (DaLAJ + Wiki 0/1/2/3 errors) | 2,000 | 0.896 | 0.976 | 0.083 | 54,307 samples/min (GPU) |
BCEWithLogitsLoss on continuous targets in [0, 1] + in-batch pairwise logistic ranking loss (rank_weight=0.25, score gap >= 0.10).train.jsonl (478 × 2).16 × 2), lr=2e-5 (head ×3), cosine schedule (8% warmup), max_length=256, BF16 AMP, seed=42.Base model
answerdotai/ModernBERT-large