An open API service indexing awesome lists of open source software.

https://github.com/shubhamhackz/project_b


https://github.com/shubhamhackz/project_b

Last synced: about 1 year ago
JSON representation

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!