Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
3tokenizer = AutoTokenizer.from_pretrained("LumiOpen/llama-hpltv2-edu-classifier-xlm-roberta-large-mal-Mlym")
4model = AutoModelForSequenceClassification.from_pretrained("LumiOpen/llama-hpltv2-edu-classifier-xlm-roberta-large-mal-Mlym")
5text = "I'm non-educational web page containing nothing useful"
6inputs = tokenizer(text, return_tensors="pt", padding="longest", truncation=True)
7outputs = model(**inputs)
8logits = outputs.logits.squeeze(-1).float().detach().numpy()
9score = logits.item()
10result = {
11 "text": text,
12 "score": score,
13 "int_score": int(round(max(0, min(score, 5)))),
14}
15print(result)
16#results from a model trained with Welsh annotations
17#{'text': "I'm non-educational web page containing nothing useful", 'score': 0.8145455718040466, 'int_score': 1}
18#{'text': 'what are most common animals found in farm? there are cows, sheeps', 'score': 1.6858888864517212, 'int_score': 2}
precision recall f1-score support
0 0.76 0.59 0.67 7294
1 0.69 0.74 0.71 11742
2 0.44 0.61 0.51 3466
3 0.40 0.38 0.39 1524
4 0.72 0.29 0.42 929
5 0.19 0.16 0.17 45
accuracy 0.64 25000
macro avg 0.53 0.46 0.48 25000
weighted avg 0.66 0.64 0.64 25000
@misc {llama_hplt_edu_classifiers_2025,
author = { Tarkka, Otto, Reunamo, Akseli, Vitiugin, Fedor and Pyysalo, Sampo }
title = { Llama-HPLT-edu classifiers },
year = 2025,
url = {https://huggingface.co/collections/LumiOpen/hplt-edu-classifiers-68a85a78f9710426320e7cbb},
publisher = { Hugging Face }
}