MediMind AI: Bridging Modern Medicine with Traditional Wisdom

Inspiration

"Healing is not just about medicine; it's about understanding, respecting, and bridging different ways of knowing." We were inspired by the challenge of creating an AI system that could harness the power of open-source large language models (GPT-OSS-120B and GPT-OSS-20B) to bridge the gap between modern medicine and traditional healing practices. In an era where healthcare is increasingly digital, we saw an opportunity to create a system that could work completely offline while providing culturally sensitive medical assistance.

The stark reality is that:

Many villages in my state in NE India are hours away from the nearest medical facility Internet connectivity is often intermittent Traditional healers are the first line of healthcare for many There's a wealth of traditional medical knowledge passed down through generations This project was born from the vision of bridging these gaps, creating a solution that works both online and offline, respecting and integrating traditional medical knowledge while providing access to modern medical insights.

What it does

MediMind AI is an innovative healthcare assistant that leverages two powerful open-source models to provide comprehensive medical assistance:

Intelligent Model Selection

# From ai_engine.py
def select_model(query):
    if is_emergency(query) or len(query) < 100:
        return 'gpt-oss-20b'  # Fast response for urgent queries
    return 'gpt-oss-120b'     # Detailed analysis for complex queries

Real-time Performance Monitoring

// From model_aware.js
function updateModelStats(response) {
    document.getElementById('responseTime').textContent = `${response.time}ms`;
    document.getElementById('modelMode').textContent = 
        response.model === 'gpt-oss-20b' ? 'Fast Response' : 'Detailed Analysis';
}

Key Features:

  • Dual Model System: Uses GPT-OSS-20B for rapid responses and GPT-OSS-120B for detailed analysis
  • Cultural Bridge: Integrates traditional healing knowledge with modern medicine
  • Offline Operation: Complete functionality without internet connectivity
  • Smart Model Switching: Automatic selection based on query urgency and complexity
  • Performance Tracking: Real-time monitoring of model response times and switches ## How we built it We developed a sophisticated system that leverages the power of GPT-OSS models:

Model Integration

# From models/ai_engine.py
class AIEngine:
    def __init__(self):
        self.models = {
            'fast': load_model('gpt-oss-20b'),
            'detailed': load_model('gpt-oss-120b')
        }
        self.knowledge_base = KnowledgeBase()

Knowledge Base Structure

// From static/app.js
async function loadKnowledgeBase() {
    const cultural_bridge = await fetch('/data/cultural_bridge.json');
    const modern_medicine = await fetch('/data/modern_medicine.json');
    const traditional_medicine = await fetch('/data/traditional_medicine.json');
    // Integration of different knowledge sources
}

Basic Response System

# From models/symptom_analyzer.py
def analyze_symptoms(query):
    # Basic keyword-based urgency detection
    emergency_keywords = ['severe', 'urgent', 'emergency', 'critical']
    is_urgent = any(keyword in query.lower() for keyword in emergency_keywords)

    return {
        'model': 'gpt-oss-20b' if is_urgent or len(query) < 100 else 'gpt-oss-120b',
        'context': 'basic'
    }

Technology Stack:

Languages and Frameworks

  • Backend:

    • Python 3.12
    • Flask web framework
    • SQLAlchemy ORM
  • Frontend:

    • HTML5/CSS3/JavaScript
    • Progressive Web App (PWA)
    • Font Awesome for UI icons

Models and AI

  • Primary Models:
    • GPT-OSS-120B (for detailed analysis)
    • GPT-OSS-20B (for fast responses)
  • Model Integration:
    • Hugging Face Transformers
    • Custom model switching logic

Database and Storage

  • Database: SQLite3 for offline-first operation
  • Data Format: JSON for knowledge bases
  • Files Structure: data/ ├── cultural_bridge.json ├── modern_medicine.json └── traditional_medicine.json

Development Tools

  • Version Control: Git/GitHub
  • IDE: Visual Studio Code
  • API Testing: Postman

