Cludoy commited on
Commit
0509be1
·
verified ·
1 Parent(s): b394f61

Add model card README

Browse files
Files changed (1) hide show
  1. README.md +128 -0
README.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ tags:
6
+ - intent-classification
7
+ - tinybert
8
+ - cnn
9
+ - education
10
+ - nlp
11
+ pipeline_tag: text-classification
12
+ ---
13
+
14
+ # IntentClassifier — TinyBERT-CNN
15
+
16
+ A lightweight intent classification model for educational AI tutoring systems. Built on **TinyBERT** (huawei-noah/TinyBERT_General_4L_312D) with a **CNN classification head**, optimized for real-time student intent detection.
17
+
18
+ ## Model Description
19
+
20
+ This model classifies student utterances into 5 pedagogical intent categories:
21
+
22
+ | Label ID | Intent | Description |
23
+ |----------|--------|-------------|
24
+ | 0 | **On-Topic Question** | Questions related to the current learning material |
25
+ | 1 | **Off-Topic Question** | Questions unrelated to the current topic |
26
+ | 2 | **Emotional-State** | Expressions of frustration, confusion, excitement, etc. |
27
+ | 3 | **Pace-Related** | Requests to speed up, slow down, or adjust pacing |
28
+ | 4 | **Repeat/Clarification** | Requests to repeat or clarify previous explanations |
29
+
30
+ ## Architecture
31
+
32
+ - **Backbone**: TinyBERT (4-layer, 312-dim) — compact BERT variant
33
+ - **Head**: Multi-kernel CNN (filter sizes 2, 3, 4) + BatchNorm + FC hidden layer
34
+ - **Parameters**: ~14.5M total
35
+ - **Inference**: <50ms on CPU
36
+
37
+ ```
38
+ TinyBERT → CNN (multi-kernel) → BatchNorm → MaxPool → FC(768→128) → FC(128→5)
39
+ ```
40
+
41
+ ## Performance
42
+
43
+ | Metric | Score |
44
+ |--------|-------|
45
+ | **Accuracy** | 99.6% |
46
+ | **F1 Score** | 99.6% |
47
+ | **Precision** | 99.6% |
48
+ | **Recall** | 99.6% |
49
+ | **Test Loss** | 0.069 |
50
+
51
+ ### Per-Class Performance
52
+
53
+ | Intent | Precision | Recall | F1 | Support |
54
+ |--------|-----------|--------|----|---------|
55
+ | On-Topic Question | 0.993 | 0.997 | 0.995 | 300 |
56
+ | Off-Topic Question | 0.997 | 0.993 | 0.995 | 300 |
57
+ | Emotional-State | 0.993 | 1.000 | 0.997 | 300 |
58
+ | Pace-Related | 0.997 | 0.993 | 0.995 | 300 |
59
+ | Repeat/Clarification | 1.000 | 0.997 | 0.998 | 300 |
60
+
61
+ ## Training Details
62
+
63
+ - **Epochs**: 7 (early stopping with patience=5)
64
+ - **Batch Size**: 16
65
+ - **Optimizer**: AdamW with discriminative fine-tuning (BERT LR: 2e-5, Head LR: 1e-3)
66
+ - **Scheduler**: Warmup + Cosine decay
67
+ - **Label Smoothing**: 0.1
68
+ - **Training Duration**: ~212 seconds
69
+
70
+ ## Usage
71
+
72
+ ```python
73
+ from TinyBert import IntentClassifier
74
+
75
+ # Initialize
76
+ classifier = IntentClassifier(num_classes=5)
77
+ classifier.load_model("prod_tinybert.pt")
78
+
79
+ # Predict
80
+ texts = ["Can you explain that again?"]
81
+ contexts = ["topic:Python Loops"]
82
+ predictions, probabilities = classifier.predict(texts, contexts)
83
+
84
+ intent_names = ['On-Topic Question', 'Off-Topic Question', 'Emotional-State', 'Pace-Related', 'Repeat/clarification']
85
+ print(f"Predicted: {intent_names[predictions[0]]}")
86
+ print(f"Confidence: {probabilities[0][predictions[0]]:.4f}")
87
+ ```
88
+
89
+ ### Compound Sentence Splitting
90
+
91
+ The model includes a `CompoundSentenceSplitter` that can detect and split compound questions:
92
+
93
+ ```python
94
+ from TinyBert import CompoundSentenceSplitter
95
+
96
+ splitter = CompoundSentenceSplitter()
97
+ questions = splitter.split_compound_question("What is a loop and how do I use it?")
98
+ # Returns: ["What is a loop?", "how do I use it?"]
99
+ ```
100
+
101
+ ## Files
102
+
103
+ | File | Description |
104
+ |------|-------------|
105
+ | `TinyBert.py` | Model architecture, IntentClassifier wrapper, CompoundSentenceSplitter |
106
+ | `train.py` | Full training pipeline with early stopping and metrics |
107
+ | `auto_trainer.py` | Automated retraining pipeline |
108
+ | `dataset_generator.py` | Synthetic data generation |
109
+ | `test_suite.py` | Comprehensive test suite |
110
+ | `prod_tinybert.pt` | Production model weights |
111
+ | `best_tinybert.pt` | Best checkpoint from latest training |
112
+ | `training_results.json` | Detailed training metrics and history |
113
+ | `data/` | Training, validation, and test datasets |
114
+
115
+ ## Requirements
116
+
117
+ ```
118
+ torch
119
+ transformers
120
+ pandas
121
+ numpy
122
+ scikit-learn
123
+ tqdm
124
+ ```
125
+
126
+ ## Citation
127
+
128
+ Part of the **AI-Powered Personalized Learning Platform** graduation project.