DistilBERT β€” book genre multi-label classifier

Fine-tune of distilbert-base-uncased on book summaries. A title can have several genres.

Labels: crime, fantasy, history, horror, psychology, romance, science, sports, thriller, travel

Prediction threshold: 0.5

Metrics (validation)

Metric Value
F1 macro 0.6583
F1 micro 0.7221
Precision macro 0.7703
Recall macro 0.5915
Accuracy (exact match) 0.6555

Metrics (test)

Metric Value
F1 macro 0.6532
F1 micro 0.7169
Precision macro 0.7529
Recall macro 0.5843
Accuracy (exact match) 0.6496

Usage

from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch

repo = "faikidine/distilbert-book-genre-multilabel"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForSequenceClassification.from_pretrained(repo)

text = "A young wizard discovers a hidden school of magic."
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256)
with torch.no_grad():
    probs = torch.sigmoid(model(**inputs).logits)[0]

predicted = [
    model.config.id2label[i]
    for i, probability in enumerate(probs.tolist())
    if probability >= 0.5
]
print(predicted)
Downloads last month
6
Safetensors
Model size
67M params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for faikidine/distilbert-book-genre-multilabel

Finetuned
(12789)
this model