ByteMeHarder-404 commited on
Commit
70879f7
·
verified ·
1 Parent(s): 9c4e6c0

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +95 -0
README.md ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ library_name: transformers
5
+ tags:
6
+ - ensemble
7
+ - text-classification
8
+ - sentiment-analysis
9
+ - imdb
10
+ license: apache-2.0
11
+ datasets:
12
+ - imdb
13
+ metrics:
14
+ - accuracy
15
+ - f1
16
+ pipeline_tag: text-classification
17
+ base_model:
18
+ - bert-base-uncased
19
+ model-index:
20
+ - name: BERT IMDb Ensemble for Sentiment Analysis
21
+ results:
22
+ - task:
23
+ type: text-classification
24
+ name: Sentiment Classification
25
+ dataset:
26
+ name: IMDb
27
+ type: imdb
28
+ split: test
29
+ metrics:
30
+ - name: Accuracy
31
+ type: accuracy
32
+ value: 0.939
33
+ - name: F1
34
+ type: f1
35
+ value: 0.939
36
+ ---
37
+
38
+ # BERT IMDb Ensemble for Sentiment Analysis 🎬🎭
39
+
40
+ ## Model description
41
+
42
+ This is an **ensemble of 3 BERT-base-uncased models** fine-tuned on the IMDb dataset for **binary sentiment classification** (positive vs. negative reviews).
43
+ Each model was trained with a different random seed, and predictions are combined using weighted or unweighted averaging for more robust performance.
44
+
45
+ - **Base model:** `bert-base-uncased`
46
+ - **Task:** Sentiment classification (binary: 0 = negative, 1 = positive)
47
+ - **Ensembling strategy:** Weighted logits averaging
48
+
49
+ ---
50
+
51
+ ## Training procedure
52
+
53
+ - **Dataset:** IMDb (train/test split from Hugging Face `datasets`)
54
+ - **Preprocessing:**
55
+ - Tokenization with `bert-base-uncased`
56
+ - Truncation at 512 tokens
57
+
58
+ - **Hyperparameters:**
59
+ - Epochs: 2
60
+ - Batch size: 8
61
+ - Optimizer: AdamW (default in `Trainer`)
62
+ - FP16: Enabled
63
+ - Seeds: `[42, 123, 999]`
64
+
65
+ ---
66
+
67
+ ## Evaluation results
68
+
69
+ Across the three models, results are very consistent:
70
+
71
+ | Model (Seed) | Epochs | Val. Accuracy | Val. Macro F1 |
72
+ |--------------|--------|---------------|---------------|
73
+ | 42 | 2 | 93.74% | 0.9374 |
74
+ | 123 | 2 | 93.84% | 0.9383 |
75
+ | 999 | 2 | 93.98% | 0.9398 |
76
+
77
+ **Ensemble performance** (weighted example `[0.2, 0.2, 0.6]`) improves stability and helps reduce variance across seeds.
78
+
79
+ ---
80
+
81
+ ## How to use
82
+
83
+ ```python
84
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
85
+ import torch
86
+
87
+ tokenizer = AutoTokenizer.from_pretrained("ByteMeHarder-404/bert-imdb-ensemble")
88
+ model = AutoModelForSequenceClassification.from_pretrained("ByteMeHarder-404/bert-imdb-ensemble")
89
+
90
+ inputs = tokenizer("This movie was an absolute masterpiece!", return_tensors="pt")
91
+ with torch.no_grad():
92
+ outputs = model(**inputs)
93
+ probs = torch.nn.functional.softmax(outputs.logits, dim=-1)
94
+
95
+ print(probs) # tensor([[0.01, 0.99]]) -> positive sentiment