https://github.com/shubhamhackz/project_b
https://github.com/shubhamhackz/project_b
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/shubhamhackz/project_b
- Owner: shubhamhackz
- Created: 2025-06-02T12:09:08.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-02T18:24:51.000Z (about 1 year ago)
- Last Synced: 2025-06-03T01:21:48.051Z (about 1 year ago)
- Language: Python
- Size: 1.49 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Production-Grade NER Model
**Single Entry Point Design** - One command for everything: train, test, and deploy!
## ๐ Quick Start
```bash
# Full pipeline: Train โ Test โ Interactive
python main.py --full-pipeline --real-world
# Individual modes
python main.py --real-world # Train only (default)
python main.py --test # Test trained model
python main.py --interactive # Interactive terminal
```
## ๐ Commands Overview
| Command | Description |
|---------|-------------|
| `python main.py --real-world` | Train robust model with overfitting fixes |
| `python main.py --test` | Run comprehensive testing suite |
| `python main.py --interactive` | Start interactive NER interface |
| `python main.py --full-pipeline --real-world` | Complete workflow |
## ๐ ๏ธ Project Structure
```
project_b/
โโโ main.py # ๐ฏ SINGLE ENTRY POINT
โโโ tools/ # Testing & interaction utilities
โ โโโ test_model_comprehensive.py # Comprehensive testing suite
โ โโโ interactive_ner.py # Interactive terminal interface
โโโ model.py # Model architecture
โโโ train.py # Training utilities
โโโ utils.py # Data processing
โโโ evaluate.py # Evaluation metrics
โโโ advanced_real_world_training.py # Overfitting fixes
```
## ๐ฏ Training Options
### Real-World Training (Recommended)
```bash
python main.py --real-world --epochs 8 --batch-size 8 --learning-rate 1.5e-5
```
**Fixes Applied:**
- โ
Surface pattern corruption (breaks @ .com memorization)
- โ
Realistic targets: EMAIL 85-90%, PHONE 82-88%, PERSON 88-94%
- โ
Stronger regularization (weight_decay 0.02, label_smoothing 0.1)
- โ
More frequent evaluation (every 100 steps)
### Standard Training
```bash
python main.py # Basic training
python main.py --epochs 4 # Custom epochs
python main.py --batch-size 16 # Custom batch size
```
## ๐งช Testing
### Comprehensive Testing Suite
```bash
python main.py --test
```
**Tests Include:**
- โ
Basic entity recognition (PER, ORG, LOC, MISC)
- โ
EMAIL/PHONE detection accuracy
- โ
Overfitting detection (corrupted patterns)
- โ
Edge cases (empty text, long sequences, special chars)
- โ
Performance analysis with 80% success threshold
**Output:** `model_test_report.json` with detailed results
## ๐ Interactive Mode
```bash
python main.py --interactive
```
**Features:**
- ๐จ Colored entity highlighting
- โก Real-time processing with timing
- ๐ Built-in commands: `help`, `examples`, `stats`, `test`
- ๐ก๏ธ Safety checks (requires testing first)
## ๐ Full Pipeline
```bash
python main.py --full-pipeline --real-world
```
**Workflow:**
1. **Training** - Robust real-world training with overfitting fixes
2. **Testing** - Comprehensive validation (must pass โฅ80%)
3. **Interactive** - Deploy only if testing passes
## ๐ Expected Performance
| Entity Type | Target F1 | Note |
|-------------|-----------|------|
| EMAIL | 85-90% | Not 99%+ (overfitting) |
| PHONE | 82-88% | Not 99%+ (overfitting) |
| PERSON | 88-94% | Not 99%+ (overfitting) |
| OVERALL | 86-92% | Not 98%+ (overfitting) |
## ๐ง Advanced Options
```bash
# Custom model
python main.py --model roberta-base --real-world
# More synthetic data
python main.py --synthetic-count 10000 --real-world
# Quick test run
python main.py --epochs 2 --batch-size 4
```
## ๐ File Organization
- **`main.py`** - Central orchestrator, single entry point
- **`tools/`** - Separate but integrated utilities
- **`production-ner-model-final/`** - Trained model output
- **`checkpoints/`** - Training checkpoints
- **`mlruns/`** - MLflow experiment tracking
## ๐ฏ Production Deployment
1. **Train:** `python main.py --real-world`
2. **Validate:** `python main.py --test` (โฅ80% required)
3. **Deploy:** `python main.py --interactive`
**Safety:** Interactive mode requires testing completion first!