Skip to content

Latest commit

Β 

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’‘ Why MindLearn AI?

Traditional e-learning platforms treat every student query as a dry, factual database search. When a student is stuck and says "I've spent 4 hours on this recursion bug and nothing works!", traditional search engines respond with technical documentationβ€”completely missing the student's affective learning friction.

MindLearn AI (v2.0) bridges the gap between Natural Language Understanding (NLU) and Empathetic Pedagogical Support:

Capability Traditional E-Learning / Search 🧠 MindLearn AI (v2.0)
Affective Understanding ❌ None (ignores tone & sentiment) βœ… Real-time 5-Class Emotion Classification
Mixed Emotions ❌ Flat single-intent lookup βœ… Flags secondary emotions with $\ge 15%$ probability
Inference Efficiency ❌ Heavy cloud models ($>1.5\text{s}$) βœ… Fine-Tuned Compact Transformer ($\le 60\text{ms}$ CPU)
Pedagogical Strategy ❌ Generic answer dumping βœ… 3-Part empathetic coaching via Google Gemini 2.5 Flash
Resilience & Offline ❌ Hard crash on API disconnect βœ… Graceful degradation to offline pedagogical matrix
Benchmarking & Audit ❌ Black-box guessing βœ… Built-in evaluation lab with Radar & Confusion heatmaps

⚑ Multi-Tier Model Zoo & Performance

MindLearn AI features a modular 3-Tier Model Zoo managed via a decoupled ModelRegistry pattern:

                                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                  β”‚                🧠 UNIFIED MODEL REGISTRY                  β”‚
                                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                                β”‚
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β–Ό                                              β–Ό                                              β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  ⚑ COMPACT TRANSFORMER v2   β”‚                β”‚   🧠 BERT-BASE BASELINE     β”‚                β”‚     ⏱️ BiLSTM BASELINE      β”‚
  β”‚   (DistilBERT / MiniLM)     β”‚                β”‚    (Contextual Baseline)    β”‚                β”‚      (Keras + RNN Tier)     β”‚
  β”‚  β€’ 66.9M Parameters         β”‚                β”‚  β€’ 109.5M Parameters        β”‚                β”‚  β€’ 3.92M Parameters         β”‚
  β”‚  β€’ 255 MB Disk Footprint    β”‚                β”‚  β€’ 438 MB Disk Footprint    β”‚                β”‚  β€’ 4.2 MB Disk Footprint    β”‚
  β”‚  β€’ ~58.5 ms Latency (p50)   β”‚                β”‚  β€’ ~126.9 ms Latency (p50)  β”‚                β”‚  β€’ ~100.9 ms Latency (p50)  β”‚
  β”‚  β€’ 17.0 Req / Sec           β”‚                β”‚  β€’ 7.9 Req / Sec            β”‚                β”‚  β€’ 9.3 Req / Sec            β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“Š Empirical Benchmarks

Evaluated over a curated 50-sample multi-domain gold evaluation dataset on single-core CPU hardware:

Model Tier Architecture Accuracy Macro F1 Latency ($p_{50}$) Throughput Model Size Speedup vs BERT
Baseline 1 (RNN) BiLSTM + Focal Loss 40.0% 0.380 100.9 ms 9.3 req/s 4.2 MB 1.3Γ—
Baseline 2 (Transformer) bert-base-uncased 64.0% 0.587 126.9 ms 7.9 req/s 438.0 MB 1.0Γ— (Baseline)
MindLearn v2 (Compact) DistilBERT v2 52.0% 0.536 58.5 ms 17.0 req/s 255.0 MB ⚑ 2.2Γ— Faster
Latency Comparison (Median p50):
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Model Tier                           β”‚ Latency (ms)                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ BERT-Base Baseline (v1)              β”‚ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 126.9 ms    β”‚
β”‚ BiLSTM Student Adaptive              β”‚ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 100.9 ms         β”‚
β”‚ MindLearn Compact Transformer (v2)   β”‚ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 58.5 ms ⚑ (2.2x Fast) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tip

Key Architectural Takeaway: The fine-tuned Compact Transformer v2 achieves a 2.2Γ— reduction in latency and 42% smaller memory footprint with 2.15Γ— higher throughput, eliminating memory-exhaustion SIGKILL risks on cost-efficient cloud instances.


πŸ—οΈ System Architecture

