Downloads · 30 days
0
hrnrxb/roberta-bilstm-attention-sentiment
roberta-bilstm-attention-sentiment is a text classification model from hrnrxb. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as apache-2.0.
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.
Downloads · 30 days
0
Access
Public
Updated Jun 6, 2026
Parameters
126M
1 GB on disk
Likes
1
Public
Click a slice to open those files.
.bin502 MB · 50%
From the Hugging Face model README
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.
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).
Standard BERT-based sentiment classifiers often fail on subtle language such as:
This model aims to address that by combining contextual language modeling (RoBERTa) with sequence learning (BiLSTM) and attention-based interpretability.
| Input | Prediction |
|---|---|
| "If I had a dollar for every cliché..." | 🔴 Negative |
| "It’s fine. Just fine. Totally fine." | 🔴 Negative |
| "The acting was great, but the plot..." | 🔴 Negative |
| "Brilliant visuals and solid pacing." | 🟢 Positive |
from transformers import RobertaTokenizer
from my_model import RobertaBiLSTMAttention # the custom model
import torch
tokenizer = RobertaTokenizer.from_pretrained("roberta-base")
model = RobertaBiLSTMAttention()
model.load_state_dict(torch.load("pytorch_model.bin"))
model.eval()
text = "It’s fine. Just fine. Totally… fine."
tokens = tokenizer(text, return_tensors="pt", padding="max_length", truncation=True, max_length=128)
logits = model(tokens["input_ids"], tokens["attention_mask"])
pred = torch.argmax(logits, dim=1).item()
print("Sentiment:", "Positive" if pred == 1 else "Negative")