Skip to content

romeerp/expressme

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExpressMe - Personalized Email Generation System

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.

🎯 Key Features

  • 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

🏗 Architecture

Core Components

  1. 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
  2. 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)
  3. 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

🚀 Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • Modal account (for GPU compute)
  • Google Cloud Console project with Gmail API enabled

Installation

  1. Clone the repository
git clone https://github.com/yourusername/expressme.git
cd expressme
  1. Set up Modal
pip install modal
modal token new
  1. Backend Setup
cd backend
pip install -r requirements.txt
  1. Frontend Setup
cd frontend
npm install
  1. Configure environment variables

Create .env files in both backend and frontend directories (see examples below).

Running the Application

  1. Deploy Modal functions
modal deploy modal_training.py
  1. Start the backend
cd backend
python server.py
  1. Start the frontend
cd frontend
npm run dev

Visit http://localhost:3000 to access the application.

🔧 Configuration

Backend Environment Variables

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=500

Frontend Environment Variables

Create 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

📊 Technical Details

Training Pipeline

  1. Email Extraction: Fetches last 500 sent emails from Gmail
  2. Data Cleaning:
    • Removes quoted text and signatures
    • Filters out code snippets and technical content
    • Smart line-break processing to preserve formatting
  3. Prompt Generation: Uses Phi-3 to create diverse training prompts
  4. Fine-tuning: LoRA training with 4-bit quantization
  5. Storage: Saves adapter to Modal volume for persistence

Model Specifications

  • 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

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Important Notes

  • 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

🔗 Related Technologies

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors