# 🧠 Active Reading Demo - Deployment Guide This directory contains a streamlined version of the Enterprise Active Reading Framework optimized for Hugging Face Spaces deployment. ## 📁 Files Overview ``` demo/ ├── app.py # Main Gradio application ├── requirements.txt # Minimal dependencies for HF Spaces ├── README.md # HF Space description (will appear on space page) ├── BLOG.md # Comprehensive blog post about Active Reading ├── SPACE_BLOG.md # Shorter, HF Space focused blog └── DEMO_README.md # This file - deployment instructions ``` ## 🚀 Quick Deploy to Hugging Face Spaces ### Option 1: Automated Script (Recommended) ```bash # From project root ./scripts/deploy_hf_space.sh YOUR_HF_USERNAME active-reading-demo ``` ### Option 2: Manual Deployment ```bash # 1. Create new space at https://huggingface.co/new-space # - Choose: Gradio SDK, Public visibility # - Hardware: CPU Basic (free) # 2. Copy demo files to new directory cp -r demo/ hf-deploy/ cd hf-deploy/ # 3. Initialize git and push git init git add . git commit -m "Active Reading demo" git remote add origin https://huggingface.co/spaces/YOUR_USERNAME/SPACE_NAME git push -u origin main ``` ## 🎯 Demo Features ### Interactive Interface - **Sample Documents**: Financial, Legal, Technical, Medical examples - **Multiple Strategies**: Fact extraction, summarization, Q&A generation - **Real-time Processing**: Watch AI analyze documents live - **Structured Output**: JSON formatted results for integration ### Sample Documents Included - **📊 Financial Report**: Quarterly earnings with growth metrics - **⚖️ Legal Contract**: Software licensing agreement - **🔧 Technical Manual**: API documentation - **🏥 Medical Research**: Clinical trial results ### Active Reading Strategies - **Fact Extraction**: Structured information capture - **Summarization**: Concise document overviews - **Question Generation**: Comprehension assessment - **Complete Analysis**: All strategies combined ## 🔧 Technical Details ### Model Configuration - **Model**: `microsoft/DialoGPT-small` (optimized for HF Spaces) - **Device**: Auto-detection (CPU/GPU) - **Memory**: Optimized for free tier limits - **Processing**: Real-time with progress indicators ### Dependencies ``` torch>=2.0.0 transformers>=4.30.0 gradio>=4.0.0 numpy>=1.24.0 ``` ### Hardware Requirements - **Minimum**: CPU Basic (FREE on HF Spaces) - **Recommended**: CPU Upgrade ($0.05/hour) - **Optimal**: GPU T4 ($0.60/hour) for faster processing ## 📊 Performance Expectations ### Processing Speed - **CPU Basic**: 10-30 seconds per document - **CPU Upgrade**: 5-15 seconds per document - **GPU T4**: 2-5 seconds per document ### Document Limits - **Text Length**: Up to 2000 words (demo limitation) - **Concurrent Users**: 10-50 depending on hardware - **Response Time**: 95th percentile under 30 seconds ## 🎨 Customization Options ### Branding Update in `app.py`: ```python # Change title and description gr.Blocks(title="Your Company Active Reading", theme=gr.themes.Soft()) # Update header gr.Markdown("# 🧠 Your Company Active Reading Demo") ``` ### Sample Documents Add your own samples in `app.py`: ```python sample_texts = { "Your Document Type": """ Your sample content here... """, # ... existing samples } ``` ### Strategies Extend reading strategies: ```python # In SimpleActiveReader class def custom_strategy(self, text: str) -> List[str]: # Your custom processing logic return results ``` ## 📈 Analytics and Monitoring ### Built-in Metrics - Document processing counts - Strategy usage patterns - Error rates and performance - User interaction patterns ### HF Spaces Analytics - View usage stats in HF Spaces dashboard - Monitor resource consumption - Track user engagement ## 🔒 Security Considerations ### Demo Limitations - **No data persistence**: Sessions are temporary - **No user authentication**: Public access - **Limited PII protection**: Basic patterns only - **No audit logging**: Demo purposes only ### For Production Use Upgrade to full enterprise framework for: - User authentication and authorization - Comprehensive PII detection - Audit logging and compliance - Data encryption and persistence ## 🐛 Troubleshooting ### Common Issues **Model Loading Errors**: ```bash # Check if model downloads properly python -c "from transformers import AutoTokenizer; AutoTokenizer.from_pretrained('microsoft/DialoGPT-small')" ``` **Memory Issues**: - Reduce max_length in model config - Use smaller batch sizes - Upgrade to paid HF Spaces hardware **Slow Performance**: - Upgrade to GPU hardware - Optimize chunk sizes - Cache model loading ### Error Messages - **"Model not loaded"**: Model initialization failed - **"Processing timeout"**: Document too large or complex - **"Memory error"**: Upgrade hardware or reduce input size ## 📚 Documentation Links ### Active Reading Research - [Original Paper](https://arxiv.org/abs/2508.09494) - [Meta AI Blog Post](https://ai.meta.com/blog/) - [Implementation Details](../IMPLEMENTATION_GUIDE.md) ### Enterprise Framework - [Full Framework](../README.md) - [Deployment Guide](../DEPLOYMENT_GUIDE.md) - [Security Features](../src/enterprise/security.py) ### Hugging Face Resources - [Spaces Documentation](https://huggingface.co/docs/hub/spaces) - [Gradio Documentation](https://gradio.app/docs/) - [Model Hub](https://huggingface.co/models) ## 🤝 Contributing ### Improve the Demo - Add new sample documents - Implement additional reading strategies - Enhance UI/UX design - Optimize performance ### Extend Functionality - Multi-language support - Advanced visualization - Integration examples - Mobile responsiveness ## 📞 Support ### For Demo Issues - Check HF Spaces logs - Review error messages - Test locally first - Update dependencies ### For Enterprise Deployment - Review full framework documentation - Contact for pilot programs - Custom implementation support - Training and consultation ## 🎉 Success Metrics ### Demo Engagement - Time spent on demo - Documents analyzed - Strategies tested - Return visitors ### Enterprise Interest - Contact form submissions - GitHub stars and forks - Enterprise inquiries - Pilot program requests --- **Ready to deploy?** Use the automated script or follow manual steps above! ```bash ./scripts/deploy_hf_space.sh YOUR_USERNAME active-reading-demo ``` 🚀 **Your Active Reading demo will be live in minutes!**