I built a sentiment analysis system from zero Python knowledge to a production-ready transformer, in one notebook.
SmartReview AI analyzes movie reviews and predicts whether they are positive or negative. It does this four different ways, each more powerful than the last, inside a single Colab notebook that runs top to bottom.
The project exists to teach AI/ML/DL/NLP through building, not through theory. Every phase produces a working model. Every failure teaches something specific. Every result connects to the next phase.
| Phase | Method | Accuracy | Training time | What it proves |
|---|---|---|---|---|
| 1 | Exploratory analysis | n/a | instant | Simple features (word count, caps ratio) have near-zero correlation with sentiment. Max correlation: 0.17. You cannot solve this problem without ML. |
| 2 | TF-IDF + Logistic Regression | 88.3% | 0.4 seconds | Word frequency alone gets you surprisingly far. "worst" carries a weight of -8.57, the single most powerful signal in the entire vocabulary. Negative language is more distinctive than positive language. |
| 3 | LSTM neural network (PyTorch) | 81.1% | ~3 minutes | Training a neural network from scratch on 25K samples with 5M parameters is unstable. The model learns but plateaus well below the classical baseline. This is the experiential proof that pre-training matters. |
| 4 | DistilBERT (fine-tuned) | 91.4% | 12 minutes | A transformer pre-trained on 3.3 billion words crushes every previous approach. It has 14x more parameters than the LSTM but does not overfit because those parameters already encode the structure of English. |
| Phase 1: Feature correlations | Phase 2: Confusion matrix |
|---|---|
![Phase 1]![]() |
|
![Phase 2]![]() |
|
| Phase 3: LSTM overfitting | Phase 4: Attention heatmap |
|---|---|
![Phase 3]![]() |
|
![Phase 4]![]() |
|
The sentence "The movie was not good but the acting was brilliant" produces three visible patterns in the transformer's attention:
Negation binding. "not" attends to itself at 0.19 and to "was" at 0.11. It locks onto its local clause and modifies "good" contextually. TF-IDF treated "not" and "good" as two independent signals. The transformer understands they form one unit.
Semantic grouping. "brilliant" attends to itself at 0.20 and to "acting" at 0.14. The model groups "the acting was brilliant" as a coherent positive statement, separate from the negative first clause.
The pivot word. "but" has the strongest self-attention in the sentence at 0.18. It acts as a separator between the negative clause and the positive clause. The LSTM would have had to carry the meaning of "not good" through its hidden state across this word. The transformer reads the entire sentence in parallel.
The model's most confident mistakes (99.8% confidence, wrong prediction) are reviews like "Stupidly beautiful. This movie epitomizes the 'so bad it's good' genre." The model predicts NEGATIVE. The IMDB label says POSITIVE. The model is arguably correct: the text IS negative about the film. The reviewer enjoys it precisely because it is bad. This is intentional sarcasm that even humans interpret differently depending on context.
These errors reveal the boundary of what current NLP can do. Sarcasm, irony, and "so bad it's good" sentiment require understanding the reviewer's intent, not just their words. This is an open research problem.
I did not study AI theory first. I ran code, observed results, changed one variable, and watched what broke.
Changing learning_rate from 2e-5 to 0.1 in Phase 4 destroyed the model. This taught me that pre-trained weights need gentle updates. Changing max_features from 10,000 to 100 in Phase 2 dropped accuracy to ~75%. This taught me that vocabulary size controls model capacity. Watching the LSTM score 81.1% while the transformer scored 91.4% with the same data taught me that architecture and pre-training matter more than training time.
The method: run it, change one thing, re-run, observe the difference. The understanding comes from the delta, not from the textbook.
SmartReview_AI.ipynb # Complete notebook, Phases 1 to 4
README.md # This file
results/
phase1_exploration.png # Feature correlation heatmap
phase2_confusion.png # Confusion matrix
phase3_training.png # LSTM training curves
phase4_attention.png # Transformer attention heatmap
Phase 5 will add LLM generation and RAG with ChromaDB. The Phase 4 embeddings become a semantic search engine: "find reviews about battery life" returns the most relevant reviews even if they never use the word "battery."
Phase 6 will introduce reinforcement learning concepts. A reward model scores generated summaries, and Direct Preference Optimization aligns the generator with human quality standards.
Phase 7 will ship the whole system as a product. FastAPI backend, React dashboard, Docker deployment, Stripe billing. The end state: a SaaS tool that companies pay for.
- Open the notebook in Google Colab
- Set runtime to T4 GPU (Runtime > Change runtime type)
- Run every cell from top to bottom
- Total time: ~20 minutes for all 4 phases
Tools and credits Fabrice Fils-Aimé designed the project architecture, directed the learning progression, ran all experiments, and performed the analysis. Claude (Anthropic) generated the notebook code and structure. DeepSeek assisted with expansion and debugging. The intellectual work of understanding, experimenting, and drawing conclusions is the author's. Citation If you use this project in your work or reference it in a publication: bibtex@misc{filsaime2025smartreview, author = {Fils-Aimé, Fabrice}, title = {SmartReview AI: Learning AI/ML/DL/NLP by Reverse Engineering}, year = {2025}, publisher = {GitHub}, url = {https://github.com/fabthebest/smartreview-ai} }
pandas>=2.0 numpy>=1.24 matplotlib>=3.7 seaborn>=0.12 scikit-learn>=1.3 torch>=2.0 transformers>=4.35 datasets>=2.14 accelerate>=0.24 evaluate>=0.4 Install everything at once: bashpip install pandas numpy matplotlib seaborn scikit-learn torch transformers datasets accelerate evaluate Or use Google Colab (recommended), which has most dependencies pre-installed. Connect I'm open to collaborations, opportunities, and conversations about AI/ML. If this project resonates with you, I'd love to hear from you.
GitHub: github.com/fabthebest
If you found this project useful or learned something from it, consider giving it a star. It helps others discover it and motivates me to keep building Phases 5, 6, and 7.
Copyright 2026 Fabrice Fils-Aimé Licensed under the Apache License, Version 2.0. See LICENSE for details.