graph TD
    User([πŸ‘¨β€πŸŽ“ Student Input]) --> UI[Streamlit Multi-Page Web App]
    UI --> Prep[Text Sanitization & Soft Bayesian Keyword Fusion]
    Prep --> Reg[Unified Model Registry]
    
    subgraph Model_Zoo ["Multi-Tier Model Zoo"]
        Reg --> Distil["⚑ MindLearn Compact v2 (67M Params)"]
        Reg --> BERT["🧠 BERT-Base Baseline (110M Params)"]
        Reg --> BiLSTM["⏱️ BiLSTM RNN Baseline (3.9M Params)"]
    end
    
    Distil --> LatencyEngine[Live Microsecond Latency Profiler]
    BERT --> LatencyEngine
    BiLSTM --> LatencyEngine
    
    LatencyEngine --> MixedCheck{Probability >= 15%?}
    MixedCheck -->|Primary & Secondary Emotions| GenAI[Google Gemini 2.5 Flash API]
    MixedCheck -->|Offline / API Fallback| Fallback[Static Pedagogical Templates]
    
    GenAI --> Output[Empathy Banner + Action Cards + Model Scores]
    Fallback --> Output
    
    Output --> DB[(SQLite app.db - WAL Mode)]
    Output --> CSV[CSV Audit Log]
    
    subgraph Benchmarking ["Model Benchmark & Evaluation Lab"]
        BenchEngine[Benchmark Engine & Gold Test Suite] --> Radar[Radar Charts & Confusion Matrices]
        Radar --> BenchUI[4_Model_Benchmark.py Page]
    end
Loading

🎭 5-Class Affective Taxonomy

MindLearn AI maps student emotional friction into 5 actionable learning states:

Emotion Sentiment Key Linguistic Cues AI Pedagogical Intervention Strategy
Confused πŸ˜• Negative Friction "don't understand", "lost", "puzzled", "unclear" Deconstructs the concept into first-principles analogies & step-by-step visual models.
Frustrated 😀 High Friction "impossible", "stuck", "bug keeps failing", "annoying" Validates frustration, recommends stepping away, and suggests a simplified baseline challenge.
Bored πŸ˜‘ Low Arousal "dry", "monotonous", "repetitive", "too simple" Introduces gamified learning techniques, competitive challenges, and real-world applications.
Curious 🀩 High Engagement "why does", "how to connect", "fascinated", "wonder" Provides deep-dive research links, architectural insights, and exploratory challenge questions.
Confident πŸŽ‰ Mastery "easy", "mastered", "solved", "crystal clear" Suggests peer-teaching exercises, advanced edge-case problems, and synthesis challenges.

πŸ–₯️ Multi-Page Experience

pages/
β”œβ”€β”€ 1_Home.py                  🏠 Interactive emotion analysis & real-time AI guidance
β”œβ”€β”€ 2_Analytics.py             πŸ“Š Longitudinal affective analytics & progress charts
β”œβ”€β”€ 3_History.py               πŸ“‹ Searchable, filterable SQL audit log with CSV export
└── 4_πŸ”¬_Model_Benchmark.py    πŸ”¬ Empirical evaluation lab (Radar charts & Confusion heatmaps)
  1. 🏠 Home (Emotion Analysis):

    • Empathy-first hero banner with dynamic color-coding.
    • 1-Click quick examples for rapid testing.
    • Live latency metering badging forward-pass execution time.
    • Step-by-step AI coaching plan powered by Google Gemini 2.5 Flash.
  2. πŸ“Š Analytics (Learning Insights):

    • Multi-metric summary cards (Total sessions, Avg confidence, Top emotion).
    • Interactive Plotly emotional distribution over time.
    • Discipline-specific breakdown across fields of study.
  3. πŸ“‹ History (Interaction Log):

    • Full database audit trail backed by SQLite (app.db).
    • Multi-filter search (by keyword, emotion, academic discipline, date range).
    • One-click CSV export.
  4. πŸ”¬ Model Benchmark Lab:

    • Interactive 5-axis Plotly Radar Chart.
    • Normalized Confusion Matrix heatmaps for error analysis.
    • Live Head-to-Head Model Arena for side-by-side comparative inference.

πŸ“ Repository Organization

