File size: 4,495 Bytes
24551d0
 
 
 
 
 
f216389
 
 
 
24551d0
f216389
 
 
 
 
 
24551d0
 
f216389
012f151
f216389
24551d0
 
 
 
 
 
 
 
f216389
 
 
 
 
 
24551d0
 
 
 
f216389
 
 
 
 
 
 
 
 
24551d0
 
f216389
24551d0
012f151
f216389
012f151
f216389
012f151
f216389
 
 
 
012f151
 
 
f216389
 
012f151
 
f216389
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7938471
 
317c497
7938471
012f151
24551d0
012f151
317c497
7938471
012f151
24551d0
317c497
f216389
012f151
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
---
license: apache-2.0
tags:
  - reinforcement-learning
  - education
  - doubt-prediction
  - adaptive-learning
  - multi-agent-systems
  - gesture-recognition
  - computer-vision
  - q-learning
  - grpo
  - edtech
  - mediapipe
  - privacy
datasets:
  - synthetic-learning-interactions
---

# ContextFlow: Predictive Doubt Detection in Adaptive Learning Systems

**A Research Implementation of RL-Powered Educational Technology**

| Property | Value |
|----------|-------|
| **Algorithm** | GRPO + Q-Learning |
| **State Dimension** | 64 features |
| **Action Dimension** | 10 doubt predictions |
| **Policy Version** | 50 |
| **Training Samples** | 200 |
| **Final Loss** | 0.2465 |
| **Avg Reward** | 0.75 |

## Overview

ContextFlow predicts student confusion **before** it occurs using reinforcement learning and behavioral signal analysis. When a learner's actions suggest they might be struggling (mouse hesitation, scroll reversals, help-seeking gestures), the system proactively offers assistance.

## Architecture

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           9 Specialized Agents                   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β€’ StudyOrchestrator  β€’ DoubtPredictorAgent      β”‚
β”‚ β€’ BehavioralAgent    β€’ HandGestureAgent          β”‚
β”‚ β€’ RecallAgent       β€’ KnowledgeGraphAgent        β”‚
β”‚ β€’ PeerLearningAgent  β€’ LLMOrchestrator          β”‚
β”‚ β€’ GestureActionMapper β€’ PromptAgent              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

## Quick Start

```python
# Load the model
from huggingface_hub import hf_hub_download
import pickle

path = hf_hub_download(
    repo_id='namish10/contextflow-rl',
    filename='checkpoint.pkl'
)
with open(path, 'rb') as f:
    checkpoint = pickle.load(f)

print(f"Policy version: {checkpoint.policy_version}")
print(f"Training samples: {checkpoint.training_stats['total_samples']}")
```

## State Vector (64 dimensions)

| Component | Dims | Description |
|-----------|------|-------------|
| Topic Embedding | 32 | TF-IDF of learning topic |
| Progress | 1 | Session progress (0.0-1.0) |
| Confusion Signals | 16 | Behavioral indicators |
| Gesture Signals | 14 | Hand gesture frequencies |
| Time Spent | 1 | Normalized session time |

## Actions (10 doubt predictions)

1. `what_is_backpropagation`
2. `why_gradient_descent`
3. `how_overfitting_works`
4. `explain_regularization`
5. `what_loss_function`
6. `how_optimization_works`
7. `explain_learning_rate`
8. `what_regularization`
9. `how_batch_norm_works`
10. `explain_softmax`

## Training Results

| Epoch | Loss | Epsilon | Avg Reward |
|-------|------|---------|------------|
| 1 | 1.2456 | 1.000 | 0.20 |
| 2 | 0.8923 | 0.995 | 0.35 |
| 3 | 0.6541 | 0.990 | 0.48 |
| 4 | 0.4127 | 0.985 | 0.62 |
| 5 | 0.2465 | 0.980 | 0.75 |

## Key Features

- **Predictive Detection**: RL-based confusion prediction before it happens
- **Multi-Agent Orchestration**: 9 specialized agents working together
- **Gesture Recognition**: Privacy-first hand gesture detection with MediaPipe
- **Face Blurring**: Real-time face blur for classroom deployment
- **Browser AI Launch**: Direct AI chat interface from predicted doubts
- **Spaced Repetition**: SM-2 based review scheduling
- **Knowledge Graphs**: Concept mapping and learning paths

## Files

| File | Description |
|------|-------------|
| `checkpoint.pkl` | Trained Q-network weights |
| `train_rl.py` | Training script with GRPO |
| `feature_extractor.py` | 64-dim state extraction |
| `inference_example.py` | Usage examples |
| `demo.ipynb` | Interactive notebook |
| `RESEARCH_PAPER.md` | Full research paper |
| `evaluation_results.json` | Training metrics |
| `requirements.txt` | Dependencies |
| `app/` | Backend agents (Flask API) |
| `frontend/` | React frontend |

## Evaluation

See [EVALUATION.md](EVALUATION.md) for detailed metrics and production readiness assessment.

## Citation

```bibtex
@software{contextflow,
  title={ContextFlow: Predictive Doubt Detection in Adaptive Learning Systems},
  author={ContextFlow Team},
  year={2026},
  version={1.0},
  url={https://huggingface.co/namish10/contextflow-rl}
}
```