NLP · Deep Learning Indonesian Twitter · 11,000 Tweets · Binar Academy 2023 → 2026

ML vs GenAI
Sentiment Analysis

Same dataset. Three approaches. One systematic question: when does BiLSTM beat Gemini Flash? And what does it actually cost to find out?

Dataset 11,000 Indonesian tweets · 3 classes Models TF-IDF+MLP · BiLSTM · Gemini Flash 2.0 Evaluation Accuracy · F1 · Cost · Latency Context Binar Academy final project, revisited 2026
11K
Indonesian tweets
across 3 classes
93%
BiLSTM accuracy
best result
772×
GenAI latency
vs neural network
$0
Annual cost for
BiLSTM vs $62+ GenAI
01 · Business Question

If you're building Indonesian sentiment analysis in 2026, which approach do you actually choose?

GenAI is fast to prototype, but nobody has directly measured it against trained LSTM on the same Indonesian dataset with the same evaluation — including cost and latency.

This project started as a 2023 Binar Academy final project (TF-IDF + MLP, 89.67%). In 2026 I revisited it with two questions: can a BiLSTM close the gap, and is GenAI zero-shot a practical alternative for production use?

The evaluation covers four dimensions: accuracy, cost, latency, and prompt engineering effort. The answer isn't obvious until you look at all four together.

Indonesian NLPTF-IDF BiLSTMGemini Flash 2.0 Cost AnalysisREST API
02 · Final Result

BiLSTM wins — not just on accuracy, but on every dimension that matters for production.

93.0% accuracy, F1 0.9328, 0.25ms inference, $0/year. GenAI zero-shot sits 7.7 points lower in accuracy and costs $62/year for the same volume.

🏆 Winner
BiLSTM
93.0%
F1 Score0.9328
Latency0.25ms
Annual cost$0
#2
TF-IDF + MLP
89.7%
F1 Score0.8930
Latency0.0008ms
Annual cost$0
#3
Gemini Flash Zero-shot
85.3%
F1 Score0.8404
Latency~195ms
Annual cost$62+

Decision matrix

Criterion TF-IDF + MLP BiLSTM Gemini Zero-shot
Accuracy🟡🟢🔴
Macro F1🟡🟢🔴
Latency🟢🟡🔴
Annual cost🟢🟢🔴
Training needed🔴🔴🟢
Labeled data needed🔴🔴🟢
Neutral class F1🔴🟢🔴

When you have labeled data: BiLSTM is the clear choice — higher accuracy, zero cost, sub-millisecond inference. GenAI zero-shot earns its place only when you need to classify without any training data or when you're building a quick prototype before the labeled dataset exists.

03 · Architecture

Three pipelines, same evaluation framework.

Each approach was evaluated under identical conditions: same 11,000-tweet dataset, same 80/20 train-test split, same metrics. Only the pipeline changed.

Approach 1
TF-IDF + MLP
Raw tweet text
Preprocessing (lower, regex, stopwords)
TF-IDF vectorization (max_features=5000)
Dense MLP (512→256→128→3)
Softmax → class label
Approach 2 · Winner
BiLSTM
Raw tweet text
Preprocessing (lower, regex, stopwords)
Tokenizer + pad_sequences (maxlen=100)
Embedding layer (dim=128)
SpatialDropout1D + Bidirectional LSTM (128)
Dense(64, relu) + L2 + Dropout
Softmax → class label
Approach 3
Gemini Flash Zero-shot
Raw tweet text
Prompt construction (ZS / FS / CoT)
Gemini Flash 2.0 API call
JSON response parsing
Class label extraction
04 · Dataset & EDA

11,000 Indonesian tweets. Class imbalance baked in.

The dataset is heavily skewed toward positive sentiment — 58% positive, 31% negative, just 10% neutral. This imbalance shapes every evaluation decision, especially for the neutral class.

The neutral class (10%) proved hardest to classify across all three approaches. BiLSTM achieved the highest neutral F1 at 0.96 — significantly better than NN (0.77) or GenAI zero-shot. The imbalance is why macro-averaged F1 matters more than accuracy alone.

Per-class performance (BiLSTM — best model)

Class Precision Recall F1 Support
Negative0.830.860.84997
Neutral0.960.950.961,035
Positive0.930.920.921,930
05 · Training Journey

Four iterations to get to 93%. Each one taught something different.

The baseline LSTM overfit badly. Each iteration added one intervention and measured the delta. The best result came at iteration 3 — adding L2 in iteration 4 slightly hurt.

Baseline
Unidirectional LSTM, no regularization
89.9%
Starting point
+ Early Stopping
patience=5, restore best weights
90.2%
+0.28%
+ BiDir + SpatialDropout
Bidirectional LSTM, SpatialDropout1D(0.2)
90.9%
+0.76%
+ L2 regularization → Final
L2(0.01) on Dense layer → best validation
93.0%
Best overall

Training history

LSTM training history: accuracy and loss curves showing convergence
06 · GenAI Experiments

Six prompt strategies tested. More examples ≠ better results.

The GenAI track tested zero-shot, 3/5/10-shot few-shot, chain-of-thought, and multilingual prompting. Adding more examples increased cost but did not reliably improve accuracy.

