stanfordnlp/imdb
Viewer • Updated • 100k • 188k • 389
How to use radwa-f/LSTM-IMDB-SentimentAnalysis with Keras:
# Available backend options are: "jax", "torch", "tensorflow".
import os
os.environ["KERAS_BACKEND"] = "jax"
import keras
model = keras.saving.load_model("hf://radwa-f/LSTM-IMDB-SentimentAnalysis")
Traditional LSTM model for binary sentiment classification achieving 89% accuracy on IMDB movie reviews.
This model serves as a baseline in a comparative study demonstrating the superiority of transfer learning (DeBERTa: 96%) over traditional approaches.
import pickle
from tensorflow import keras
from huggingface_hub import hf_hub_download
# Download
model_path = hf_hub_download("radwa-f/LSTM-IMDB-SentimentAnalysis", "model.h5")
tok_path = hf_hub_download("radwa-f/LSTM-IMDB-SentimentAnalysis", "tokenizer.pkl")
# Load
model = keras.models.load_model(model_path)
with open(tok_path, 'rb') as f:
tokenizer = pickle.load(f)
# Predict
text = "This movie was amazing!"
seq = tokenizer.texts_to_sequences([text])
padded = keras.preprocessing.sequence.pad_sequences(seq, maxlen=200)
pred = model.predict(padded)[0][0]
print(f"{'POSITIVE' if pred > 0.5 else 'NEGATIVE'} ({pred:.2%})")
| Model | Accuracy | Type |
|---|---|---|
| LSTM (this) | 89% | Traditional RNN |
| DeBERTa | 96% | Transfer Learning |
| Difference | -7% |
Embedding(vocab_size, 128)
LSTM(128)
Dense(64, relu)
Dropout(0.5)
Dense(1, sigmoid)
Radwa Fattouhi
Amine Boktaya
If you use this model in your research, please cite:
@misc{fattouhi2025imdb,
author = {Fattouhi, Radwa and Boktaya, Amine},
title = {LSTM IMDB Sentiment Analysis: Transfer Learning vs Traditional Approaches},
year = {2025},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/radwa-f/DeBERTA-Imdb-SentimentAnalysis}}
howpublished = {\url{https://huggingface.co/radwa-f/LSTM-IMDB-SentimentAnalysis}}
}
Published Research:
Related Projects:
Radwa Fattouhi - ENSA El Jadida, Morocco