Views
No views yet
distilbert-base-cased on the UCSD Goodreads book reviews dataset to classify books into 7 distinct genres. It was developed as part of an MLOps assignment for IIT Jodhpur.DistilBERT)distilbert-base-casedcomics_graphicfantasy_paranormalhistory_biographymystery_thriller_crimepoetryromanceyoung_adult1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4model_name = "g25ait2004/DistilBERT_Goodreads"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
8review = "The world-building was absolutely breathtaking, full of dark magic, hidden ancient kingdoms, and dragons."
9
10inputs = tokenizer(review, return_tensors="pt", truncation=True, max_length=512)
11with torch.no_grad():
12 outputs = model(**inputs)
13
14probs = torch.nn.functional.softmax(outputs.logits, dim=-1)
15predicted_class_id = outputs.logits.argmax().item()
16
17print(f"Predicted class ID: {predicted_class_id}")
18
19### Downstream Use [optional]
20
21This model is well-suited for integration into digital libraries, book discovery applications, and automated content cataloging pipelines. It can be used as a backend service to automatically tag user-generated reviews with relevant genre nodes or to power downstream recommendation engines based on text sentiment and genre alignment.
22
23### Out-of-Scope Use
24
25* **Non-Review Text Processing:** The model is not intended to classify full-length manuscripts, legal copy, news articles, or technical code repositories.
26* **Multilingual Input:** It was fine-tuned purely on English text reviews; feeding it non-English text will result in highly unreliable performance.
27* **Automated Moderation:** This model should not be used to flag or filter out explicit or harmful text, as its objective is strictly genre classification.
28
29## Bias, Risks, and Limitations
30
31The dataset relies heavily on self-reported, user-generated content from the UCSD Goodreads Graph, introducing self-selection bias and uneven structural syntax in text inputs.
32
33A significant technical limitation observed during evaluation is the model's performance variability across genres. While it exhibits strong predictive power for unique stylistic categories like **poetry (0.79 F1)** and **comics_graphic (0.81 F1)**, it experiences high confusion rates on structurally overlapping genres such as **young_adult (0.28 F1)** and **fantasy_paranormal (0.41 F1)**.
34
35### Recommendations
36
37Direct and downstream users should expect lower classification fidelity when analyzing books targeting young adult or genre-bending fantasy audiences. We recommend using a confidence threshold (e.g., softmax probability greater than 70%) or falling back to a human-in-the-loop validation model for these ambiguous categories.
38
39## How to Get Started with the Model
40
41Use the code below to quickly load the model and its tokenizer for basic inference:
42
43```python
44from transformers import AutoTokenizer, AutoModelForSequenceClassification
45import torch
46
47# Initialize model and tokenizer
48model_name = "g25ait2004/DistilBERT_Goodreads"
49tokenizer = AutoTokenizer.from_pretrained(model_name)
50model = AutoModelForSequenceClassification.from_pretrained(model_name)
51
52# Sample review text
53review_text = "The world-building was absolutely breathtaking, full of dark magic and deep mystery."
54
55# Tokenize and predict
56inputs = tokenizer(review_text, return_tensors="pt", truncation=True, max_length=512)
57with torch.no_grad():
58 outputs = model(**inputs)
59
60# Extract predicted class
61probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)
62predicted_class = outputs.logits.argmax().item()
63print(f"Predicted Class ID: {predicted_class}")
64
65
66**BibTeX:**
67```bibtex
68@inproceedings{sanh2019distilbert,
69 title={DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter},
70 author={Sanh, Victor and Debut, Lysandre and Chaumond, Julien and Wolf, Thomas},
71 booktitle={NeurIPS EMC^2 Workshop},
72 year={2019}
73}
74
75@article{lacoste2019quantifying,
76 title={Quantifying the carbon emissions of machine learning},
77 author={Lacoste, Alexandre and Alexandra, Luccioni and Schmidt, Victor and Dandres, Thomas},
78 journal={arXiv preprint arXiv:1910.09700},
79 year={2019}
80}
81APA:
82
83Sanh, V., Debut, L., Chaumond, J., & Wolf, T. (2019). DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter. NeurIPS EMC^2 Workshop.
84
85Lacoste, A., Alexandra, L., Schmidt, V., & Dandres, T. (2019). Quantifying the carbon emissions of machine learning. arXiv preprint arXiv:1910.09700.
86
87Glossary [optional]
88Distillation: A structural compression mechanism where a smaller student model (DistilBERT) attempts to recreate the output probability distribution vectors of a much bulkier teacher network (BERT-Base).
89
90Macro F1-Score: The unweighted mean of individual F1-scores across all 7 classes. This treats all genre categories equally, regardless of variations in local test support records.
91
92Mixed Precision (fp16): An optimization method where models calculate gradients inside a 16-bit float structure to maximize processing speed and lower memory usage, while storing base weights in 32-bit floats.
93
94More Information [optional]
95This repository belongs to the educational coursework sequences submitted under student assignment benchmarks for the Indian Institute of Technology Jodhpur (IIT Jodhpur) curriculum.
96
97Model Card Authors [optional]
98Er. Abhishek Kumar (M.Tech Data Science & Engineering Track Student)
99
100Model Card Contact
101For development inquiries, pipeline tracking issues, or alternative checkpoint requests, please submit an issue ticket directly inside your active GitHub project dashboard: GitHub Abhishek Repo Management.