Skip to content

Commit 45153bf

Browse files
committed
Clean README formatting
1 parent 44bba6f commit 45153bf

1 file changed

Lines changed: 98 additions & 118 deletions

File tree

README.md

Lines changed: 98 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
# Sentiment Analysis Project (DistilBERT)
22

3-
4-
A deep learning project that fine-tunes DistilBERT for binary sentiment classification. Includes training, evaluation, inference, and a Streamlit web UI.
3+
A deep learning project that fine-tunes DistilBERT for binary sentiment classification. It includes training, evaluation, inference, and a Streamlit web UI.
54

65
## Streamlit Run Link
76

7+
- Public link: [https://sentiment-nlp-live-20260617.streamlit.app/](https://sentiment-nlp-live-20260617.streamlit.app/)
8+
- Local run link: [http://localhost:8501/](http://localhost:8501/)
89

9-
- https://sentiment-nlp-live-20260617.streamlit.app/
10-
- Local run link: http://localhost:8501/
11-
12-
Note: the current public link is a Cloudflare quick tunnel (no card needed). It stays live while the cloudflared process is running on this machine.
10+
The public link is a Cloudflare quick tunnel. It stays live while the `cloudflared` process is running on this machine.
1311

1412
### One-Click Public Link (Windows)
1513

1614
Run `start_public_link.bat` from the project root. It starts:
15+
1716
- Streamlit on localhost:8501
1817
- Cloudflare quick tunnel for a public HTTPS URL
1918

20-
Keep both opened terminal windows running while sharing the app.
19+
Keep both terminal windows open while sharing the app.
2120

22-
## Quick Start - Run Locally
21+
## Quick Start
2322

2423
### Prerequisites
24+
2525
- Python 3.10 or higher
26-
- pip or conda package manager
27-
- ~2GB free disk space (for models)
26+
- `pip` or `conda`
27+
- About 2 GB of free disk space for model files
2828

29-
### Installation & Running
29+
### Installation and Running
3030

3131
```bash
3232
# Clone the repository
@@ -40,9 +40,9 @@ pip install -r requirements.txt
4040
python -m streamlit run app.py
4141
```
4242

43-
The app will open at `http://localhost:8501/` in your browser.
43+
The app will open at [http://localhost:8501/](http://localhost:8501/) in your browser.
4444

45-
### Alternative: Run Development Version
45+
### Alternative: Development Version
4646

4747
```bash
4848
# Use local development dependencies
@@ -54,44 +54,51 @@ python -m streamlit run SRC/Streamlit_App.py
5454

5555
## Project Status
5656

57-
### ✅ What Works
58-
- Local Streamlit app runs perfectly
57+
### What Works
58+
59+
- Local Streamlit app runs correctly
5960
- DistilBERT model inference works correctly
60-
- All core functionality (training, evaluation, batch prediction) is operational
61+
- Training, evaluation, and batch prediction are operational
6162
- Deployment configuration is ready
6263

63-
### ⚠️ Deployment Status
64-
- **Streamlit Cloud**: Currently unavailable (403 Forbidden access error on platform)
65-
- **Hugging Face Spaces**: Recommended alternative (requires HF account)
66-
- **Local testing**: Fully functional
67-
- **SSH tunneling**: Can be used for temporary sharing
64+
### Deployment Status
65+
66+
- Streamlit Cloud: currently unavailable due to a 403 Forbidden access issue
67+
- Hugging Face Spaces: recommended alternative if you want hosted deployment
68+
- Local testing: fully functional
69+
- SSH tunneling: available for temporary sharing
6870

6971
## Deployment Options
7072

71-
### 1. **Hugging Face Spaces** (Recommended)
72-
1. Create account at [huggingface.co](https://huggingface.co)
73-
2. Create new Space with Streamlit template
74-
3. Connect GitHub repo or upload files
75-
4. Auto-deploys on push
73+
### 1. Hugging Face Spaces
74+
75+
1. Create an account at [huggingface.co](https://huggingface.co)
76+
2. Create a new Space with the Streamlit template
77+
3. Connect the GitHub repo or upload the files
78+
4. The app auto-deploys on push
79+
80+
### 2. Railway, Render, or Heroku
7681

77-
### 2. **Railway, Render, or Heroku**
78-
1. Fork/push repo to GitHub
79-
2. Connect repo to hosting platform
80-
3. Set startup command: `streamlit run app.py`
82+
1. Fork or push the repo to GitHub
83+
2. Connect the repo to your hosting platform
84+
3. Set the startup command to `python -m streamlit run app.py`
8185
4. Deploy
8286

83-
### 3. **Local Sharing via SSH Tunnel** (Temporary)
87+
### 3. Local Sharing via SSH Tunnel
88+
8489
```bash
85-
# In a new terminal (keep app running in another)
90+
# Terminal 1: Run the app
91+
python -m streamlit run app.py
92+
93+
# Terminal 2: Create tunnel
8694
ssh -o StrictHostKeyChecking=no -R 80:localhost:8501 nokey@localhost.run
8795
```
88-
This generates a public HTTPS URL (changes each time)
8996

90-
## Full Feature List
97+
This generates a public HTTPS URL that changes each time you restart the tunnel.
9198

9299
## Project Structure
93100

94-
```
101+
```text
95102
SENTIMENT_Project/
96103
├── app.py # Streamlit entry point (deployment)
97104
├── requirements.txt # Production dependencies
@@ -107,9 +114,9 @@ SENTIMENT_Project/
107114
│ ├── Data_Loader.py # Dataset utilities
108115
│ ├── Requirement.txt # Development dependencies
109116
│ └── Models/ # Trained model checkpoints
110-
├── Data/ # Datasets & sample data
117+
├── Data/ # Datasets and sample data
111118
├── Models/ # Model outputs
112-
└── Outputs/ # Predictions & results
119+
└── Outputs/ # Predictions and results
113120
```
114121

115122
## Installation
@@ -124,16 +131,17 @@ pip install -r requirements.txt
124131
pip install -r SRC/Requirement.txt
125132
```
126133

127-
**Requirements Include:**
134+
### Requirements Include
135+
128136
- streamlit
129-
- transformers (HuggingFace)
130-
- torch & torchvision
137+
- transformers
138+
- torch and torchvision
131139
- pandas, numpy, scikit-learn
132140
- datasets, evaluate
133141

134142
## Usage
135143

136-
### 🎯 Web Interface (Recommended for testing)
144+
### Web Interface
137145

138146
```bash
139147
# Deploy-ready entry point
@@ -143,42 +151,46 @@ python -m streamlit run app.py
143151
python -m streamlit run SRC/Streamlit_App.py
144152
```
145153

146-
Then open http://localhost:8501/ in your browser and enter text for sentiment prediction.
154+
Then open [http://localhost:8501/](http://localhost:8501/) in your browser and enter text for sentiment prediction.
147155

148-
### 🔧 Command Line
156+
### Command Line
157+
158+
Train the model:
149159

150-
**Train the model:**
151160
```bash
152-
python SRC/Train.py # Full training
153-
python SRC/Train.py --smoke-test # Quick test run
161+
python SRC/Train.py
162+
python SRC/Train.py --smoke-test
154163
```
155164

156-
**Evaluate performance:**
165+
Evaluate performance:
166+
157167
```bash
158168
python SRC/Evaluate_Model.py
159169
```
160170

161-
**Predict sentiment for single text:**
171+
Predict sentiment for a single text:
172+
162173
```bash
163174
python SRC/Inference.py --text "Great movie!"
164175
```
165176

166-
**Batch predict from CSV:**
177+
Batch predict from CSV:
178+
167179
```bash
168180
python SRC/Batch_Predict.py --input Data/sample_reviews.csv --output predictions.csv
169181
```
170182

171-
**Run full pipeline:**
183+
Run the full pipeline:
184+
172185
```bash
173-
python run_pipeline.py # Full execution
174-
python run_pipeline.py --fast # Quick test run
186+
python run_pipeline.py
187+
python run_pipeline.py --fast
175188
```
176189

177190
## Troubleshooting
178191

179-
### Issue: "Module not found" errors
192+
### Module not found errors
180193

181-
**Solution:**
182194
```bash
183195
# Reinstall all dependencies
184196
pip install -r requirements.txt --force-reinstall
@@ -188,89 +200,57 @@ pip install --upgrade pip
188200
pip install -r requirements.txt
189201
```
190202

191-
### Issue: Port 8501 already in use
203+
### Port 8501 already in use
192204

193-
**Solution:**
194205
```bash
195-
# Use different port
196-
streamlit run app.py --server.port 8502
206+
# Use a different port
207+
python -m streamlit run app.py --server.port 8502
197208
```
198209

199-
### Issue: Out of memory during training
210+
### Out of memory during training
211+
212+
Open `SRC/Config.py` and reduce `BATCH_SIZE` or `MAX_LENGTH`.
200213

201-
**Solution:** Open `SRC/Config.py` and reduce `BATCH_SIZE` or `MAX_LENGTH`
214+
### Model checkpoint not found
202215

203-
### Issue: Model checkpoint not found
216+
The app automatically falls back to HuggingFace's default DistilBERT model. To train and save your own checkpoint:
204217

205-
**Solution:** The app automatically falls back to HuggingFace's default DistilBERT model. To train and save your own:
206218
```bash
207-
python SRC/Train.py # Creates checkpoint in SRC/Models/
219+
python SRC/Train.py
208220
```
209221

210222
## Model Details
211223

212-
- **Base Model**: DistilBERT (distilbert-base-uncased)
213-
- **Task**: Binary sentiment classification (positive/negative)
214-
- **Training Data**: IMDb movie reviews (50K samples)
215-
- **Framework**: HuggingFace Transformers + PyTorch
216-
- **Input**: Any text string
217-
- **Output**: Predicted label (positive/negative) + confidence score
224+
- Base model: DistilBERT (`distilbert-base-uncased`)
225+
- Task: binary sentiment classification
226+
- Training data: IMDb movie reviews (50K samples)
227+
- Framework: HuggingFace Transformers + PyTorch
228+
- Input: any text string
229+
- Output: predicted label and confidence score
218230

219231
## Notes
220232

221233
- Paths are configured to be execution-location independent
222234
- Model files are auto-downloaded from HuggingFace on first run
223235
- Streamlit UI includes interactive examples
224236
- Batch predictions support custom text column names
225-
- Training uses GPU if available, falls back to CPU
226-
- Config file: `SRC/Config.py` for customization
227-
228-
## Known Issues & Limitations
229-
230-
1. **Streamlit Cloud Deployment**: Currently returns 403 Forbidden error (platform account access issue)
231-
- **Workaround**: Deploy to Hugging Face Spaces, Railway, or Render instead
232-
233-
2. **First Run Slowness**: Model & dependencies download on first execution (~2-3 min)
234-
- Subsequent runs are much faster due to caching
235-
236-
3. **Requires Internet**: Initial download of model from HuggingFace requires connection
237+
- Training uses GPU if available, otherwise CPU
238+
- Configure `SRC/Config.py` for customization
237239

238-
## Deployment Guide (Step-by-Step)
239-
240-
### Option A: Hugging Face Spaces (Recommended)
241-
242-
1. Create HuggingFace account
243-
2. Go to [huggingface.co/spaces](https://huggingface.co/spaces)
244-
3. Create new Space → Streamlit template
245-
4. Upload `app.py` and `requirements.txt`
246-
5. Or connect GitHub repo for auto-deploy
247-
6. Share the generated Space URL
248-
249-
### Option B: Railway.app (Free Tier Available)
250-
251-
1. Connect GitHub repo to [railway.app](https://railway.app)
252-
2. Add environment variable: `PORT=8501`
253-
3. Set startup command: `streamlit run app.py --server.port 8501`
254-
4. Deploy
240+
## Known Issues and Limitations
255241

256-
### Option C: Local with SSH Tunnel (Temporary)
257-
258-
```bash
259-
# Terminal 1: Run the app
260-
streamlit run app.py
261-
262-
# Terminal 2: Create tunnel
263-
ssh -o StrictHostKeyChecking=no -R 80:localhost:8501 nokey@localhost.run
264-
```
265-
266-
The tunnel generates a public HTTPS URL (changes each restart, no account needed)
242+
1. Streamlit Cloud deployment currently returns a 403 Forbidden error due to platform account access.
243+
- Workaround: deploy to Hugging Face Spaces, Railway, or Render.
244+
2. First run is slower because the model and dependencies download on the initial execution.
245+
- Later runs are faster due to caching.
246+
3. Initial model download requires internet access.
267247

268248
## Development
269249

270250
### Setup Development Environment
271251

272252
```bash
273-
# Create virtual environment (optional but recommended)
253+
# Create a virtual environment (optional but recommended)
274254
python -m venv venv
275255
source venv/bin/activate # On Windows: venv\Scripts\activate
276256

@@ -281,24 +261,23 @@ pip install -r SRC/Requirement.txt
281261
### Running Tests
282262

283263
```bash
284-
# Quick smoke test of all components
285264
python SRC/Train.py --smoke-test
286265
python SRC/Evaluate_Model.py
287266
python SRC/Inference.py
288267
```
289268

290269
## Contributing
291270

292-
Feel free to fork, modify, and submit pull requests!
271+
Feel free to fork, modify, and submit pull requests.
293272

294273
### Potential Improvements
295274

296-
- [ ] Support for other languages
297-
- [ ] Multi-class classification (star ratings)
298-
- [ ] Model quantization for faster inference
299-
- [ ] GPU optimization for batch processing
300-
- [ ] API deployment with FastAPI
301-
- [ ] Docker containerization
275+
- Support for other languages
276+
- Multi-class classification with star ratings
277+
- Model quantization for faster inference
278+
- GPU optimization for batch processing
279+
- API deployment with FastAPI
280+
- Docker containerization
302281

303282
## License
304283

@@ -307,5 +286,6 @@ This project is open source and available under the MIT License.
307286
## Contact
308287

309288
For issues or questions:
289+
310290
- GitHub Issues: [SENTIMENT-NLP- Issues](https://github.com/EbiAraz/SENTIMENT-NLP-/issues)
311291
- Author: EbiAraz

0 commit comments

Comments
 (0)