lanretto commited on
Commit
b6b48db
·
verified ·
1 Parent(s): 61a1e76

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: mit
4
+ library_name: pytorch
5
+ tags:
6
+ - shakespeare
7
+ - text-classification
8
+ - bert
9
+ - pytorch
10
+ - nlp
11
+ datasets:
12
+ - lanretto/shakespeare-vs-modern-dialogue
13
+ ---
14
+
15
+ # 🎭 Shakespeare Authenticator - PyTorch Implementation
16
+
17
+ ## Model Description
18
+
19
+ 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.
20
+
21
+ ## Model Performance
22
+
23
+ | Metric | Value |
24
+ |--------|-------|
25
+ | **Accuracy** | 0.9835 |
26
+ | **F1-Score** | 0.9685 |
27
+ | **Test Samples** | 40,626 |
28
+ | **Avg Confidence** | 0.9938 |
29
+
30
+ ### Comparison with Original Implementation
31
+
32
+ | Model | Accuracy | F1-Score |
33
+ |-------|----------|----------|
34
+ | Original (HF Trainer) | 0.9820 | 0.9658 |
35
+ | **PyTorch Manual** | **0.9835** | **0.9685** |
36
+
37
+ ## Training Details
38
+
39
+ - **Architecture**: BERT-base + Custom Classification Head
40
+ - **Training Approach**: Manual PyTorch training loop
41
+ - **Learning Rates**: BERT (2e-5), Classifier (1e-4)
42
+ - **Epochs**: 3
43
+ - **Batch Size**: 128
44
+ - **Best Epoch**: 3
45
+ - **Best Validation Accuracy**: 0.9849
46
+
47
+ ## Model Architecture
48
+
49
+ ```python
50
+ class ShakespeareClassifier(nn.Module):
51
+ def __init__(self, bert_model, num_classes=2, dropout_rate=0.1):
52
+ super().__init__()
53
+ self.bert = bert_model
54
+ self.dropout = nn.Dropout(dropout_rate)
55
+ self.classifier = nn.Linear(768, num_classes)
56
+
57
+ def forward(self, input_ids, attention_mask):
58
+ outputs = self.bert(input_ids=input_ids, attention_mask=attention_mask)
59
+ pooled_output = outputs.pooler_output
60
+ x = self.dropout(pooled_output)
61
+ logits = self.classifier(x)
62
+ return logits
63
+ ```
config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bert_model_name": "bert-base-uncased",
3
+ "hidden_size": 768,
4
+ "num_labels": 2,
5
+ "id2label": {
6
+ "0": "Modern Creation",
7
+ "1": "Authentic Shakespeare"
8
+ },
9
+ "label2id": {
10
+ "Modern Creation": 0,
11
+ "Authentic Shakespeare": 1
12
+ },
13
+ "architecture": "BertForSequenceClassification",
14
+ "pytorch_version": "2.9.1+cu128",
15
+ "transformers_version": "4.57.3"
16
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4e08d518fc143d0fa1facb505a0b378d7f8c341f568a463d132650ff5cb113b2
3
+ size 438018375
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": false,
45
+ "cls_token": "[CLS]",
46
+ "do_lower_case": true,
47
+ "extra_special_tokens": {},
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 512,
50
+ "pad_token": "[PAD]",
51
+ "sep_token": "[SEP]",
52
+ "strip_accents": null,
53
+ "tokenize_chinese_chars": true,
54
+ "tokenizer_class": "BertTokenizer",
55
+ "unk_token": "[UNK]"
56
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff