Xlm Roberta Large Sdg Openalex Multilabel 2026 09
Model description
Multilingual sequence classification model fine-tuned from XLM-RoBERTa-large to predict UN Sustainable Development Goal (SDG) labels (sdg1 … sdg17) from scientific text (OpenAlex-derived corpus).
- Task: multi-label text classification
- Classes: 17 SDG labels (sdg1–sdg17, incl. SDG 17)
- Fine-tuned from:
FacebookAI/xlm-roberta-large - Selection metric: F1 macro (best checkpoint)
Intended uses & limitations
Intended uses
- Tagging research abstracts and publications with one or more SDG labels
- Large-scale bibliometric SDG analytics on OpenAlex-style corpora
- Multilingual SDG pipelines that require SDG 17 (Partnerships)
Out-of-scope uses
- Legal or compliance decisions without human review
- High-stakes allocation of funds based solely on model predictions
- Fine-grained policy classification outside the SDG taxonomy
Limitations
- Trained on sdg-openalex; performance may drop on non-academic or very short text
- Input format:
<TITLE>…</TITLE>and optionally<ABSTRACT>…</ABSTRACT>(same as the datasettextcolumn; ~29% of training samples are title-only) - Strong class imbalance across SDGs; rare goals may underperform
- Dataset majoritàriament single-label per fila (~0.0014% train amb >1 SDG); el model prediu multi-label via sigmoid per classe
- Evaluation used the dataset test split as validation during training
- Threshold 0.5 per defecte a l'exemple d'ús; cal ajustar segons el cas d'ús
Training and evaluation data
Dataset
- Hub: albertmartinez/sdg-openalex
- Config:
v1 - Train split: 1,041,829 examples
- Test split: 260,458 examples (used for evaluation each epoch)
- Input column:
text - Label column:
labels(sdg1…sdg17)
Preprocessing
- Tokenizer: XLM-RoBERTa (
max_seq_length=512) - Pos weights applied to BCEWithLogitsLoss (inverse frequency, normalized)
- Train shuffle: enabled
Training procedure
Framework
Fine-tuning with Hugging Face Transformers Trainer, using the official run_classification.py script (project fork with class-weight / pos_weight support).
Training
- Optimizer: AdamW (Trainer default)
- Precision: bf16 on NVIDIA GPU
- Best checkpoint selected by eval F1 macro (
load_best_model_at_end=True) - Early stopping patience: 1 (eval F1 macro)
Training hyperparameters
| Parameter | Value |
|---|---|
| Base model | FacebookAI/xlm-roberta-large |
| Epochs (max) | 3.0 |
| Batch size / device (train) | 32 |
| Batch size / device (eval) | 32 |
| Gradient accumulation | 2 |
| Learning rate | 2e-05 |
| Weight decay | 0.01 |
| Warmup ratio | 0.1 |
| Max sequence length | 512 |
| Seed | 42 |
| BF16 | True |
| TF32 | True |
| Loss | BCEWithLogitsLoss + pos_weight |
| Metric | F1 macro |
Training results
Final metrics (best checkpoint)
| Metric | Value |
|---|---|
| Eval F1 macro | 0.9453 |
| Eval loss | 0.0009 |
| Train loss | 0.0048 |
| Train runtime | 6h 47m 6s |
| Train samples/sec | 127.957 |
Eval per epoch
| Epoch | Eval F1 macro | Eval loss |
|---|---|---|
| 1 | 0.8797 | 0.0014 |
| 2 | 0.9069 | 0.0012 |
| 3 | 0.9453 | 0.0009 |
Per-class evaluation
Per-class metrics via confusion matrix no disponibles en multi-label; veure F1 macro global al bloc d'avaluació.
Confusion matrix
Per-class metrics via confusion matrix no disponibles en multi-label; veure F1 macro global al bloc d'avaluació.
Usage
El model s'ha entrenat amb el format del dataset sdg-openalex: <TITLE>…</TITLE><ABSTRACT>…</ABSTRACT>. Si només tens títol, <TITLE>…</TITLE> n'hi ha prou.
from transformers import pipeline
model_id = "albertmartinez/xlm-roberta-large-sdg-openalex-multilabel-2026-09"
def format_input(title: str, abstract: str | None = None) -> str:
"""Format d'entrada del dataset sdg-openalex."""
text = "<TITLE>" + title.strip() + "</TITLE>"
if abstract and abstract.strip():
text += "<ABSTRACT>" + abstract.strip() + "</ABSTRACT>"
return text
classifier = pipeline(
"text-classification",
model=model_id,
top_k=None, # totes les etiquetes (multi-label, sigmoid automàtic)
)
text = format_input(
"Partnerships for sustainable development goals and international cooperation.",
"This study examines cross-sector collaboration for SDG implementation.",
)
results = classifier(text)[0]
threshold = 0.5
for item in results:
if item["score"] >= threshold:
print(item["label"], item["score"])
Framework versions
| Package | Version |
|---|---|
transformers |
4.57.6 |
torch |
2.6.0+cu124 |
datasets |
5.0.1 |
accelerate |
1.14.0 |
tokenizers |
0.22.2 |