emotionDetectionLearningSupportEngine/
β”œβ”€β”€ HLD.md                             ← High-Level Design Document (v2.0)
β”œβ”€β”€ LLD.md                             ← Low-Level Design Document (v2.0)
β”œβ”€β”€ PRD.md                             ← Product Requirements Document (v2.0)
β”œβ”€β”€ README.md                          ← Main Project Showcase & Documentation
β”œβ”€β”€ requirements.txt                   ← Global Python dependencies
β”œβ”€β”€ documentation/                     ← 8-Phase Engineering Process Documentation
β”‚   β”œβ”€β”€ 1. Brainstorming & Ideation/
β”‚   β”œβ”€β”€ 2. Requirement Analysis/
β”‚   β”œβ”€β”€ 3. Project Design Phase/
β”‚   β”œβ”€β”€ 4. Project Planning Phase/
β”‚   β”œβ”€β”€ 5. Project Development Phase/
β”‚   β”œβ”€β”€ 6. Project Testing/
β”‚   β”œβ”€β”€ 7. Project Documentation/
β”‚   └── 8. Project Demonstration/
└── project_files/
    β”œβ”€β”€ app.py                         ← Main Streamlit application entry point
    β”œβ”€β”€ benchmark.py                   ← CLI benchmark runner & latency profiler
    β”œβ”€β”€ benchmark_results.json         ← Cached empirical benchmark metrics
    β”œβ”€β”€ performance_test.py            ← Concurrency & stress testing script
    β”œβ”€β”€ emotion_response_examples.csv  ← Dataset audit log
    β”œβ”€β”€ data/
    β”‚   └── app.db                     ← SQLite database (WAL mode enabled)
    β”œβ”€β”€ models/
    β”‚   β”œβ”€β”€ bltsm/                     ← BiLSTM weights (.keras) & tokenizer
    β”‚   └── bert_emotion_model_final/  ← Fine-tuned BERT-Base weights & configs
    β”œβ”€β”€ notebooks/
    β”‚   β”œβ”€β”€ kaggle_training.ipynb      ← Kaggle GPU training pipeline (v1)
    β”‚   └── v2_compact_transformer_training.ipynb ← Compact Transformer distillation (v2)
    β”œβ”€β”€ pages/                         ← Streamlit multi-page interface
    β”œβ”€β”€ src/                           ← Core engine modules
    β”‚   β”œβ”€β”€ compact_transformer.py     ← Compact Transformer loader & calibration
    β”‚   β”œβ”€β”€ registry.py                ← Unified ModelRegistry & BaseClassifier
    β”‚   β”œβ”€β”€ benchmark_engine.py        ← Benchmark suite & latency profiler
    β”‚   β”œβ”€β”€ bert_model.py              ← BERT-Base inference engine
    β”‚   β”œβ”€β”€ model.py                   ← BiLSTM RNN inference engine
    β”‚   β”œβ”€β”€ preprocessing.py           ← Text sanitization & keyword fusion
    β”‚   β”œβ”€β”€ predict.py                 ← Prediction coordinator (v1 & v2)
    β”‚   β”œβ”€β”€ database.py                ← SQLAlchemy persistence & ORM models
    β”‚   β”œβ”€β”€ gamification.py            ← XP, streaks & achievement engine
    β”‚   β”œβ”€β”€ components.py              ← UI primitives & empathy banners
    β”‚   └── styles.py                  ← Glassmorphic dark CSS design system
    └── tests/                         ← Automated Pytest test suite
        β”œβ”€β”€ test_engine.py             ← Unit & regression tests
        └── test_v2_engine.py          ← v2 Model registry & benchmark tests

πŸš€ Quick Start

1. Clone & Set Up Environment

# Clone the repository
git clone https://github.com/UdeepChowdary/emotionDetectionLearningSupportEngine.git
cd emotionDetectionLearningSupportEngine/project_files

# Create and activate a virtual environment
python -m venv .venv
.venv\Scripts\activate          # On Windows
# source .venv/bin/activate     # On Linux / macOS

# Install dependencies
pip install -r requirements.txt
python -c "import nltk; nltk.download('stopwords'); nltk.download('punkt'); nltk.download('punkt_tab')"

2. Configure API Keys

Create a .env file in project_files/:

GEMINI_API_KEY=your_gemini_api_key_here

(If no API key is provided, MindLearn AI automatically engages its offline pedagogical fallback matrix!)

3. Run the Application

streamlit run app.py

Open http://localhost:8501 in your browser.

4. Run Automated Benchmarks & Tests

# Execute standalone CLI benchmark
python benchmark.py

# Run the complete test suite
pytest -v tests/

πŸ’» Programmatic Python SDK

You can easily integrate MindLearn AI into any existing learning platform or backend service:

from src.registry import model_registry
from src.predict import run_v2_prediction

# Run inference with Compact Transformer (v2)
response = run_v2_prediction(
    "I don't understand how Dijkstra's priority queue prevents cycles, I am totally confused.",
    selected_model="compact_transformer"
)

primary = response["primary_result"]
print(f"🎯 Emotion:    {primary['emotion']}")       # Confused
print(f"πŸ“ˆ Confidence: {primary['confidence']:.1%}")  # 91.2%
print(f"⚑ Latency:    {primary['latency_ms']:.1f} ms") # 58.5 ms
print(f"🎭 Mixed:      {response['primary_mixed']}") # [('Confused', 0.91), ('Frustrated', 0.18)]

πŸ›‘οΈ License & Acknowledgements

This project is licensed under the MIT License β€” see the LICENSE file for details.

Built with ❀️ by Udeep Chowdary β€’ Developed during the Google Cloud Internship

About

An AI-powered Streamlit web app that detects a student's emotional state from their study challenge description and delivers personalized, empathetic learning support using BiLSTM, BERT, and Gemini 2.5 Flash AI.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Contributors

Languages