Skip to content

thrishank007/NeuraX

Repository files navigation

NeuraX - Offline Multimodal RAG System

Python 3.8+ License: MIT Build Status

Overview

NeuraX is a production-ready offline multimodal Retrieval-Augmented Generation (RAG) system designed for NTRO's SIH 2025 problem statement. It provides secure, air-gapped document intelligence with advanced multimodal capabilities and enterprise-grade security features.

Demo:

Watch the video

✨ Key Features

πŸ”’ Security & Privacy

  • Complete Offline Operation: Zero internet dependencies, air-gapped deployment
  • Knowledge Graph Security: Real-time anomaly detection and tamper protection
  • Audit Logging: Comprehensive activity tracking and compliance monitoring
  • Data Sovereignty: All processing occurs locally with no external API calls

πŸ€– Advanced AI Capabilities

  • Multimodal Understanding: Process documents, images, and audio seamlessly
  • Cross-Modal Search: Find relevant content across different data types
  • LM Studio Integration: Local LLM hosting with Gemma 3n (multimodal) and Qwen3 4B (reasoning)
  • CLIP Embeddings: State-of-the-art visual-text similarity matching
  • Intelligent Citations: Numbered references with confidence scores and expandable sources

πŸ“ Comprehensive Format Support

  • Documents: PDF, DOCX, DOC, TXT with OCR fallback
  • Images: JPG, JPEG, PNG, BMP, TIFF, WEBP with visual similarity search
  • Audio: WAV, MP3, M4A, FLAC, OGG with speech-to-text processing
  • Batch Processing: Handle multiple files simultaneously with progress tracking

πŸš€ Production Features

  • Auto-Deployment: One-click executable generation with PyInstaller
  • USB Portability: Export complete system to USB for air-gapped deployment
  • Performance Optimization: Memory-efficient processing with GPU acceleration
  • Error Resilience: Graceful degradation and comprehensive error handling
  • Real-time Feedback: User feedback collection and performance metrics

πŸ—οΈ Architecture

Core Components

  • LM Studio Integration: Local LLM server for multimodal and reasoning tasks
  • ChromaDB: Persistent vector database for semantic search
  • CLIP Embeddings: Visual-text cross-modal understanding
  • Whisper STT: Speech-to-text for audio processing
  • NetworkX: Knowledge graph with security monitoring
  • Gradio UI: Modern web interface for end users
  • Streamlit Dashboard: Analytics and system monitoring

πŸ› οΈ System Requirements

Minimum Requirements

  • Python: 3.8+ (3.9+ recommended for optimal performance)
  • Memory: 8GB RAM (16GB+ recommended for large datasets)
  • Storage: 5GB free space (models are managed via LM Studio)
  • OS: Windows 10+, Linux (Ubuntu 18.04+), macOS 10.15+

Recommended Setup

  • Memory: 16GB+ RAM for smooth operation
  • GPU: 6GB+ VRAM for accelerated processing (CPU fallback available)
  • Storage: 10GB+ for cache and data processing
  • Network: None required during operation (offline-first design)

Dependencies

  • LM Studio: For local LLM hosting (Gemma 3n + Qwen3 4B)
  • Tesseract OCR: For document text extraction (auto-bundled)
  • FFmpeg: For audio processing (platform-specific installation)

πŸš€ Quick Start

Option 1: Automated Installation (Recommended)

# Clone the repository
git clone https://github.com/thrishank007/NeuraX.git
cd NeuraX

# Run automated setup
python install_dependencies.py

# Setup LM Studio integration
python migrate_to_lmstudio.py

# Launch the system
python main_launcher.py

Option 2: Manual Installation

# Clone repository
git clone https://github.com/thrishank007/NeuraX.git
cd NeuraX

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Install system dependencies (platform-specific)
# Ubuntu/Debian: sudo apt-get install tesseract-ocr ffmpeg
# macOS: brew install tesseract ffmpeg
# Windows: Automated via install_dependencies.py

# Launch system
python main_launcher.py

Option 3: Portable Executable

# Build portable executable
python build_executables.py

# Deploy to USB or air-gapped system
# Executable will be in packages/ directory

🎯 LM Studio Setup (Required)

NeuraX uses LM Studio for local LLM hosting, providing better performance and easier model management:

1. Install LM Studio

2. Download Models

In LM Studio, search for and download:

  • Gemma 3n: For multimodal queries (text + images)
  • Qwen3 4B Thinking 2507: For complex reasoning tasks

3. Start Local Server

  1. Go to "Local Server" tab in LM Studio
  2. Load your preferred model (Gemma for multimodal, Qwen for reasoning)
  3. Start server on localhost:1234
  4. Verify server is running with green status indicator

4. Test Integration

python test_lmstudio_integration.py

πŸ’» Usage Examples

Basic Document Processing

# Upload documents via Gradio interface
# Supported: PDF, DOCX, DOC, TXT files
# Automatic text extraction and indexing