Features and APIs

  • Speech Recognition: Web Speech API
  • Text-to-Speech: Browser native TTS
  • Offline Support: Service Workers
  • Real-time Monitoring: Custom metrics system

Challenges we ran into

Model Integration Challenges

// Initial challenge with model switching
modelSwitch.addEventListener('change', async (event) => {
    try {
        await switchModel(event.target.checked ? 'gpt-oss-120b' : 'gpt-oss-20b');
    } catch (error) {
        console.error('Model switch failed:', error);
        // Fallback mechanism needed
    }
});

Key Challenges:

  1. Model Size Management:

    • Optimizing GPT-OSS-120B for reasonable response times
    • Balancing memory usage between two models
  2. Response Time Optimization:

    • Implementing efficient model switching
    • Reducing latency in emergency scenarios
  3. Cultural Integration:

    • Creating accurate mappings between traditional and modern terms
    • Maintaining cultural sensitivity in responses
  4. Technical Limitations:

    • Managing memory with two large models
    • Ensuring smooth offline operation
    • Handling concurrent model access ## Accomplishments that we're proud of

Successful Model Integration

# Initial performance metrics from our testing
class ModelMetrics:
    def __init__(self):
        self.response_times = {
            'gpt-oss-20b': avg_ms=800,  # Basic implementation for emergencies
            'gpt-oss-120b': avg_ms=2000  # Initial version for detailed analysis
        }

Key Achievements:

  1. Technical Innovation:

    • Successfully integrated both GPT-OSS models with basic switching mechanism
    • Implemented initial version of emergency response system
    • Developed foundational model selection logic
  2. Knowledge Integration:

    • Created basic cultural bridge database structure
    • Implemented initial knowledge retrieval system
    • Developed basic medical term mapping between traditional and modern medicine
  3. User Experience:

    • Real-time performance monitoring
    • Adaptive response system
    • Cultural sensitivity in responses ## What we learned

Technical Insights

# Lessons from model optimization
def optimize_model_selection(query_length, urgency, cultural_context):
    if urgency > 0.8:
        return 'gpt-oss-20b'  # Learned: Fast model crucial for emergencies
    if cultural_context.complexity > 0.7:
        return 'gpt-oss-120b'  # Learned: Detailed model better for cultural nuance

Key Learnings:

  1. Model Optimization:

    • GPT-OSS-20B excels at quick, emergency responses
    • GPT-OSS-120B provides better cultural context understanding
    • Efficient model switching is crucial for user experience
  2. Cultural Integration:

    • The importance of preserving traditional knowledge
    • Methods for mapping traditional to modern medical terms
    • Techniques for cultural context detection
  3. System Architecture:

    • Strategies for offline-first applications
    • Approaches to managing multiple AI models
    • Techniques for real-time performance monitoring ## What's next for MediMind AI

Model Enhancement

# Planned model improvements
class FutureEnhancements:
    def __init__(self):
        self.planned_features = {
            'fine_tuning': 'Specialized medical domain adaptation',
            'multilingual': 'Support for 10+ languages',
            'hardware': 'Optimization for edge devices',
            'integration': 'API for healthcare systems'
        }

Development Roadmap:

  1. Model Optimization (Future Plans):

    • Fine-tune GPT-OSS models for medical domain
    • Add support for regional languages
    • Improve emergency response accuracy
    • Implement advanced cultural context detection
  2. Technical Enhancements (Planned):

    • Optimize for mobile devices
    • Enhance offline capabilities
    • Add advanced symptom analysis
    • Implement better model switching logic
    • Add more sophisticated cultural mappings
  3. Knowledge Expansion:

    • Expand traditional medicine database
    • Add more cultural contexts
    • Integrate with medical research databases
  4. Community Features:

    • Collaborative knowledge sharing
    • Healthcare provider integration
    • Community contribution system

Our vision is to create a comprehensive healthcare AI system that combines the best of traditional wisdom and modern medicine, powered by state-of-the-art open-source language models.

Built With

Share this project:

Updates