π Shakespeare Authenticator - PyTorch Implementation
Model Description
This is a PyTorch manual implementation of the Shakespeare Authenticator model, distinguishing between authentic Shakespearean text and modern writing. This model was built from scratch using raw PyTorch (without Hugging Face Trainer) for educational purposes.
Model Performance
| Metric |
Value |
| Accuracy |
0.9835 |
| F1-Score |
0.9685 |
| Test Samples |
40,626 |
| Avg Confidence |
0.9938 |
Comparison with Original Implementation
| Model |
Accuracy |
F1-Score |
| Original (HF Trainer) |
0.9820 |
0.9658 |
| PyTorch Manual |
0.9835 |
0.9685 |
Training Details
- Architecture: BERT-base + Custom Classification Head
- Training Approach: Manual PyTorch training loop
- Learning Rates: BERT (2e-5), Classifier (1e-4)
- Epochs: 3
- Batch Size: 128
- Best Epoch: 3
- Best Validation Accuracy: 0.9849
Model Architecture
class ShakespeareClassifier(nn.Module):
def __init__(self, bert_model, num_classes=2, dropout_rate=0.1):
super().__init__()
self.bert = bert_model
self.dropout = nn.Dropout(dropout_rate)
self.classifier = nn.Linear(768, num_classes)
def forward(self, input_ids, attention_mask):
outputs = self.bert(input_ids=input_ids, attention_mask=attention_mask)
pooled_output = outputs.pooler_output
x = self.dropout(pooled_output)
logits = self.classifier(x)
return logits