# Query your documents
query = "What are the main findings in the research?"
# System returns relevant passages with citations

Multimodal Search

# Upload images along with documents
# Supported: JPG, PNG, BMP, TIFF, WEBP

# Cross-modal queries
query = "Find documents related to this chart"
# System matches visual content with textual descriptions

Audio Processing

# Upload audio files
# Supported: WAV, MP3, M4A, FLAC, OGG

# Audio-to-text search
query = "What was discussed about budget planning?"
# System transcribes audio and searches content

πŸ“‚ Project Structure

NeuraX/
β”œβ”€β”€ πŸ“ ingestion/              # Multimodal data processors
β”‚   β”œβ”€β”€ document_processor.py  # PDF, DOCX, DOC, TXT processing
β”‚   β”œβ”€β”€ image_processor.py     # Image analysis and OCR
β”‚   β”œβ”€β”€ audio_processor.py     # Speech-to-text conversion
β”‚   β”œβ”€β”€ notes_processor.py     # Structured note processing
β”‚   └── ingestion_manager.py   # Orchestrates all processors
β”‚
β”œβ”€β”€ πŸ“ indexing/               # Vector embeddings and storage
β”‚   β”œβ”€β”€ embedding_manager.py   # CLIP + text embeddings
β”‚   β”œβ”€β”€ vector_store.py        # ChromaDB interface
β”‚   β”œβ”€β”€ cache_manager.py       # Embedding cache optimization
β”‚   β”œβ”€β”€ memory_manager.py      # Memory usage optimization
β”‚   └── performance_benchmarker.py # Performance monitoring
β”‚
β”œβ”€β”€ πŸ“ retrieval/              # Query processing
β”‚   β”œβ”€β”€ query_processor.py     # Multimodal query handling
β”‚   └── speech_to_text_processor.py # Audio query processing
β”‚
β”œβ”€β”€ πŸ“ generation/             # LLM integration
β”‚   β”œβ”€β”€ lmstudio_generator.py  # LM Studio API client
β”‚   β”œβ”€β”€ llm_factory.py         # Model selection logic
β”‚   β”œβ”€β”€ llm_generator.py       # Legacy HF integration
β”‚   └── citation_generator.py  # Citation formatting
β”‚
β”œβ”€β”€ πŸ“ kg_security/            # Knowledge graph security
β”‚   β”œβ”€β”€ knowledge_graph_manager.py # Graph construction
β”‚   β”œβ”€β”€ anomaly_detector.py    # Security monitoring
β”‚   β”œβ”€β”€ security_event_logger.py # Audit logging
β”‚   └── feedback_integration.py # User feedback processing
β”‚
β”œβ”€β”€ πŸ“ feedback/               # Feedback system
β”‚   β”œβ”€β”€ feedback_system.py     # User feedback collection
β”‚   β”œβ”€β”€ metrics_collector.py   # Performance metrics
β”‚   └── πŸ“ exports/            # Feedback data exports
β”‚
β”œβ”€β”€ πŸ“ ui/                     # User interfaces
β”‚   β”œβ”€β”€ gradio_app.py          # Main web interface
β”‚   β”œβ”€β”€ streamlit_dashboard.py # Analytics dashboard
β”‚   └── demo_gradio_app.py     # Demo interface
β”‚
β”œβ”€β”€ πŸ“ tests/                  # Comprehensive test suite
β”‚   β”œβ”€β”€ test_*.py              # Unit and integration tests
β”‚   └── conftest.py            # Test configuration
β”‚
β”œβ”€β”€ πŸ“ models/                 # Local model cache (LM Studio managed)
β”œβ”€β”€ πŸ“ data/                   # Input data and samples
β”œβ”€β”€ πŸ“ vector_db/              # ChromaDB persistent storage
β”œβ”€β”€ πŸ“ cache/                  # Embedding and processing cache
β”œβ”€β”€ πŸ“ logs/                   # System logs and error reports
β”‚
β”œβ”€β”€ πŸ”§ config.py               # Central configuration
β”œβ”€β”€ πŸš€ main_launcher.py        # Application orchestrator
β”œβ”€β”€ πŸ“‹ requirements.txt        # Python dependencies
β”œβ”€β”€ πŸ› οΈ install_dependencies.py # Automated setup script
β”œβ”€β”€ πŸ“¦ build_executables.py    # Portable build script
β”œβ”€β”€ πŸ”„ migrate_to_lmstudio.py  # LM Studio migration tool
└── πŸ§ͺ test_*.py              # Verification and test scripts

πŸ”§ Configuration

Core Settings (config.py)

# LM Studio Configuration
LM_STUDIO_CONFIG = {
    "base_url": "http://localhost:1234/v1",
    "gemma_model": "google/gemma-3n",           # Multimodal model
    "qwen_model": "qwen/qwen3-4b-thinking-2507", # Reasoning model
    "auto_model_switching": True,               # Auto switch based on query type
}

