|
|
--- |
|
|
library_name: transformers |
|
|
tags: |
|
|
- text-style-transfer |
|
|
license: apache-2.0 |
|
|
datasets: |
|
|
- GuillermoTBB/charles-dickens-text-classification |
|
|
language: |
|
|
- en |
|
|
metrics: |
|
|
- accuracy |
|
|
base_model: distilbert/distilbert-base-uncased |
|
|
pipeline_tag: text-classification |
|
|
--- |
|
|
|
|
|
# Model Card for Model ID |
|
|
|
|
|
**Charles Dickens Text Classifier** |
|
|
|
|
|
This model is a text classification model fine-tuned on a dataset designed to distinguish between paragraphs written by Charles Dickens and those that imitate his style. The model uses `distilbert-base-uncased` as the base model and has been fine-tuned on 1,100 samples with 100 positive and 1,000 negative examples, achieving an accuracy of 99.5%. |
|
|
|
|
|
## Model Details |
|
|
|
|
|
### Model Description |
|
|
|
|
|
This is a text classification model developed to classify text as either written by Charles Dickens or generated in different styles. It is built using the `distilbert-base-uncased` model from the Hugging Face Transformers library and fine-tuned on a dataset specifically designed for this task. |
|
|
|
|
|
- **Developed by:** Independent ML Engineer |
|
|
- **Model type:** Text Classification |
|
|
- **Language(s) (NLP):** English (en) |
|
|
- **License:** Apache-2.0 |
|
|
- **Finetuned from model:** `distilbert/distilbert-base-uncased` |
|
|
|
|
|
### Model Sources |
|
|
|
|
|
- **Generation Script**: [this colab](https://colab.research.google.com/drive/1Cvx_UpaBWJFQZvLsRk5LdPPRugNVo8gn) |
|
|
- **Example usage**: [this colab to validate methods of text-style-transfer](https://colab.research.google.com/drive/1haZ8xlraV76a3Ld3tpVtIwxMP8nemkKl) |
|
|
|
|
|
## Uses |
|
|
|
|
|
### Direct Use |
|
|
|
|
|
This model can be directly used for distinguishing between authentic Charles Dickens texts and texts generated in various imitative styles. It can be used for literary analysis, text style transfer evaluation, and educational purposes. |
|
|
|
|
|
### Out-of-Scope Use |
|
|
|
|
|
This model is not suitable for general text classification tasks outside of the scope of identifying Charles Dickens' writing style. Misuse of the model might include applying it to texts outside of the intended use case or in a context where the stylistic nuances of Dickens' writing are not relevant. |
|
|
|
|
|
## Bias, Risks, and Limitations |
|
|
|
|
|
The model may have biases related to the synthetic nature of the negative examples, which might not fully capture the diversity of non-Dickensian writing styles. The dataset is based only on "Great Expectations" and might not generalize well to other works by Dickens or other authors. |
|
|
|
|
|
### Recommendations |
|
|
|
|
|
Users should be aware of the synthetic nature of the negative samples, which might limit the model's generalizability. It is recommended to expand the dataset to include more works by Dickens for a more robust classification. |
|
|
|
|
|
## How to Get Started with the Model |
|
|
|
|
|
To use this model, load it using the Hugging Face Transformers library: |
|
|
|
|
|
```python |
|
|
from transformers import pipeline |
|
|
|
|
|
classifier = pipeline("text-classification", model="GuillermoTBB/charles-dickens-classifier", tokenizer="GuillermoTBB/charles-dickens-classifier") |
|
|
|
|
|
text = "Your text here..." |
|
|
result = classifier(text) |
|
|
print(result) |
|
|
``` |
|
|
|
|
|
An example to use this model can be found in [this colab](https://colab.research.google.com/drive/1haZ8xlraV76a3Ld3tpVtIwxMP8nemkKl) used to validate different methods to transfer text style. |
|
|
|
|
|
## Training Details |
|
|
|
|
|
### Training Data |
|
|
|
|
|
The model was trained on a dataset composed of 1,100 paragraphs, where 100 were original excerpts from "Great Expectations" by Charles Dickens and 1,000 were synthetic examples generated by rewriting the Dickensian paragraphs in 10 distinct styles using GPT-4. |
|
|
Dataset can be found [HF GuillermoTBB/charles-dickens-text-classification](https://huggingface.co/datasets/GuillermoTBB/charles-dickens-text-classification) |
|
|
|
|
|
### Training Procedure |
|
|
|
|
|
The model was fine-tuned using the following hyperparameters: |
|
|
- **Training regime:** Mixed precision (fp16) on a single T4 GPU |
|
|
- **Learning rate:** 2e-5 |
|
|
- **Batch size:** 16 |
|
|
- **Epochs:** 2 |
|
|
- **Optimizer:** AdamW |
|
|
- **Weight decay:** 0.01 |
|
|
|
|
|
## Evaluation |
|
|
|
|
|
### Testing Data, Factors & Metrics |
|
|
|
|
|
#### Testing Data |
|
|
|
|
|
The test set consisted of 220 samples, stratified to maintain a balanced class distribution. |
|
|
|
|
|
#### Metrics |
|
|
|
|
|
The primary evaluation metric was accuracy, which is ideal for binary classification tasks. The model achieved a test accuracy of 99.5%. |
|
|
|
|
|
### Results |
|
|
|
|
|
The model performed exceptionally well on the test set with an accuracy of 99.5%, demonstrating its effectiveness in distinguishing between Dickensian and non-Dickensian text. |
|
|
|
|
|
|
|
|
## Technical Specifications |
|
|
|
|
|
### Model Architecture and Objective |
|
|
|
|
|
The model is based on the `distilbert-base-uncased` architecture, fine-tuned to perform binary text classification. |
|
|
|
|
|
### Compute Infrastructure |
|
|
|
|
|
- **Hardware:** Google Colab with a T4 GPU |
|
|
- **Software:** Python 3.7, PyTorch 1.7, Hugging Face Transformers 4.5 |
|
|
|
|
|
## Citation |
|
|
|
|
|
Please cite the following if you use this model: |
|
|
|
|
|
**BibTeX:** |
|
|
|
|
|
```bibtex |
|
|
@misc{guillermo2024charlesdickens, |
|
|
title={Charles Dickens Text Classifier}, |
|
|
author={Guillermo Blasco}, |
|
|
year={2024}, |
|
|
howpublished={\url{https://huggingface.co/GuillermoTBB/charles-dickens-classifier}}, |
|
|
} |
|
|
|
|
|
**APA:** |
|
|
|
|
|
Blasco, G. (2024). Charles Dickens Text Classifier. Retrieved from https://huggingface.co/GuillermoTBB/charles-dickens-classifier. |
|
|
|
|
|
## Model Card Authors |
|
|
|
|
|
- Guillermo Blasco, Independent ML Engineer |