Downloads · 30 days
110
28% of all-time downloads
pymlex/roberta-spanish-cefr
roberta-spanish-cefr is a text classification model from pymlex. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as gpl-3.0.
pymlex/roberta-spanish-cefr is a Spanish text classifier fine-tuned from bertin-project/bertin-roberta-base-spanish for CEFR level prediction. It is intended for Spanish learner-text classification and readability-sty…
Downloads · 30 days
110
28% of all-time downloads
All-time downloads
388
Public
Parameters
125M
499 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors499 MB · 99%
From the Hugging Face model README
pymlex/roberta-spanish-cefr is a Spanish text classifier fine-tuned from bertin-project/bertin-roberta-base-spanish for CEFR level prediction. It is intended for Spanish learner-text classification and readability-style proficiency assessment.
The model was trained on UniversalCEFR/caes_es, a Spanish dataset of learner texts with CEFR annotations. The dataset has 31.1k rows.
Results for the test set:
Our model's performance (F1: 0.9894) is SOTA. Most documented Spanish CEFR classifiers fall within the 0.75 – 0.88 F1-score range. The obtained results significantly outperform these common baselines:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_id = "pymlex/roberta-spanish-cefr"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
model.eval()
def predict_cefr(text, top_k=3):
inputs = tokenizer(
text,
return_tensors="pt",
truncation=True,
max_length=512,
)
with torch.no_grad():
logits = model(**inputs).logits
probs = torch.softmax(logits, dim=-1)[0]
k = min(top_k, probs.numel())
values, indices = torch.topk(probs, k=k)
return [
{
"label": model.config.id2label[i.item()],
"score": float(v.item()),
}
for i, v in zip(indices, values)
]
text = "Estimados señores, les escribo para solicitar información sobre el curso."
print(predict_cefr(text, top_k=3))