hrnrxb commited on
Commit
de3803d
·
verified ·
1 Parent(s): f79dfdb

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +59 -1
README.md CHANGED
@@ -1 +1,59 @@
1
- roberta-bilstm-attention-sentiment model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🤖 Sentiment Classifier with Sarcasm Detection
2
+
3
+ This model combines `roberta-base` embeddings with a BiLSTM layer and attention mechanism to classify the **sentiment of movie reviews**, even when the language includes sarcasm, irony, or mixed emotional signals.
4
+
5
+ ## 🧩 Architecture
6
+
7
+ - **Base Encoder:** RoBERTa (frozen)
8
+ - **Sequence Modeling:** Bidirectional LSTM (BiLSTM)
9
+ - **Attention Layer:** Learnable scalar attention weights
10
+ - **Classifier:** Fully connected + Softmax
11
+
12
+ This model takes the output of RoBERTa, processes it through a BiLSTM, applies attention to focus on important parts of the sentence, and classifies sentiment as **Positive (1)** or **Negative (0)**.
13
+
14
+ ## 💡 Why this model?
15
+
16
+ Standard BERT-based sentiment classifiers often fail on subtle language such as:
17
+
18
+ - *"If I had a dollar for every cliché in this film, I’d be rich."* → sarcastic → **Negative**
19
+ - *"It’s fine. Just fine. Totally… fine."* → sarcastic tone → **Negative**
20
+ - *"The visuals were stunning, but the plot was as dead as a doorknob."* → contrast → **Negative**
21
+
22
+ This model aims to address that by combining contextual language modeling (RoBERTa) with sequence learning (BiLSTM) and attention-based interpretability.
23
+
24
+ ## 📊 Training Details
25
+
26
+ - **Dataset:** IMDB (2-class, 25k reviews)
27
+ - **Training Subset:** 2,000 samples for prototype
28
+ - **Loss:** CrossEntropyLoss
29
+ - **Optimizer:** Adam
30
+ - **Epochs:** 3
31
+ - **Hardware:** Google Colab (T4 GPU)
32
+ - **Additional Inputs:** Custom sarcastic and ambiguous examples
33
+
34
+ ## 🧪 Example Inputs
35
+
36
+ | Input | Prediction |
37
+ |-------|------------|
38
+ | "If I had a dollar for every cliché..." | 🔴 Negative |
39
+ | "It’s fine. Just fine. Totally fine." | 🔴 Negative |
40
+ | "The acting was great, but the plot..." | 🔴 Negative |
41
+ | "Brilliant visuals and solid pacing." | 🟢 Positive |
42
+
43
+ ## 🚀 How to Use
44
+
45
+ ```python
46
+ from transformers import RobertaTokenizer
47
+ from my_model import RobertaBiLSTMAttention # Your custom model
48
+ import torch
49
+
50
+ tokenizer = RobertaTokenizer.from_pretrained("roberta-base")
51
+ model = RobertaBiLSTMAttention()
52
+ model.load_state_dict(torch.load("pytorch_model.bin"))
53
+ model.eval()
54
+
55
+ text = "It’s fine. Just fine. Totally… fine."
56
+ tokens = tokenizer(text, return_tensors="pt", padding="max_length", truncation=True, max_length=128)
57
+ logits = model(tokens["input_ids"], tokens["attention_mask"])
58
+ pred = torch.argmax(logits, dim=1).item()
59
+ print("Sentiment:", "Positive" if pred == 1 else "Negative")