Views
No views yet
1{
2 "train_samples": 4044,
3 "val_samples": 867,
4 "test_samples": 867,
5 "num_labels": 216
6}1{
2 "batch_size": 32,
3 "learning_rate": 2e-05,
4 "num_epochs": 5,
5 "max_length": 512,
6 "threshold": 0.5
7}1| | validation_results | test_results |
2|:---------------------|---------------------:|---------------:|
3| eval_exact_match | 0.310265 | 0.303345 |
4| eval_hamming_loss | 0.00932868 | 0.00976654 |
5| eval_f1_micro | 0.589038 | 0.566896 |
6| eval_f1_macro | 0.142712 | 0.157367 |
7| eval_precision_micro | 0.773795 | 0.746259 |
8| eval_precision_macro | 0.206659 | 0.234683 |
9| eval_recall_micro | 0.475503 | 0.457045 |
10| eval_recall_macro | 0.118758 | 0.13034 |1| | hit_rate | precision | recall | f1 | ndcg | coverage | mrr |
2|:----|-----------:|------------:|---------:|-------:|-------:|-----------:|-------:|
3| @1 | 0.7255 | 0.7255 | 0.2076 | 0.302 | 0.7255 | 0.2076 | 0.2076 |
4| @3 | 0.8316 | 0.5398 | 0.4278 | 0.4389 | 0.6316 | 0.4278 | 0.3084 |
5| @5 | 0.8674 | 0.3852 | 0.4841 | 0.3924 | 0.5862 | 0.4841 | 0.3214 |
6| @10 | 0.9193 | 0.2261 | 0.546 | 0.2955 | 0.5756 | 0.546 | 0.3297 |1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2from huggingface_hub import hf_hub_download
3import pickle
4import torch
5import numpy as np
6
7repo_id = "giacomorossojakala/dbmdz-bert-base-italian-xxl-cased-eutekne-filtri-materia-lv2"
8
9# Load tokenizer and model
10tokenizer = AutoTokenizer.from_pretrained(repo_id)
11model = AutoModelForSequenceClassification.from_pretrained(repo_id)
12
13# Download and load label encoder
14downloaded_path = hf_hub_download(repo_id=repo_id, filename="label_encoder.pkl")
15with open(downloaded_path, 'rb') as f:
16 mlb = pickle.load(f)
17
18custom_text = "agevolazioni acquisto prima casa"
19inputs = tokenizer(custom_text, truncation=True, padding=True, max_length=512, return_tensors="pt")
20
21model.eval()
22with torch.no_grad():
23 outputs = model(**inputs)
24
25logits = outputs.logits
26probabilities = torch.sigmoid(logits)
27predictions = (probabilities > 0.75).int().cpu().numpy()
28predicted_labels = mlb.inverse_transform(predictions)
29ranked_idexes = np.argsort(probabilities.cpu().numpy(), axis=1)[:, ::-1]
30ranked_labels = np.array(mlb.classes_)[ranked_idexes]
31
32print(f"Custom Text: agevolazioni acquisto prima casa")
33print(f"Predicted Labels: ('V',)")
34print(f"Ranked Labels: {'[' +', '.join(ranked_labels[0, :5]) + '...]'}")