This project demonstrates how to perform multi-label text classification using Hugging Face Transformers and Fastai. It involves training a deep learning model to predict multiple genre labels for a given text description.
- Web scraping using Selenium Webdriver.
- Scaping over 55k data from Royal Road, a popular website for fan made stories/fictions.
- Utilizes the power of pre-trained transformer models from Hugging Face Transformers.
- Implements multi-label classification using Fastai's powerful text processing capabilities.
- Analyzes model performance using various metrics such as F1 score, ROC AUC score, and confusion matrix.
- Provides code snippets and explanations for data preprocessing, model training, and evaluation.
git clone https://github.com/2mdipro7/story-genre-classifier.gitFirst, run url_scraper.py to retrieve the URLs of the files to be scraped.
python url_scraper.pyThen, run description_scraper.py to gather detailed information from the retrieved URLs.
python description_scraper.pyIn this project, we harnessed the power of pre-trained transformer models from Hugging Face Transformers to elevate our text classification capabilities. By tapping into these models, we gained access to their extensive knowledge of language and context, allowing us to achieve impressive results in genre classification.
For this project, we selected the bert-base-uncased architecture, a well-established variant of BERT that's specifically designed for uncased text. By making this strategic choice, we enabled our model to comprehend the subtleties of language usage, leading to enhanced accuracy and performance in genre classification.
Our journey is documented in the model_training.ipynb notebook, where we documented each step of the training process. From preprocessing our data to configuring the model, defining the loss function, selecting optimization strategies, and monitoring training progress, the notebook serves as a comprehensive guide to our approach.
Here is how our model performed after training for 7 epochs:
| Metric | Score |
|---|---|
| Accuracy Multi | 0.87 |
| F1 (Micro) | 0.65 |
| F1 (Macro) | 0.52 |
| ROC AUC (Micro) | 0.77 |
| ROC AUX (Macro) | 0.71 |
Refer to the model_evaluation.ipynb notebook for detailed instructions.
Convert your trained model to the ONNX format for deployment using the convert_to_onnx.ipynb notebook.
The model is deployed and accessible on Hugging Face's Model Hub. You can use it for inference and predictions by visiting the following link:
Story Genre Classifier - Hugging Face Model
Additionally, the model is deployed and hosted on Render, allowing you to interact with it via a web interface. You can access the deployed model using the following link:
Story Genre Classifier - Render Web Interface
Contributions are welcome! If you find any issues, have suggestions for enhancements, or want to contribute new features, feel free to submit pull requests or raise issues in the repository.
This project is licensed under the MIT License. See LICENSE for more details.
This project is inspired by the capabilities of Hugging Face Transformers and the ease of use provided by Fastai. Special thanks to the open-source community for their valuable contributions.
Feel free to explore the repository, experiment with the model, and contribute to make it even better. If you have any questions or need assistance, please don't hesitate to reach out. Happy coding!