A self-learning AI proofreader that corrects English grammar while preserving meaning and adapts to your writing style through user feedback.
- Grammar Correction: Uses T5-based models for high-quality grammar and fluency corrections
- Semantic Validation: Ensures corrections preserve meaning using sentence embeddings
- User Feedback Learning: Adapts to your style through accepted/rejected corrections
- Offline-First: Runs locally without external dependencies
- CLI & GUI Interfaces: Choose your preferred way to interact
- Docker Support: Containerized deployment for reproducibility
Supercharged Performance on Mac M1/M2/M3 and NVIDIA GPUs!
The system now supports automatic GPU acceleration for dramatically improved performance:
- Mac M1/M2/M3: 2-3x faster processing with Metal Performance Shaders (MPS)
- NVIDIA GPUs: 3-5x faster with CUDA acceleration
- Intelligent Optimization: Auto-adjusts batch sizes and worker counts
- Memory Management: Smart GPU memory handling and cleanup
# Automatic GPU detection and acceleration (enabled by default)
python3 cli/batch_proofread.py sample_docs/ --output-dir corrected/ --show-device-info
# Mac M1/M2 optimized processing
python3 cli/batch_proofread.py book_chapters/ --workers 8 --batch-size 8 --show-device-info
# Compare GPU vs CPU performance
python3 cli/batch_proofread.py docs/ --output-dir gpu_test/ --show-device-info
python3 cli/batch_proofread.py docs/ --output-dir cpu_test/ --disable-gpu# GPU control options
--enable-gpu # Enable GPU acceleration (default: enabled)
--disable-gpu # Disable GPU acceleration (force CPU only)
--enable-mps # Enable Apple Silicon MPS (default: enabled)
--disable-mps # Disable MPS acceleration
--workers 8 # Parallel workers (optimized for GPU)
--batch-size 8 # GPU-optimized batch size
--show-device-info # Display GPU/CPU informationSee docs/GPU_Acceleration_Guide.md for complete GPU documentation and optimization guides.
This project implements a complete AI proofreading pipeline based on the comprehensive plan outlined in [docs/Master Project Guide.md](docs/Master Project Guide.md:1). It provides:
- Text preprocessing and normalization
- Grammar correction using transformer models
- Semantic similarity validation
- SQLite-based feedback collection
- Optional model retraining
- Web-based GUI for interactive review
-
Clone the repository
git clone <repository-url> cd grammar-proofreader
-
Install dependencies
# Create virtual environment python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate # Install requirements pip install -r requirements.txt # Download language model python -m spacy download en_core_web_sm
-
Run CLI
python cli/proofread.py --input my_text.txt --export corrected.txt
-
Run GUI (optional)
python gui/app.py # Opens at http://localhost:7860
# Build image
docker build -t proofreader .
# Run CLI
docker run --rm -v $(pwd):/data proofreader --input /data/input.txt --export /data/output.txt
# Run GUI
docker run --rm -p 7860:7860 proofreader python gui/app.py# Process a file
python cli/proofread.py --input sample.txt --export corrected.txt
# Process text directly
python cli/proofread.py --text "I have went to the store." --export corrected.txt
# Get detailed results
python cli/proofread.py --input sample.txt --export-json results.json --stats
# Adjust similarity threshold
python cli/proofread.py --input sample.txt --similarity-threshold 0.9CLI Options:
--input, -i: Input file path--text, -t: Input text directly--export, -o: Output file for corrected text--export-json, -j: Output file for detailed results (JSON)--similarity-threshold, -s: Semantic similarity threshold (0.0-1.0)--model-name: Grammar model to use--batch-size: Batch size for inference--stats: Show processing statistics--quiet, -q: Suppress output--verbose, -v: Increase verbosity
The GUI provides an interactive interface for:
- Text Input: Paste or upload your text
- Real-time Processing: See corrections as you type
- Accept/Reject: Manually review each suggestion
- Statistics: Track processing metrics and feedback
- Adjustable Threshold: Fine-tune semantic similarity requirements
The system follows a modular architecture as defined in tech/Technical_Spec.md:
Text Input
β
Text Preprocessor (src/preprocessor.py)
β
Grammar Model (src/inference.py)
β
Semantic Validator (src/validator.py)
β
Feedback Database (src/db.py)
β
[Optional] Model Retraining
- Pipeline (
src/pipeline.py): Orchestrates the entire workflow - Preprocessor (
src/preprocessor.py): Normalizes and splits text - Grammar Model (
src/inference.py): Handles T5-based grammar correction - Semantic Validator (
src/validator.py): Validates meaning preservation - Feedback DB (
src/db.py): SQLite database for user feedback
- Python: 3.9+
- CUDA: Optional, for GPU acceleration
- Memory: 4GB+ RAM recommended
- Storage: 2GB+ for models and dependencies
torch>=1.13.0: Deep learning frameworktransformers>=4.30.0: Pre-trained modelssentence-transformers: Semantic similaritygradio: Web interfacespacy: Natural language processingsqlite3: Database (built-in)
See requirements.txt for complete list.
The project includes comprehensive testing as defined in tests/Test_Plan.md:
# Run all tests
pytest
# Run with coverage
pytest --cov=src
# Run specific test types
pytest tests/unit/ # Unit tests
pytest tests/integration/ # Integration testsThe system includes analytics as outlined in analytics/Analytics_Plan.md:
- Acceptance Rate: Track user acceptance of corrections
- Semantic Similarity: Monitor meaning preservation
- Processing Statistics: Performance metrics
- User Feedback: Accepted/rejected corrections for learning
Access statistics via CLI:
python cli/proofread.py --stats --input sample.txtSee security/Security_Compliance.md for complete security documentation.
- Local-First: All processing happens locally
- Data Privacy: User content stays on your machine
- Optional Encryption: Database encryption available
- No Telemetry: No data sent to external services by default
See docs/Repo_Scaffold.md for deployment details.
# Production build
docker build -t proofreader:latest .
# Run with volume mount
docker run -v /path/to/data:/app/data proofreader:latestMODEL_CACHE_DIR: Custom path for downloaded modelsDB_PATH: Custom path for SQLite databaseLOG_LEVEL: Logging level (DEBUG, INFO, WARNING, ERROR)
See shards/shard_backlog.md for detailed development plan.
β Completed:
- Core pipeline and architecture
- Text preprocessing module
- Grammar correction model integration
- Semantic validation
- Feedback database
- CLI interface
- Gradio GUI prototype
- Docker support
- CI/CD pipeline
π In Progress:
- Model retraining automation
- Enhanced GUI features
- Performance optimizations
π Planned:
- Multiple model support
- Batch processing improvements
- Web API interface
- Advanced analytics dashboard
- Follow the installation instructions above
- Install development dependencies:
pip install black flake8 pytest pytest-cov
- Run code formatting:
black src/ cli/ gui/ tests/
- Run linting:
flake8 src/ cli/ gui/ tests/
βββ src/ # Core modules
β βββ pipeline.py # Main orchestration
β βββ preprocessor.py # Text preprocessing
β βββ inference.py # Grammar model
β βββ validator.py # Semantic validation
β βββ db.py # Feedback database
βββ cli/ # Command-line interface
β βββ proofread.py
βββ gui/ # Web interface
β βββ app.py
βββ tests/ # Test suite
βββ docs/ # Documentation
βββ requirements.txt # Dependencies
βββ Dockerfile # Containerization
βββ README.md # This file
- Follow the architecture defined in the tech spec
- Write tests for new features
- Update documentation for user-facing changes
- Use semantic versioning for releases
- Keep dependencies updated regularly
- [
docs/Master Project Guide.md](docs/Master Project Guide.md:1): Project overview and roadmap - [
prd/PRD - Product Requirements.md](prd/PRD - Product Requirements.md:1): Product requirements tech/Technical_Spec.md: Technical architecturetests/Test_Plan.md: Testing strategyanalytics/Analytics_Plan.md: Analytics and metricssecurity/Security_Compliance.md: Security documentationshards/shard_backlog.md: Development backlog
This project is licensed under the MIT License. See LICENSE file for details.
- Based on the comprehensive plan in
plan for grammar correction.md - Uses T5-based grammar correction models from Hugging Face
- Semantic validation powered by SentenceTransformers
- GUI built with Gradio
- Architecture inspired by modern MLOps practices
For questions, issues, or contributions:
- Check the documentation
- Search existing issues
- Create a new issue with detailed description
- Join our discussions
Built with β€οΈ for writers, editors, and anyone who values clear, correct English prose.
The system includes a comprehensive learning verification system that tracks AI improvement over time:
python3 cli/proofread.py --learning-reportKey Features:
- Learning Patterns - Shows most frequently corrected patterns
- Quality Distribution - Breaks down corrections by similarity scores
- Learning Trends - Week-over-week improvement tracking
- Source Analytics - Usage patterns by interface (CLI/GUI/API)
- Training Readiness - Indicates when enough data is collected for retraining
- Performance Metrics - Acceptance rates, similarity improvements, daily activity
This enables you to verify that the system is truly learning from itself and improving over time.
π§ AI LEARNING REPORT
==================================================
π OVERALL STATISTICS
Total Feedback: 2
Accepted Corrections: 2
Rejected Corrections: 0
Acceptance Rate: 100.0%
Recent Activity (24h): 2
Average Similarity (accepted): 0.638
π― QUALITY DISTRIBUTION
Low: 2/2 accepted (100.0%)
π LEARNING TRENDS
Last 7 days: 2 corrections
Previous 7 days: 0 corrections
Week-over-week change: +2 corrections
Similarity improvement: +0.638
π MOST LEARNED PATTERNS
1. '"Huuuβ¦.' β 'Huuu....'
Frequency: 1 | Similarity: 0.726
2. 'β¦β¦' β '......'
Frequency: 1 | Similarity: 0.55
π SOURCE USAGE PATTERNS
Api: 2 corrections (avg similarity: 0.638)
π
DAILY PERFORMANCE TREND
2025-11-03: 2 corrections, 100.0% accepted
β οΈ LEARNING STATUS: Gathering feedback (need 8 more corrections)
π TRAINING PREPARATION: 2 pairs (need 8 more for training)
The system supports batch processing for multiple files simultaneously:
# Process entire directory of files
python3 cli/batch_proofread.py sample_docs/ --output-dir corrected_docs/
# Process with summary report and parallel processing
python3 cli/batch_proofread.py *.txt --output-dir batch_output/ --summary-file report.json --workers 4
# Sequential processing for debugging
python3 cli/batch_proofread.py sample_docs/ --sequentialBatch Features:
- Multiple file formats:
.txt,.md,.rstfiles - Parallel processing: Configurable worker threads
- Progress tracking: Real-time progress bars
- Summary reporting: JSON export of batch statistics
- Error handling: Continues processing even if individual files fail
- Output organization: Preserves original file structure and extensions
Batch Processing Output:
π BATCH PROCESSING SUMMARY
==================================================
Total files: 3
Successful: 3
Failed: 0
Success rate: 100.0%
Total processing time: 135.9s
Total sentences processed: 35
Auto-applied corrections: 35
Requiring review: 0
Average processing rate: 0.3 sentences/sec
==================================================