Views
No views yet
1{
2 "train_samples": 4044,
3 "val_samples": 867,
4 "test_samples": 867,
5 "num_labels": 31
6}1{
2 "batch_size": 32,
3 "learning_rate": 2e-05,
4 "num_epochs": 20,
5 "max_length": 512,
6 "threshold": 0.5
7}1| | validation_results | test_results |
2|:--------------------------------|---------------------:|---------------:|
3| eval_exact_match | 0.489043 | 0.472895 |
4| eval_hamming_loss | 0.0273096 | 0.0298024 |
5| eval_f1_micro | 0.697444 | 0.674258 |
6| eval_f1_macro | 0.537159 | 0.57959 |
7| eval_precision_micro | 0.725557 | 0.684558 |
8| eval_precision_macro | 0.593484 | 0.626934 |
9| eval_recall_micro | 0.671429 | 0.664263 |
10| eval_recall_macro | 0.511322 | 0.574265 |
11| eval_best_threshold | 0.6 | 0.6 |
12| eval_avg_predictions_per_sample | 1.34487 | 1.39677 |
13| eval_avg_labels_per_sample | 1.45329 | 1.43945 |1| | hit_rate | precision | recall | f1 | ndcg | coverage | mrr |
2|:----|-----------:|------------:|---------:|-------:|-------:|-----------:|-------:|
3| @1 | 0.7589 | 0.7589 | 0.2243 | 0.3217 | 0.7589 | 0.2243 | 0.2243 |
4| @3 | 0.9043 | 0.3806 | 0.2963 | 0.3011 | 0.5013 | 0.2963 | 0.2571 |
5| @5 | 0.9377 | 0.2496 | 0.3149 | 0.2514 | 0.4421 | 0.3149 | 0.2614 |
6| @10 | 0.9746 | 0.1349 | 0.3334 | 0.176 | 0.4168 | 0.3334 | 0.2639 |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-lv1"
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]) + '...]'}")