Instantly classify text as Positive or Negative using DistilBERT — no API key, no cloud cost, runs on any machine.
- Single-text analysis — paste any text and get an instant POSITIVE / NEGATIVE label with a confidence score and visual bar
- Batch CSV processing — upload a CSV with a
textcolumn and analyze hundreds of rows at once - Downloadable results — export your batch results as a clean CSV file
- Sentiment distribution chart — auto-generated bar chart showing the split across your dataset
- Zero cost — powered by a free HuggingFace model that runs fully on CPU; no GPU or paid API required
- Clean Gradio UI — two-tab layout built with
gr.Blocksandgr.themes.Soft()
git clone https://github.com/your-username/sentiment-analyzer.git && cd sentiment-analyzer
pip install -r requirements.txt
python app.pyThen open your browser at http://localhost:7860
DistilBERT is a smaller, faster version of Google's BERT language model — trained by reading billions of sentences from the internet until it learned what words, phrases, and sentence structures tend to mean. It was then fine-tuned specifically on movie and product reviews so it knows the difference between language that expresses satisfaction and language that expresses frustration. When you give it a sentence, it converts every word into a stream of numbers, passes those numbers through 6 layers of "attention" math that weighs how each word relates to every other word, and produces a single prediction: Positive or Negative, along with a confidence score showing how certain it is.
— add your screen recording here
sentiment-analyzer/
├── app.py # Gradio Blocks UI + tab logic
├── model.py # Lazy model loading + analyze_text / analyze_batch
├── requirements.txt # Pinned dependencies
├── sample_reviews.csv # 10 Amazon-style test reviews
└── README.md
- E-commerce — automatically flag negative product reviews for urgent review
- Social media monitoring — gauge public sentiment on brand mentions or campaigns
- Customer support — prioritize tickets that contain strongly negative language
- Research — quickly label large text datasets without manual annotation
- Education — learn how transformer-based NLP pipelines work end-to-end
- Create a new Space at huggingface.co/spaces (choose Gradio SDK)
- Push this repository to the Space's git remote
- HuggingFace will auto-install
requirements.txtand runapp.py
Or for a quick public share link, change the last line of app.py to:
demo.launch(share=True)MIT © 2024 — free to use, modify, and distribute.