--- title: Scholar Express emoji: โœˆ๏ธ colorFrom: green colorTo: yellow sdk: gradio sdk_version: 5.38.2 app_file: app.py pinned: false --- # Scholar Express ## AI-Powered Accessible Academic Research Platform Scholar Express is an innovative AI-powered platform that transforms inaccessible scientific research papers into interactive, screen-reader compatible documents. The system addresses critical accessibility barriers faced by students with disabilities in academic research, leveraging specialized AI models to make scientific literature truly inclusive. ## ๐ŸŽฏ Problem Statement According to the U.S. National Center for Education Statistics, a significant portion of undergraduate students have disabilities: - 18% of male undergraduate students - 22% of female undergraduate students - 54% of nonbinary undergraduate students These students face major barriers when conducting research, as scientific PDFs are fundamentally inaccessible to screen readers due to complex mathematical equations, figures, and diagrams lacking alt text descriptions. ## ๐Ÿš€ Key Features ### Document Processing - **OCR and layout analysis** optimized for scientific papers - **Table and figure extraction** with proper formatting for research content - **AI-generated alt text** specifically for scientific diagrams, charts, and equations - **Structured markdown output** that preserves document hierarchy ### Interactive Features - **RAG-powered chatbot** for scientific document Q&A - **Real-time voice conversations** about research content - **Multi-tab interface** optimized for research workflows ### Accessibility Focus - **Screen reader compatible** output - **Descriptive alt text** for all figures following WCAG guidelines - **Privacy-first design** with local processing ## ๐Ÿ—๏ธ System Architecture ### Core AI Models The platform utilizes a specialized ensemble of AI models, each optimized for specific tasks: - **Gemma 3n 4B**: Primary engine for alt text generation and document chatbot functionality - **Gemma 3n 2B**: Specialized for real-time voice chat interactions - **DOLPHIN**: Handles PDF layout analysis and text extraction - **SentenceTransformer**: Enables semantic search for Retrieval-Augmented Generation (RAG) ### Processing Pipeline #### PDF Processing ``` PDF Upload โ†’ Image Conversion โ†’ Layout Analysis โ†’ Element Extraction โ†’ Alt Text Generation โ†’ Markdown Output ``` #### Chat System ``` User Question โ†’ Document Search โ†’ Context Retrieval โ†’ AI Response (Gemma 3n 4B) ``` #### Voice System ``` Audio Input โ†’ Speech Detection โ†’ Voice Processing โ†’ Text Response โ†’ Speech Output ``` ## ๐Ÿ“ Project Structure ``` Scholar-Express/ โ”œโ”€โ”€ ๐Ÿ“„ Core Application Files โ”‚ โ”œโ”€โ”€ app.py # Main Gradio application with multi-tab interface โ”‚ โ”œโ”€โ”€ chat.py # Document chat functionality โ”‚ โ”œโ”€โ”€ gradio_final_app.py # Final integrated Gradio application โ”‚ โ””โ”€โ”€ gradio_local_gemma.py # Local Gemma model integration โ”‚ โ”œโ”€โ”€ ๐Ÿ”ง Configuration & Dependencies โ”‚ โ”œโ”€โ”€ requirements.txt # Main project dependencies โ”‚ โ”œโ”€โ”€ requirements_gemma.txt # Gemma-specific dependencies โ”‚ โ”œโ”€โ”€ requirements_voice_gemma.txt # Voice chat dependencies โ”‚ โ”œโ”€โ”€ requirements_hf_spaces.txt # HuggingFace Spaces deployment โ”‚ โ”œโ”€โ”€ pyproject.toml # Project configuration (Black formatting) โ”‚ โ””โ”€โ”€ config/ โ”‚ โ””โ”€โ”€ Dolphin.yaml # DOLPHIN model configuration โ”‚ โ”œโ”€โ”€ ๐Ÿ› ๏ธ Utility Modules โ”‚ โ””โ”€โ”€ utils/ โ”‚ โ”œโ”€โ”€ markdown_utils.py # Markdown processing utilities โ”‚ โ”œโ”€โ”€ model.py # AI model management โ”‚ โ”œโ”€โ”€ processor.py # Document processing utilities โ”‚ โ””โ”€โ”€ utils.py # General utility functions โ”‚ โ”œโ”€โ”€ ๐ŸŽค Voice Chat System โ”‚ โ””โ”€โ”€ voice_chat/ โ”‚ โ”œโ”€โ”€ app.py # Voice chat Gradio interface โ”‚ โ”œโ”€โ”€ gemma3n_inference.py # Gemma 3n voice inference โ”‚ โ”œโ”€โ”€ inference.py # General inference utilities โ”‚ โ”œโ”€โ”€ server.py # Voice chat server โ”‚ โ”œโ”€โ”€ requirements.txt # Voice-specific dependencies โ”‚ โ”œโ”€โ”€ litgpt/ # LitGPT integration โ”‚ โ”‚ โ”œโ”€โ”€ config.py # Model configuration โ”‚ โ”‚ โ”œโ”€โ”€ model.py # Model architecture โ”‚ โ”‚ โ”œโ”€โ”€ tokenizer.py # Tokenization utilities โ”‚ โ”‚ โ””โ”€โ”€ generate/ # Text generation utilities โ”‚ โ”œโ”€โ”€ utils/ โ”‚ โ”‚ โ”œโ”€โ”€ vad.py # Voice Activity Detection โ”‚ โ”‚ โ”œโ”€โ”€ snac_utils.py # Audio processing utilities โ”‚ โ”‚ โ””โ”€โ”€ assets/ โ”‚ โ”‚ โ””โ”€โ”€ silero_vad.onnx # Silero VAD model โ”‚ โ””โ”€โ”€ data/samples/ # Audio sample outputs โ”‚ โ”œโ”€โ”€ ๐Ÿค– Pre-trained Models โ”‚ โ””โ”€โ”€ hf_model/ # HuggingFace model files โ”‚ โ”œโ”€โ”€ config.json # Model configuration โ”‚ โ”œโ”€โ”€ model.safetensors # Model weights โ”‚ โ”œโ”€โ”€ tokenizer.json # Tokenizer configuration โ”‚ โ””โ”€โ”€ generation_config.json # Generation parameters โ”‚ โ”œโ”€โ”€ ๐Ÿงช Development & Demo Files โ”‚ โ”œโ”€โ”€ demo_element_hf.py # Element extraction demo โ”‚ โ”œโ”€โ”€ demo_page_hf.py # Page processing demo โ”‚ โ”œโ”€โ”€ gradio_pdf_app.py # PDF processing demo โ”‚ โ”œโ”€โ”€ gradio_image_app.py # Image processing demo โ”‚ โ”œโ”€โ”€ gradio_gemma.py # Gemma integration demo โ”‚ โ””โ”€โ”€ gradio_gemma_api.py # Gemma API demo โ”‚ โ””โ”€โ”€ ๐Ÿ“š Documentation โ”œโ”€โ”€ README.md # This comprehensive guide โ””โ”€โ”€ Scholar_Express_Technical_Write_Up.pdf # Detailed technical documentation ``` ### ๐Ÿ”‘ Essential Files Explained #### Core Application - **`app.py`**: Main entry point with complete Gradio interface featuring PDF processing, document chat, and voice interaction tabs #### Configuration & Dependencies - **`requirements.txt`**: Complete dependency list including PyTorch, Transformers, Gradio, PDF processing, and voice libraries - **`requirements_voice_gemma.txt`**: Specialized dependencies for voice chat (LitGPT, SNAC, Whisper) - **`config/Dolphin.yaml`**: Configuration file for DOLPHIN model parameters and settings #### Utility Modules (`utils/`) - **`model.py`**: AI model loading, initialization, and management functions - **`processor.py`**: PDF processing, image extraction, and document parsing utilities - **`markdown_utils.py`**: Markdown generation and formatting for accessible output - **`utils.py`**: General helper functions for file handling and data processing #### Voice Chat System (`voice_chat/`) - **`gemma3n_inference.py`**: Core Gemma 3n 2B inference engine for voice processing - **`utils/vad.py`**: Voice Activity Detection using Silero VAD model - **`utils/snac_utils.py`**: Audio preprocessing and formatting utilities - **`litgpt/`**: Lightweight GPT implementation for efficient voice processing #### Model Files (`hf_model/`) - **`model.safetensors`**: Pre-trained model weights in SafeTensors format - **`config.json`**: Model architecture and parameter configuration - **`tokenizer.json`**: Tokenization rules and vocabulary ### ๐Ÿ“‹ Dependency Categories The project uses multiple requirement files for different deployment scenarios: | File | Purpose | Key Dependencies | |------|---------|------------------| | `requirements.txt` | Main application | PyTorch, Transformers, Gradio, PyMuPDF | | `requirements_voice_gemma.txt` | Voice features | LitGPT, SNAC, Whisper, Librosa | | `requirements_hf_spaces.txt` | HuggingFace deployment | Streamlined for cloud deployment | | `requirements_gemma.txt` | Gemma-specific | Optimized for Gemma model usage | ### Key Components #### PDF Processing (`app.py:convert_pdf_to_images_gradio`) - Converts PDFs to high-quality images (2x scaling) - Uses PyMuPDF for reliable extraction #### Layout Analysis (`app.py:process_elements_optimized`) - DOLPHIN identifies text blocks, tables, figures, headers - Maintains proper reading order for accessibility #### Alt Text Generation - Gemma 3n 4B processes images with accessibility-focused prompts - Generates 1-2 sentence descriptions following WCAG guidelines - Low temperature (0.1) for consistent, reliable output #### RAG System - **Document chunking**: Smart overlap-based chunking (1024 tokens, 100 overlap) - **Semantic retrieval**: SentenceTransformer embeddings with cosine similarity - **Context integration**: Top-3 relevant chunks for accurate responses #### Voice Chat System - **Gemma 3n 2B**: Optimized for real-time voice processing - **Silero VAD**: Voice Activity Detection for speech vs silence - **gTTS**: Google Text-to-Speech for audio responses - **Audio preprocessing**: 16kHz mono, normalized amplitude ## ๐Ÿ› ๏ธ Technology Stack | Component | Technology | |-----------|------------| | Frontend | Gradio web interface with streaming capabilities | | AI Models | Gemma 3n, DOLPHIN, SentenceTransformer | | Document Processing | PyMuPDF, OpenCV, PIL | | Voice Processing | Librosa, VAD, gTTS | | Search | SentenceTransformers for semantic retrieval | ## ๐ŸŽจ Architecture Philosophy ### Right Tool for Right Job - **DOLPHIN** for PDF extraction and layout analysis - **Gemma 3n 4B** for alt text generation and document chat - **Gemma 3n 2B** for real-time voice interaction - Each component matched to its optimal model and specialization ### Privacy-First Design - All processing happens locally to protect sensitive academic content - Meets institutional privacy requirements for research documents ### Accessibility Focus - AI-generated alt text makes academic papers inclusive for visually impaired researchers - Addresses a real gap in academic publishing accessibility ## ๐Ÿš€ Getting Started 1. **Install dependencies**: The app uses Gradio, PyMuPDF, and various AI model libraries 2. **Run the application**: `python app.py` 3. **Access the interface**: Open the Gradio web interface 4. **Upload a PDF**: Use the document processing tab to convert research papers 5. **Interact**: Chat with documents or use voice features for hands-free research ## ๐Ÿ’ก Design Challenges Solved ### Challenge 1: Narrowing Down Big Ideas - Focused on three core applications: alt text, document chat, and voice interaction - Chose accessibility as the primary value proposition - Specialized each model variant (4B vs 2B) for optimal performance ### Challenge 2: Storage Limitations - Developed code-first approach with thorough review before testing - Built comprehensive error handling upfront since debugging was expensive - Improved documentation and commenting discipline ## ๐Ÿ“ˆ Impact Scholar Express bridges the accessibility gap in scientific research, ensuring that the 18-54% of students with disabilities can access the same research literature as their peers, while providing enhanced interaction capabilities for all users working with complex scientific content.