ExpressMe is an AI-powered email generation system that learns from your writing style to create authentic, personalized emails. It uses fine-tuned Large Language Models (LLMs) with Low-Rank Adaptation (LoRA) to capture individual writing patterns.
- Personal Style Learning: Analyzes your sent Gmail emails to understand your unique writing patterns
- Serverless GPU Training: Leverages Modal for cost-effective, on-demand GPU compute
- Fast Inference: Sub-2 second generation with cached model adapters
- Privacy-First: All processing happens in isolated containers, data is never shared
- One-Click Setup: Simple OAuth flow for Gmail integration
-
Data Pipeline (
modal_training.py)- Gmail API integration for email extraction
- Multi-stage cleaning with regex patterns and heuristics
- Prompt synthesis using Phi-3 for training pair generation
- Smart filtering to remove code, forwards, and non-English content
-
Training System
- Fine-tunes Llama-3.2 3B using LoRA adapters
- 4-bit quantization for memory efficiency
- Gradient checkpointing to fit on 16GB VRAM
- Per-user adapter storage (~100MB each)
-
Inference Service
- Pre-loaded base model with on-demand adapter loading
- Container reuse for low-latency responses
- Automatic fallback to base model if adapter unavailable
- Python 3.11+
- Node.js 18+
- Modal account (for GPU compute)
- Google Cloud Console project with Gmail API enabled
- Clone the repository
git clone https://github.com/yourusername/expressme.git
cd expressme- Set up Modal
pip install modal
modal token new- Backend Setup
cd backend
pip install -r requirements.txt- Frontend Setup
cd frontend
npm install- Configure environment variables
Create .env files in both backend and frontend directories (see examples below).
- Deploy Modal functions
modal deploy modal_training.py- Start the backend
cd backend
python server.py- Start the frontend
cd frontend
npm run devVisit http://localhost:3000 to access the application.
Create backend/.env:
# Modal configuration
MODAL_TOKEN_ID=your_modal_token_id
MODAL_TOKEN_SECRET=your_modal_token_secret
# Optional: Custom model settings
BASE_MODEL_NAME=meta-llama/Llama-3.2-3B-Instruct
MAX_TRAINING_EMAILS=500Create frontend/.env.local:
# API endpoint
NEXT_PUBLIC_API_URL=http://localhost:8000
# Google OAuth (from Google Cloud Console)
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your_google_client_id- Email Extraction: Fetches last 500 sent emails from Gmail
- Data Cleaning:
- Removes quoted text and signatures
- Filters out code snippets and technical content
- Smart line-break processing to preserve formatting
- Prompt Generation: Uses Phi-3 to create diverse training prompts
- Fine-tuning: LoRA training with 4-bit quantization
- Storage: Saves adapter to Modal volume for persistence
- Base Model: Llama-3.2 3B Instruct
- LoRA Configuration: r=16, alpha=32, all-linear targeting
- Training: 5 epochs, batch size 1, gradient accumulation 8
- Quantization: 4-bit NF4 with double quantization
- Memory Usage: ~12GB VRAM during training
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- This project requires a Google Cloud project with Gmail API enabled
- You'll need to configure OAuth consent screen for Gmail access
- Modal usage incurs costs based on GPU compute time (~$0.50 per training session)
- The system currently supports English emails only