Update README.md
Browse files
README.md
CHANGED
|
@@ -16,78 +16,176 @@ tags: []
|
|
| 16 |
<!-- Provide a longer summary of what this model is. -->
|
| 17 |
|
| 18 |
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
- **
|
| 33 |
-
- **
|
| 34 |
-
- **
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
##
|
| 37 |
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
### Direct Use
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
|
|
|
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
|
|
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
### Out-of-Scope Use
|
| 53 |
|
| 54 |
-
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
## Bias, Risks, and Limitations
|
| 59 |
|
| 60 |
-
|
| 61 |
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
### Recommendations
|
| 65 |
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
|
|
|
|
|
|
|
| 69 |
|
| 70 |
## How to Get Started with the Model
|
| 71 |
|
| 72 |
Use the code below to get started with the model.
|
| 73 |
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
## Training Details
|
| 77 |
|
| 78 |
### Training Data
|
| 79 |
|
| 80 |
-
|
| 81 |
|
| 82 |
-
|
|
|
|
|
|
|
| 83 |
|
|
|
|
|
|
|
|
|
|
| 84 |
### Training Procedure
|
| 85 |
|
| 86 |
-
|
|
|
|
| 87 |
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
[More Information Needed]
|
| 91 |
|
| 92 |
|
| 93 |
#### Training Hyperparameters
|
|
@@ -102,8 +200,26 @@ Use the code below to get started with the model.
|
|
| 102 |
|
| 103 |
## Evaluation
|
| 104 |
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
|
|
|
| 107 |
### Testing Data, Factors & Metrics
|
| 108 |
|
| 109 |
#### Testing Data
|
|
|
|
| 16 |
<!-- Provide a longer summary of what this model is. -->
|
| 17 |
|
| 18 |
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
| 19 |
+
---
|
| 20 |
+
language:
|
| 21 |
+
- en
|
| 22 |
+
tags:
|
| 23 |
+
- text-classification
|
| 24 |
+
- shakespeare
|
| 25 |
+
- nlp
|
| 26 |
+
- bert
|
| 27 |
+
- transformers
|
| 28 |
+
- literary-analysis
|
| 29 |
+
pipeline_tag: text-classification
|
| 30 |
+
widget:
|
| 31 |
+
- text: "To be or not to be, that is the question"
|
| 32 |
+
example_title: "Hamlet"
|
| 33 |
+
- text: "Friends, Romans, countrymen, lend me your ears"
|
| 34 |
+
example_title: "Julius Caesar"
|
| 35 |
+
- text: "The meeting is scheduled for 2 PM tomorrow"
|
| 36 |
+
example_title: "Modern Text"
|
| 37 |
+
---
|
| 38 |
|
| 39 |
+
# Shakespeare Authenticator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
## Model Description
|
| 42 |
|
| 43 |
+
A BERT-based model fine-tuned to distinguish authentic Shakespearean text from modern imitations and synthetic Shakespearean-style writing.
|
| 44 |
|
| 45 |
+
- **Developed by:** Lanre Moluga
|
| 46 |
+
- **Model type:** BERT for Sequence Classification
|
| 47 |
+
- **Language(s):** English (Early Modern English & Contemporary English)
|
| 48 |
+
- **License:** MIT
|
| 49 |
+
- **Finetuned from model:** `bert-base-uncased`
|
| 50 |
+
- **Repository:** [GitHub Repository Link - Optional]
|
| 51 |
|
| 52 |
+
## Model Sources
|
| 53 |
|
| 54 |
+
- **Repository:** [Your GitHub repo if available]
|
| 55 |
+
- **Demo:** [https://huggingface.co/spaces/lanretto/shakespeare-authenticator]
|
| 56 |
+
|
| 57 |
+
## Uses
|
| 58 |
|
| 59 |
### Direct Use
|
| 60 |
|
| 61 |
+
This model is designed for binary text classification to determine whether a given text sample is authentic Shakespearean writing or a modern creation/imitation.
|
| 62 |
|
| 63 |
+
```python
|
| 64 |
+
from transformers import pipeline
|
| 65 |
|
| 66 |
+
classifier = pipeline("text-classification", model="lanretto/shakespeare-authenticator")
|
| 67 |
+
result = classifier("To be or not to be, that is the question")
|
| 68 |
+
print(result)
|
| 69 |
|
| 70 |
+
Downstream Use [optional]
|
| 71 |
+
Literary analysis and research tools
|
| 72 |
|
| 73 |
+
Educational applications for Shakespeare studies
|
| 74 |
+
|
| 75 |
+
Content moderation for Shakespearean text databases
|
| 76 |
+
|
| 77 |
+
Style transfer evaluation
|
| 78 |
+
|
| 79 |
+
Digital humanities research
|
| 80 |
|
| 81 |
### Out-of-Scope Use
|
| 82 |
|
| 83 |
+
Classification of non-English text
|
| 84 |
|
| 85 |
+
Professional literary authentication without human verification
|
| 86 |
+
|
| 87 |
+
Legal or academic authentication purposes
|
| 88 |
+
|
| 89 |
+
Texts from other historical periods or authors
|
| 90 |
|
| 91 |
## Bias, Risks, and Limitations
|
| 92 |
|
| 93 |
+
Temporal Bias: Model is trained specifically on Shakespearean vs modern text, not other historical periods
|
| 94 |
|
| 95 |
+
Style Limitations: May misclassify high-quality modern Shakespearean imitations
|
| 96 |
+
|
| 97 |
+
Length Sensitivity: Performance may vary with very short text fragments
|
| 98 |
+
|
| 99 |
+
Genre Limitations: Primarily trained on dramatic dialogue, may perform differently on poetry or prose
|
| 100 |
+
|
| 101 |
+
Cultural Context: Limited to English language and Western literary traditions
|
| 102 |
|
| 103 |
### Recommendations
|
| 104 |
|
| 105 |
+
Users should:
|
| 106 |
+
|
| 107 |
+
Verify critical classifications with human experts
|
| 108 |
+
|
| 109 |
+
Use longer text samples for more reliable predictions
|
| 110 |
|
| 111 |
+
Consider the model as a supplementary tool rather than definitive authentication
|
| 112 |
+
|
| 113 |
+
Be aware of potential false positives with sophisticated modern imitations
|
| 114 |
|
| 115 |
## How to Get Started with the Model
|
| 116 |
|
| 117 |
Use the code below to get started with the model.
|
| 118 |
|
| 119 |
+
# Install required packages
|
| 120 |
+
# pip install transformers torch
|
| 121 |
+
|
| 122 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 123 |
+
import torch
|
| 124 |
+
|
| 125 |
+
# Load model and tokenizer
|
| 126 |
+
model_name = "lanretto/shakespeare-authenticator"
|
| 127 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 128 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 129 |
+
|
| 130 |
+
# Example prediction
|
| 131 |
+
text = "Shall I compare thee to a summer's day?"
|
| 132 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
|
| 133 |
+
|
| 134 |
+
with torch.no_grad():
|
| 135 |
+
outputs = model(**inputs)
|
| 136 |
+
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
| 137 |
+
predicted_class = torch.argmax(predictions, dim=-1).item()
|
| 138 |
+
|
| 139 |
+
labels = {0: "Modern Creation", 1: "Authentic Shakespeare"}
|
| 140 |
+
print(f"Prediction: {labels[predicted_class]}")
|
| 141 |
+
print(f"Confidence: {predictions[0][predicted_class]:.2%}")
|
| 142 |
|
| 143 |
## Training Details
|
| 144 |
|
| 145 |
### Training Data
|
| 146 |
|
| 147 |
+
Total Samples: ~400,000 text samples
|
| 148 |
|
| 149 |
+
Authentic Shakespeare: ~108,000 lines from Shakespearean plays
|
| 150 |
+
|
| 151 |
+
Modern Dialogue: ~300,000 lines from modern movie scripts
|
| 152 |
|
| 153 |
+
Train/Validation/Test Split: 80%/10%/10%
|
| 154 |
+
|
| 155 |
+
Class Distribution: ~26% Shakespeare, ~74% Modern
|
| 156 |
### Training Procedure
|
| 157 |
|
| 158 |
+
Preprocessing
|
| 159 |
+
Text normalization and cleaning
|
| 160 |
|
| 161 |
+
Tokenization using BERT tokenizer (bert-base-uncased)
|
| 162 |
+
|
| 163 |
+
Maximum sequence length: 512 tokens
|
| 164 |
+
|
| 165 |
+
Dynamic padding during training
|
| 166 |
+
|
| 167 |
+
Training Hyperparameters
|
| 168 |
+
Training regime: Mixed precision training
|
| 169 |
+
|
| 170 |
+
Optimizer: AdamW
|
| 171 |
+
|
| 172 |
+
Learning Rate: 2e-5
|
| 173 |
+
|
| 174 |
+
Batch Size: 128 (with gradient accumulation)
|
| 175 |
+
|
| 176 |
+
Epochs: 3
|
| 177 |
+
|
| 178 |
+
Weight Decay: 0.01
|
| 179 |
+
|
| 180 |
+
Warmup Ratio: 0.1
|
| 181 |
+
|
| 182 |
+
Speeds, Sizes, Times
|
| 183 |
+
Model Size: 438 MB
|
| 184 |
+
|
| 185 |
+
Training Time: ~2 hours on 1x Tesla T4 GPU
|
| 186 |
+
|
| 187 |
+
Inference Speed: ~100 samples/second on CPU
|
| 188 |
|
|
|
|
| 189 |
|
| 190 |
|
| 191 |
#### Training Hyperparameters
|
|
|
|
| 200 |
|
| 201 |
## Evaluation
|
| 202 |
|
| 203 |
+
Testing Data & Metrics
|
| 204 |
+
Testing Data
|
| 205 |
+
Test Set Size: ~40,000 samples
|
| 206 |
+
|
| 207 |
+
Class Distribution: Representative of training distribution
|
| 208 |
+
|
| 209 |
+
Data Source: Held-out from original dataset
|
| 210 |
+
|
| 211 |
+
Metrics
|
| 212 |
+
Accuracy: 84.7%
|
| 213 |
+
|
| 214 |
+
F1 Score: 0.8928
|
| 215 |
+
|
| 216 |
+
Precision (Shakespeare): 0.8619
|
| 217 |
+
|
| 218 |
+
Recall (Shakespeare): 0.8300
|
| 219 |
+
|
| 220 |
+
Precision (Modern): 0.8321
|
| 221 |
|
| 222 |
+
Recall (Modern): 0.8642
|
| 223 |
### Testing Data, Factors & Metrics
|
| 224 |
|
| 225 |
#### Testing Data
|