andreaceto commited on
Commit
7f5a53f
·
verified ·
1 Parent(s): f3d6425

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +99 -51
README.md CHANGED
@@ -7,74 +7,122 @@ tags:
7
  model-index:
8
  - name: schedulebot-nlu-engine
9
  results: []
 
 
 
 
10
  ---
11
 
12
  <!-- This model card has been generated automatically according to the information the Trainer had access to. You
13
  should probably proofread and complete it, then remove this comment. -->
14
 
15
- # schedulebot-nlu-engine
16
 
17
- This model is a fine-tuned version of [distilbert-base-uncased](https://huggingface.co/distilbert-base-uncased) on an unknown dataset.
18
- It achieves the following results on the evaluation set:
19
- - Loss: 0.4952
20
- - Intent Accuracy: 0.8767
21
- - Intent F1: 0.8762
22
- - Ner F1: 0.9222
23
 
24
- ## Model description
25
 
26
- More information needed
 
27
 
28
- ## Intended uses & limitations
29
 
30
- More information needed
31
 
32
- ## Training and evaluation data
33
 
34
- More information needed
 
 
 
 
 
35
 
36
- ## Training procedure
37
 
38
- ### Training hyperparameters
39
 
40
- The following hyperparameters were used during training:
41
- - learning_rate: 1e-06
42
- - train_batch_size: 32
43
- - eval_batch_size: 32
44
- - seed: 42
45
- - optimizer: Use OptimizerNames.ADAMW_TORCH with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
46
- - lr_scheduler_type: linear
47
- - num_epochs: 20
48
 
49
- ### Training results
50
 
51
- | Training Loss | Epoch | Step | Validation Loss | Intent Accuracy | Intent F1 | Ner F1 |
52
- |:-------------:|:-----:|:----:|:---------------:|:---------------:|:---------:|:------:|
53
- | 0.9887 | 1.0 | 64 | 0.7098 | 0.8219 | 0.8214 | 0.9200 |
54
- | 1.0663 | 2.0 | 128 | 0.6923 | 0.8196 | 0.8187 | 0.9200 |
55
- | 0.9498 | 3.0 | 192 | 0.6631 | 0.8288 | 0.8267 | 0.9188 |
56
- | 0.8652 | 4.0 | 256 | 0.6372 | 0.8447 | 0.8432 | 0.9199 |
57
- | 0.8757 | 5.0 | 320 | 0.6231 | 0.8311 | 0.8312 | 0.9211 |
58
- | 0.8406 | 6.0 | 384 | 0.5914 | 0.8562 | 0.8559 | 0.9194 |
59
- | 0.8455 | 7.0 | 448 | 0.5781 | 0.8562 | 0.8551 | 0.9216 |
60
- | 0.7884 | 8.0 | 512 | 0.5670 | 0.8630 | 0.8619 | 0.9229 |
61
- | 0.8384 | 9.0 | 576 | 0.5606 | 0.8607 | 0.8604 | 0.9210 |
62
- | 0.7189 | 10.0 | 640 | 0.5468 | 0.8539 | 0.8530 | 0.9246 |
63
- | 0.7834 | 11.0 | 704 | 0.5350 | 0.8767 | 0.8765 | 0.9221 |
64
- | 0.774 | 12.0 | 768 | 0.5231 | 0.8699 | 0.8691 | 0.9222 |
65
- | 0.7204 | 13.0 | 832 | 0.5185 | 0.8767 | 0.8764 | 0.9216 |
66
- | 0.7161 | 14.0 | 896 | 0.5131 | 0.8790 | 0.8787 | 0.9216 |
67
- | 0.7283 | 15.0 | 960 | 0.5094 | 0.8721 | 0.8719 | 0.9205 |
68
- | 0.8251 | 16.0 | 1024 | 0.5029 | 0.8744 | 0.8739 | 0.9222 |
69
- | 0.6644 | 17.0 | 1088 | 0.4997 | 0.8790 | 0.8786 | 0.9228 |
70
- | 0.7437 | 18.0 | 1152 | 0.4966 | 0.8767 | 0.8762 | 0.9228 |
71
- | 0.6905 | 19.0 | 1216 | 0.4952 | 0.8767 | 0.8762 | 0.9222 |
72
- | 0.6605 | 20.0 | 1280 | 0.4952 | 0.8767 | 0.8762 | 0.9222 |
73
 
 
74
 
75
- ### Framework versions
76
 
77
- - Transformers 4.53.1
78
- - Pytorch 2.6.0+cu124
79
- - Datasets 4.0.0
80
- - Tokenizers 0.21.2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  model-index:
8
  - name: schedulebot-nlu-engine
9
  results: []
10
+ datasets:
11
+ - andreaceto/hasd
12
+ language:
13
+ - en
14
  ---
15
 
16
  <!-- This model card has been generated automatically according to the information the Trainer had access to. You
17
  should probably proofread and complete it, then remove this comment. -->
18
 
19
+ # Schedulebot-nlu-engine
20
 
21
+ ## Model Description
 
 
 
 
 
22
 
23
+ This model is a multi-task Natural Language Understanding (NLU) engine designed specifically for an appointment scheduling chatbot. It is fine-tuned from a **`distilbert-base-uncased`** backbone and is capable of performing two tasks simultaneously:
24
 
25
+ - **Intent Classification**: Identifying the user's primary goal (e.g., `schedule`, `cancel`).
26
+ - **Named Entity Recognition (NER)**: Extracting custom, domain-specific entities (e.g., `appointment_type`).
27
 
28
+ This model stands out due to its custom classification heads, which use a more complex architecture to improve performance on nuanced tasks.
29
 
30
+ ## Model Architecture
31
 
32
+ The model uses a standard `distilbert-base-uncased` model as its core feature extractor. Two custom classification "heads" are placed on top of this base to perform the downstream tasks.
33
 
34
+ - **Base Model**: `distilbert-base-uncased`
35
+ - **Classifier Heads**: each head is a Multi-Layer Perceptron (MLP) with the following structure to allow for more complex feature interpretation:
36
+ 1. A Linear layer projecting the transformer's output dimension (768) to an intermediate size (384).
37
+ 2. A GELU activation function.
38
+ 3. A Dropout layer with a rate of 0.3 for regularization.
39
+ 4. A final Linear layer projecting the intermediate size to the number of output labels for the specific task (intent or NER).
40
 
41
+ ## Intended Use
42
 
43
+ This model is intended to be the core NLU component of a conversational AI system for managing appointments. It takes raw user text as input and outputs a structured JSON object containing the predicted intent and a list of extracted entities.
44
 
45
+ ```python
46
+ from transformers import AutoTokenizer
 
 
 
 
 
 
47
 
 
48
 
49
+ ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
+ ## Training Data
52
 
53
+ The model was trained on the **HASD (Hybrid Appointment Scheduling Dataset)**, a custom dataset built specifically for this task.
54
 
55
+ - **Source**: The dataset is a hybrid of real-world conversational examples from `clinc/clinc_oos` (for simple intents) and synthetically generated, template-based examples for complex scheduling intents.
56
+ - **Balancing**: To combat class imbalance, intents sourced from `clinc/clinc_oos` were **down-sampled** to a maximum of **150 examples** each. [cite: multitask_model.ipynb]
57
+ - **Augmentation**: To increase data diversity for complex intents (`schedule`, `reschedule`, etc.), **Contextual Word Replacement** was used. A `distilbert-base-uncased` model augmented the templates by replacing non-placeholder words with contextually relevant synonyms. [cite: multitask_model.ipynb]
58
+
59
+ ### Intents
60
+
61
+ The model is trained to recognize the following intents:
62
+ `schedule`, `reschedule`, `cancel`, `query_avail`, `greeting`, `positive_reply`, `negative_reply`, `bye`, `oos` (out-of-scope). [cite: multitask_model.ipynb]
63
+
64
+ ### Entities
65
+
66
+ The model is trained to recognize the following custom named entities:
67
+ `practitioner_name`, `appointment_type`, `appointment_id`. [cite: multitask_model.ipynb]
68
+
69
+ ## Training Procedure
70
+
71
+ The model was trained using a two-stage fine-tuning strategy to ensure stability and performance.
72
+
73
+ ### Stage 1: Training the Classifier Heads
74
+
75
+ - The `distilbert-base-uncased` base model was **frozen**. [cite: multitask_model.ipynb]
76
+ - Only the randomly initialized MLP heads for intent and NER classification were trained.
77
+ - This was done for **5 epochs** with a higher learning rate (`5e-4`), allowing the new layers to learn the task basics without disrupting the pre-trained backbone. [cite: multitask_model.ipynb]
78
+
79
+ ### Stage 2: Selective Fine-Tuning
80
+
81
+ - The classification heads were kept trainable, and the **top two layers** of the DistilBERT backbone were **unfrozen**. [cite: multitask_model.ipynb]
82
+ - The entire model was then fine-tuned for **3 epochs** with a much lower learning rate (`2e-5`). [cite: multitask_model.ipynb]
83
+ - This gradual unfreezing approach allows the model to adapt its most task-specific layers to the new data while preserving the powerful, general-purpose knowledge in the lower layers.
84
+
85
+ ## Evaluation
86
+
87
+ The model was evaluated on a held-out test set, and its performance was measured for both tasks.
88
+
89
+ ### Intent Classification Performance
90
+
91
+ | Intent | Precision | Recall | F1-Score | Support |
92
+ | --- | --- | --- | --- | --- |
93
+ | bye | 1.00 | 1.00 | 1.00 | 22 |
94
+ | cancel | 1.00 | 0.95 | 0.98 | 21 |
95
+ | greeting | 1.00 | 1.00 | 1.00 | 23 |
96
+ | negative_reply | 0.96 | 1.00 | 0.98 | 22 |
97
+ | oos | 1.00 | 1.00 | 1.00 | 22 |
98
+ | positive_reply | 1.00 | 0.96 | 0.98 | 23 |
99
+ | query_avail | 0.95 | 1.00 | 0.98 | 21 |
100
+ | reschedule | 0.96 | 1.00 | 0.98 | 22 |
101
+ | schedule | 0.95 | 0.95 | 0.95 | 21 |
102
+ | **Accuracy** | | | **0.98** | **197** |
103
+ | **Macro Avg** | **0.98** | **0.98** | **0.98** | **197** |
104
+ | **Weighted Avg** | **0.98** | **0.98** | **0.98** | **197** |
105
+
106
+ *[Based on the classification report in the provided `multitask_model.ipynb` notebook.]* [cite: multitask_model.ipynb]
107
+
108
+ ### NER (Token Classification) Performance
109
+
110
+ | Entity | Precision | Recall | F1-Score | Support |
111
+ | --- | --- | --- | --- | --- |
112
+ | B-appointment_id | 1.00 | 1.00 | 1.00 | 25 |
113
+ | B-appointment_type | 1.00 | 1.00 | 1.00 | 33 |
114
+ | B-practitioner_name | 1.00 | 1.00 | 1.00 | 44 |
115
+ | O | 1.00 | 1.00 | 1.00 | 1342 |
116
+ | **Micro Avg** | **1.00** | **1.00** | **1.00** | 1444 |
117
+ | **Macro Avg** | **1.00** | **1.00** | **1.00** | 1444 |
118
+ | **Weighted Avg** | **1.00** | **1.00** | **1.00** | 1444 |
119
+
120
+ *[Based on the classification report in the provided `multitask_model.ipynb` notebook.]* [cite: multitask_model.ipynb]
121
+
122
+ The model achieves near-perfect results on the NER task and excellent results on the intent classification task for this specific dataset.
123
+
124
+ ## Limitations and Bias
125
+
126
+ - The model's performance is highly dependent on the quality and scope of the **HASD dataset**. It may not generalize well to phrasing or appointment types significantly different from what it was trained on.
127
+ - The dataset was primarily generated from templates, which may not capture the full diversity of real human language.
128
+ - The model inherits any biases present in the `distilbert-base-uncased` model and the `clinc/clinc_oos` dataset.