Analytics: Retention Strength

RNN Gradient Flow
LSTM Gradient Flow

Decides how much of Ct-1 to keep.

Decides what new info to store in Ct.

Filters the output ht from Ct.

Word-to-Vector Pipeline

Waiting for input...

Final Prediction

Negative 0.00 Positive

Word Influence Heatmap

Click any word to see its contribution

📝 Key Insight: Word order matters in sentiment analysis. The word "not" before "good" flips the sentiment entirely. LSTMs handle this through their gating mechanism, while RNNs struggle to maintain context over longer distances.

Hyperparameters

Experiment Setup

  • Vocab Size: 10,000
  • Embed Dim: 256
  • RNN Units: 256
  • LSTM Units: 64

RNN

Gradient Magnitude

Confusion Matrix

LSTM

Gradient Magnitude

Confusion Matrix

📝 Key Insight: The RNN's gradient bars shrink over epochs (vanishing gradient), causing its validation accuracy to plateau around 79%. The LSTM maintains stable gradients through its cell state highway, converging smoothly to ~87% validation accuracy.

Word Attribution — Sentence A

LSTM Cell State Magnitude


Compare Mode — Sentence B

LSTM Cell State Magnitude — Sentence B

📝 Key Insight: RNNs assign strong influence to recent sentiment words but weak influence to early context. LSTMs distribute influence more evenly, allowing context words to shape the cell state over time. Compare sentences A and B to see how word order changes attribution.

📊 Accuracy Comparison

Metric RNN LSTM
Train Accuracy 0% 0%
Val Accuracy 0% 0%
Test Accuracy 0% 0%

📈 Accuracy Bar Chart

📉 ROC Curve

📉 Precision-Recall Curve

🎯 F1 Score Comparison

RNN
78.5%
LSTM
84.2%
🔑 Key Takeaways:
  • LSTM handles long-term dependencies significantly better than RNN.
  • RNN suffers from vanishing gradient, limiting its learning capacity.
  • LSTM generalizes better — higher validation and test performance.
  • Despite using only 64 units vs RNN's 256, LSTM outperforms across all metrics.