Rashmii30/distilbert-goodreads-genres
Model
DistilBERT Book Genre Classifier
A transformer-based model fine-tuned to classify Goodreads reviews into eight distinct genres.
Key Features Model: DistilBERT (Transformer-based) Dataset: Goodreads book reviews Output: 8 genre categories Task: Multi-class text classification
Model Description
This model is a specialized text classification tool designed to bridge the gap between subjective reader feedback and structured metadata. By fine-tuning the DistilBERT architecture a lighter, faster version of the original BERT model—this classifier can interpret the nuance, tone, and vocabulary used in Goodreads reviews to predict a book's genre. Unlike traditional keyword matching, this model uses deep learning to understand the context of a review. It can distinguish between the "thrilling" elements of a mystery and the "breathless" excitement found in a romance. This makes it an ideal solution for organizing large digital libraries, enhancing recommendation engines, or helping authors understand how their work is being perceived by specific audiences.
Supported Genres
The model categorizes reviews into the following eight
Label Genre 0 Children 1 Comics & Graphic 2 Fantasy & Paranormal 3 History & Biography 4 Mystery, Thriller & Crime 5 Poetry 6 Romance 7 Young Adult
Training Configuration
Training Results
Final Evaluation Metrics
Installation
Install the required libraries:
pip install transformers torchQuick Inference
Use the Hugging Face pipeline API:
from huggingface_hub import login
# Login to HuggingFace using token from Kaggle Secrets
login(token=HF_TOKEN)
print("Logged in to HuggingFace!")
HF_USERNAME = "Rashmii30"
REPO_NAME = "distilbert-goodreads-genres"
HF_REPO = f"{HF_USERNAME}/{REPO_NAME}"
# Push model weights to HuggingFace Hub
print("Pushing model to HuggingFace Hub...")
model.push_to_hub(HF_REPO)
print("Model pushed successfully!")
# Push tokenizer to same repository
print("Pushing tokenizer to HuggingFace Hub...")
tokenizer.push_to_hub(HF_REPO)
print("Tokenizer pushed successfully!")
# Log the HuggingFace URL to W&B run summary
wandb.run.summary["huggingface_model"] = f"https://huggingface.co/{HF_REPO}"
print(f"HuggingFace model URL logged to W&B!")
print(f"Your model is live at: https://huggingface.co/{HF_REPO}")Dataset
The model was trained using the UCSD Book Graph / Goodreads Reviews Dataset, which contains large-scale Goodreads book reviews across multiple genres.
8 genres were selected
2,000 reviews sampled per genre
Stratified train-test split:
800 training samples per genre 200 test samples per genre
Project Highlights
Fine-tuned transformer-based NLP classifier GPU training on Kaggle Experiment tracking using Weights & Biases Hugging Face model deployment Reproducible MLOps workflow
Technologies Used
Python PyTorch Hugging Face Transformers Dataset Weights & Biases Kaggle Notebooks
Author
Name: Rashmi Kumari Roll Number: G25AIT2083
Model Repository
Hugging Face Model Repository