Temperature sweep — accuracy vs randomness

Temperature 0.0 (deterministic) produced the highest accuracy at 86.0%. Higher temperatures introduced variance without improving results.

Prompt strategy comparison

Temperature sweep accuracy chart
07 · Benchmark

Accuracy, F1, and latency side by side.

Accuracy & F1

Accuracy
89.7%
93.0%
85.3%
Macro F1
0.8930
0.9328
0.8404
TF-IDF + MLP
BiLSTM
Gemini Zero-shot

Latency comparison (log scale)

GenAI is 772× slower than the neural network. On log scale, this 24ms → 195ms range dwarfs both trained models. Bar width represents log₁₀ position.

Benchmark charts

Accuracy comparison bar chart Latency comparison chart
Confusion matrices for all three approaches Cost vs accuracy Pareto chart
08 · Cost Analysis

More prompting strategy = more cost, not more accuracy.

Assuming 1,000 classifications/day at 2025 Gemini Flash pricing. Zero-shot costs $62/year. Chain-of-thought costs $304/year — and doesn't improve accuracy over zero-shot.

Trained ML (BiLSTM)
$0
/year · after training
Acc 93.0% · F1 0.9328
Zero-shot
$62
/year · 1K req/day
Acc 85.3% · F1 0.8404
3-shot few-shot
$120
/year
~same accuracy as ZS
5-shot few-shot
$175
/year
Marginal improvement
10-shot few-shot
$268
/year
Diminishing returns
Chain-of-Thought
$304
/year
No accuracy gain vs ZS
"The Pareto-optimal point is zero-shot at $62/year — but even that is dominated by BiLSTM at $0. The entire GenAI cost curve sits below 89% accuracy."
09 · Bugs Found

Three bugs that only surfaced when the system was actually used.

Bug 01 · Wrong filename
Model file not found
main_model_new1.h5
main_model_new.h5
API returned 500 on first deployment. Typo in the hardcoded filename — the actual saved model never had the trailing "1".
Bug 02 · Early return
Batch endpoint returned only first result
for item in data:
  process(item)
  return response_data
for item in data:
  process(item)
return response_data
return inside the for-loop exited after the first iteration. Batch requests always returned a single prediction regardless of input size.
Bug 03 · HTTP method
All Swagger endpoints declared as GET
get:
  /predict
  /predict-all
post:
  /predict
  /predict-all
All 6 Swagger YAML files used get: instead of post:. The UI showed GET forms that couldn't submit a request body — the endpoints were unreachable from the docs.
10 · Lessons Learned

What this experiment actually settled.

On GenAI for NLP tasks

GenAI zero-shot is a starting point, not an endpoint. For a task with a well-labeled dataset, a trained model will consistently outperform prompt engineering — and at zero ongoing cost.

On class imbalance

Accuracy hides imbalance problems. The neutral class (10%) is where all three models struggle most. Reporting only accuracy would have obscured the 0.77 vs 0.96 neutral F1 gap between NN and LSTM.

On overfitting

Validation loss is a better stopping criterion than accuracy. The baseline LSTM overfit within 10 epochs — early stopping with patience=5 added 0.28 points without any architecture change.

On prompt cost escalation

Each prompt strategy multiplies cost without linearly multiplying accuracy. Going from zero-shot ($62) to Chain-of-Thought ($304) is a 5× cost increase for near-zero accuracy gain.

When ML · When GenAI

Use Trained ML When
  • You have 1,000+ labeled examples
  • Latency matters (sub-ms inference)
  • Cost at scale matters ($0 marginal)
  • You're serving one specific language/domain
Use GenAI When
  • No labeled data exists yet
  • You need a working prototype in hours
  • Task scope is undefined (exploratory)
  • Multilingual coverage matters more than accuracy
11 · References

Papers & resources.

  1. [1]Hochreiter, S., & Schmidhuber, J. (1997). Long short-term memory. Neural Computation, 9(8), 1735–1780.
  2. [2]Schuster, M., & Paliwal, K. K. (1997). Bidirectional recurrent neural networks. IEEE Transactions on Signal Processing, 45(11), 2673–2681.
  3. [3]Srivastava, N., et al. (2014). Dropout: A simple way to prevent neural networks from overfitting. JMLR, 15(1), 1929–1958.
  4. [4]Brown, T., et al. (2020). Language models are few-shot learners. NeurIPS 2020. GPT-3 paper establishing few-shot prompting.
  5. [5]Wei, J., et al. (2022). Chain-of-thought prompting elicits reasoning in large language models. NeurIPS 2022.
  6. [6]Google DeepMind. (2024). Gemini 1.5: Unlocking multimodal understanding. Technical Report.
  7. [7]Mikolov, T., et al. (2013). Efficient estimation of word representations in vector space. ICLR 2013.
  8. [8]Gal, Y., & Ghahramani, Z. (2016). A theoretically grounded application of dropout in recurrent neural networks. NeurIPS 2016. Basis for SpatialDropout1D.
See the code

All models, prompts, and evaluation code on GitHub.

The repository includes the full BiLSTM training pipeline, all six prompt strategy implementations, the Gemini Flash evaluation loop, and cost calculation scripts.