# Security Configuration
SECURITY_CONFIG = {
    "allowed_file_extensions": [
        ".pdf", ".docx", ".doc", ".txt",        # Documents
        ".jpg", ".jpeg", ".png", ".bmp", ".tiff", ".webp", # Images
        ".wav", ".mp3", ".m4a", ".flac", ".ogg" # Audio
    ],
    "max_file_size_mb": 100,
    "enable_audit_logging": True,
}

Advanced Configuration

  • Performance tuning: Memory thresholds, batch sizes, GPU settings
  • Security policies: File validation, audit logging, anomaly detection
  • UI customization: Interface themes, component visibility
  • Model preferences: LLM selection, embedding models, fallback strategies

πŸ§ͺ Testing & Validation

Automated Testing Suite

# Run complete test suite
python -m pytest tests/

# Test specific components
python test_image_query_no_ocr.py     # Image processing
python test_multimodal_simple.py      # Multimodal queries  
python test_lmstudio_integration.py   # LM Studio integration
python test_final_verification.py     # End-to-end validation

Manual Testing

# Test file upload interface
python test_file_upload_interface_fix.py

# Validate system performance  
python test_vector_store.py

# Check citation generation
python test_citation_fix.py

🚒 Deployment Options

Option 1: Standard Installation

  • Install Python dependencies via pip
  • Setup LM Studio separately
  • Run via python main_launcher.py

Option 2: Portable Executable

# Build self-contained executable
python build_executables.py

# Generates:
# - NeuraX-Windows-x64.zip
# - USB_Deployment/ folder for air-gapped systems

Option 3: USB Deployment

# Create USB-ready package
python build_executables.py --usb-deployment

# Copy USB_Deployment/ contents to USB drive
# Includes autorun.inf for Windows systems

Air-Gapped Deployment

  1. Build executable on internet-connected system
  2. Copy package to air-gapped environment
  3. Install LM Studio and download models offline
  4. Run executable with zero internet dependencies

πŸ“Š Performance Metrics

Processing Speeds

  • Document Indexing: 50-100 documents/minute
  • Image Processing: 25-50 images/minute
  • Audio Transcription: Real-time (1x speed with Whisper-tiny)
  • Query Response: 200-500ms average
  • Vector Search: 4.7+ items/second similarity search

Resource Usage

  • Memory: 4-8GB typical usage (scales with data size)
  • Storage: 100MB base + data size + cache
  • GPU: Optional but recommended for large datasets
  • CPU: Efficient with multi-core utilization

πŸ›‘οΈ Security Features

Data Protection

  • Local Processing: All data remains on local system
  • Encrypted Storage: Vector database encryption at rest
  • Audit Trails: Comprehensive activity logging
  • Access Control: File type and size validation

Anomaly Detection

  • Knowledge Graph Monitoring: Real-time graph analysis
  • Behavioral Analysis: Unusual query pattern detection
  • Tamper Detection: Content integrity verification
  • Alert System: Automated security event notifications

🀝 Contributing & Support

Development Setup

# Clone for development
git clone https://github.com/thrishank007/NeuraX.git
cd NeuraX

# Install development dependencies
pip install -r requirements.txt
pip install pytest black flake8

# Run tests before committing
python -m pytest tests/

Known Issues & Solutions

  • Tesseract OCR: Auto-bundled in executables, manual install for dev
  • GPU Memory: Adjust batch sizes in config for lower VRAM systems
  • LM Studio Connection: Ensure server is running on localhost:1234
  • Large Files: Use batch processing for datasets >1GB

Documentation

  • API Reference: /docs/api/ (generated from code)
  • Architecture Guide: /docs/architecture.md
  • Deployment Guide: /docs/deployment.md
  • Troubleshooting: /docs/troubleshooting.md

πŸ“ˆ Roadmap

Current Version (v1.0)

  • βœ… Complete offline multimodal RAG system
  • βœ… LM Studio integration with Gemma 3n + Qwen3 4B
  • βœ… Cross-modal search capabilities
  • βœ… Portable executable generation
  • βœ… Enterprise security features

Future Enhancements (v1.1+)

  • πŸ”„ Additional LLM integrations (Ollama, LocalAI)
  • πŸ”„ Enhanced video processing capabilities
  • πŸ”„ Multi-language support expansion
  • πŸ”„ Advanced analytics dashboard
  • πŸ”„ Distributed deployment options

πŸ“„ License

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

πŸ† Acknowledgments

  • NTRO SIH 2025: Problem statement and requirements definition
  • Hugging Face: CLIP and Transformer models
  • LM Studio: Local LLM hosting platform
  • ChromaDB: Vector database infrastructure
  • Gradio: Modern web interface framework

Built with ❀️ for secure, offline AI document intelligence

For detailed documentation, visit: Documentation
For support and issues: GitHub Issues

About

NeuraX is a production-ready offline multimodal Retrieval-Augmented Generation (RAG) system designed for NTRO's SIH 2025 problem statement. It provides secure, air-gapped document intelligence with advanced multimodal capabilities and enterprise-grade security features.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages