lanretto/shakespeare-vs-modern-dialogue
Viewer β’ Updated β’ 406k β’ 4 β’ 1
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.
| Metric | Value |
|---|---|
| Accuracy | 0.9835 |
| F1-Score | 0.9685 |
| Test Samples | 40,626 |
| Avg Confidence | 0.9938 |
| Model | Accuracy | F1-Score |
|---|---|---|
| Original (HF Trainer) | 0.9820 | 0.9658 |
| PyTorch Manual | 0.9835 | 0.9685 |
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