nimishgarg commited on
Commit
9b7c383
·
verified ·
1 Parent(s): 5a7af2b

Upload 7 files

Browse files
Files changed (7) hide show
  1. README.md +121 -0
  2. config.json +332 -0
  3. model.safetensors +3 -0
  4. special_tokens_map.json +37 -0
  5. tokenizer.json +0 -0
  6. tokenizer_config.json +63 -0
  7. vocab.txt +0 -0
README.md ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # BERT-Base-Uncased Fine-Tuned Model for Intent Classification on CLINC150 Dataset
3
+
4
+ This repository hosts a fine-tuned BERT model for multi-class intent classification using the CLINC150 (plus) dataset. The model is trained to classify user queries into 150 in-scope intents and handle out-of-scope (OOS) queries.
5
+
6
+ ## Model Details
7
+
8
+ - **Model Architecture:** BERT Base Uncased
9
+ - **Task:** Multi-class Intent Classification
10
+ - **Dataset:** CLINC150 (plus variant)
11
+ - **Quantization:** Float16
12
+ - **Fine-tuning Framework:** Hugging Face Transformers
13
+
14
+ ---
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install transformers datasets scikit-learn evaluate
20
+
21
+ ```
22
+
23
+ ---
24
+
25
+ ## Loading the Model
26
+
27
+ ```python
28
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
29
+ import torch
30
+
31
+ # Load tokenizer and model
32
+ model_path = "bert-base-uncased"
33
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
34
+ model = AutoModelForSequenceClassification.from_pretrained(model_path)
35
+ # Define test sentences
36
+ test_sentences = [
37
+ "Can you tell me the weather in New York?",
38
+ "I want to transfer money to my friend",
39
+ "Play some relaxing jazz music",
40
+ ]
41
+
42
+
43
+ # Tokenize and predict
44
+ def predict_intent(sentences, model, tokenizer, id2label_fn, device="cpu"):
45
+ if isinstance(sentences, str):
46
+ sentences = [sentences]
47
+
48
+ model.eval()
49
+ model.to(device)
50
+
51
+ inputs = tokenizer(sentences, padding=True, truncation=True, return_tensors="pt").to(device)
52
+
53
+ with torch.no_grad():
54
+ outputs = model(**inputs)
55
+ logits = outputs.logits
56
+ predictions = torch.argmax(logits, dim=-1)
57
+
58
+ return [id2label_fn(label.item()) for label in predictions]
59
+
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Performance Metrics
65
+
66
+ - **Accuracy:** 0.947097
67
+ - **Precision:** 0.949821
68
+ - **Recall:** 0.947097
69
+ - **F1 Score:** 0.945876
70
+
71
+
72
+ ---
73
+
74
+ ## Fine-Tuning Details
75
+
76
+ ### Dataset
77
+
78
+ The CLINC150 (plus) dataset contains 151 intent classes (150 in-scope + 1 out-of-scope) for intent classification in English utterances. It includes 15k training, 3k validation, and 4.5k test examples with diverse user queries.
79
+
80
+
81
+ ### Training
82
+
83
+ - **Epochs:** 5
84
+ - **Batch size:** 16
85
+ - **Learning rate:** 2e-5
86
+ - **Evaluation strategy:** `epoch`
87
+
88
+ ---
89
+
90
+ ## Quantization
91
+
92
+ Post-training quantization was applied using PyTorch’s `half()` precision (FP16) to reduce model size and inference time.
93
+
94
+ ---
95
+
96
+ ## Repository Structure
97
+
98
+ ```python
99
+ .
100
+ ├── quantized-model/ # Contains the quantized model files
101
+ │ ├── config.json
102
+ │ ├── model.safetensors
103
+ │ ├── tokenizer_config.json
104
+ │ ├── vocab.txt
105
+ │ └── special_tokens_map.json
106
+ ├── README.md # Model documentation
107
+ ```
108
+
109
+ ---
110
+
111
+ ## Limitations
112
+
113
+ - The model is trained specifically for multi classification on CLINIC150 Dataset.
114
+ - FP16 quantization may result in slight numerical instability in edge cases.
115
+
116
+
117
+ ---
118
+
119
+ ## Contributing
120
+
121
+ Feel free to open issues or submit pull requests to improve the model or documentation.
config.json ADDED
@@ -0,0 +1,332 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForSequenceClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "gradient_checkpointing": false,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 768,
11
+ "id2label": {
12
+ "0": "LABEL_0",
13
+ "1": "LABEL_1",
14
+ "2": "LABEL_2",
15
+ "3": "LABEL_3",
16
+ "4": "LABEL_4",
17
+ "5": "LABEL_5",
18
+ "6": "LABEL_6",
19
+ "7": "LABEL_7",
20
+ "8": "LABEL_8",
21
+ "9": "LABEL_9",
22
+ "10": "LABEL_10",
23
+ "11": "LABEL_11",
24
+ "12": "LABEL_12",
25
+ "13": "LABEL_13",
26
+ "14": "LABEL_14",
27
+ "15": "LABEL_15",
28
+ "16": "LABEL_16",
29
+ "17": "LABEL_17",
30
+ "18": "LABEL_18",
31
+ "19": "LABEL_19",
32
+ "20": "LABEL_20",
33
+ "21": "LABEL_21",
34
+ "22": "LABEL_22",
35
+ "23": "LABEL_23",
36
+ "24": "LABEL_24",
37
+ "25": "LABEL_25",
38
+ "26": "LABEL_26",
39
+ "27": "LABEL_27",
40
+ "28": "LABEL_28",
41
+ "29": "LABEL_29",
42
+ "30": "LABEL_30",
43
+ "31": "LABEL_31",
44
+ "32": "LABEL_32",
45
+ "33": "LABEL_33",
46
+ "34": "LABEL_34",
47
+ "35": "LABEL_35",
48
+ "36": "LABEL_36",
49
+ "37": "LABEL_37",
50
+ "38": "LABEL_38",
51
+ "39": "LABEL_39",
52
+ "40": "LABEL_40",
53
+ "41": "LABEL_41",
54
+ "42": "LABEL_42",
55
+ "43": "LABEL_43",
56
+ "44": "LABEL_44",
57
+ "45": "LABEL_45",
58
+ "46": "LABEL_46",
59
+ "47": "LABEL_47",
60
+ "48": "LABEL_48",
61
+ "49": "LABEL_49",
62
+ "50": "LABEL_50",
63
+ "51": "LABEL_51",
64
+ "52": "LABEL_52",
65
+ "53": "LABEL_53",
66
+ "54": "LABEL_54",
67
+ "55": "LABEL_55",
68
+ "56": "LABEL_56",
69
+ "57": "LABEL_57",
70
+ "58": "LABEL_58",
71
+ "59": "LABEL_59",
72
+ "60": "LABEL_60",
73
+ "61": "LABEL_61",
74
+ "62": "LABEL_62",
75
+ "63": "LABEL_63",
76
+ "64": "LABEL_64",
77
+ "65": "LABEL_65",
78
+ "66": "LABEL_66",
79
+ "67": "LABEL_67",
80
+ "68": "LABEL_68",
81
+ "69": "LABEL_69",
82
+ "70": "LABEL_70",
83
+ "71": "LABEL_71",
84
+ "72": "LABEL_72",
85
+ "73": "LABEL_73",
86
+ "74": "LABEL_74",
87
+ "75": "LABEL_75",
88
+ "76": "LABEL_76",
89
+ "77": "LABEL_77",
90
+ "78": "LABEL_78",
91
+ "79": "LABEL_79",
92
+ "80": "LABEL_80",
93
+ "81": "LABEL_81",
94
+ "82": "LABEL_82",
95
+ "83": "LABEL_83",
96
+ "84": "LABEL_84",
97
+ "85": "LABEL_85",
98
+ "86": "LABEL_86",
99
+ "87": "LABEL_87",
100
+ "88": "LABEL_88",
101
+ "89": "LABEL_89",
102
+ "90": "LABEL_90",
103
+ "91": "LABEL_91",
104
+ "92": "LABEL_92",
105
+ "93": "LABEL_93",
106
+ "94": "LABEL_94",
107
+ "95": "LABEL_95",
108
+ "96": "LABEL_96",
109
+ "97": "LABEL_97",
110
+ "98": "LABEL_98",
111
+ "99": "LABEL_99",
112
+ "100": "LABEL_100",
113
+ "101": "LABEL_101",
114
+ "102": "LABEL_102",
115
+ "103": "LABEL_103",
116
+ "104": "LABEL_104",
117
+ "105": "LABEL_105",
118
+ "106": "LABEL_106",
119
+ "107": "LABEL_107",
120
+ "108": "LABEL_108",
121
+ "109": "LABEL_109",
122
+ "110": "LABEL_110",
123
+ "111": "LABEL_111",
124
+ "112": "LABEL_112",
125
+ "113": "LABEL_113",
126
+ "114": "LABEL_114",
127
+ "115": "LABEL_115",
128
+ "116": "LABEL_116",
129
+ "117": "LABEL_117",
130
+ "118": "LABEL_118",
131
+ "119": "LABEL_119",
132
+ "120": "LABEL_120",
133
+ "121": "LABEL_121",
134
+ "122": "LABEL_122",
135
+ "123": "LABEL_123",
136
+ "124": "LABEL_124",
137
+ "125": "LABEL_125",
138
+ "126": "LABEL_126",
139
+ "127": "LABEL_127",
140
+ "128": "LABEL_128",
141
+ "129": "LABEL_129",
142
+ "130": "LABEL_130",
143
+ "131": "LABEL_131",
144
+ "132": "LABEL_132",
145
+ "133": "LABEL_133",
146
+ "134": "LABEL_134",
147
+ "135": "LABEL_135",
148
+ "136": "LABEL_136",
149
+ "137": "LABEL_137",
150
+ "138": "LABEL_138",
151
+ "139": "LABEL_139",
152
+ "140": "LABEL_140",
153
+ "141": "LABEL_141",
154
+ "142": "LABEL_142",
155
+ "143": "LABEL_143",
156
+ "144": "LABEL_144",
157
+ "145": "LABEL_145",
158
+ "146": "LABEL_146",
159
+ "147": "LABEL_147",
160
+ "148": "LABEL_148",
161
+ "149": "LABEL_149",
162
+ "150": "LABEL_150"
163
+ },
164
+ "initializer_range": 0.02,
165
+ "intermediate_size": 3072,
166
+ "label2id": {
167
+ "LABEL_0": 0,
168
+ "LABEL_1": 1,
169
+ "LABEL_10": 10,
170
+ "LABEL_100": 100,
171
+ "LABEL_101": 101,
172
+ "LABEL_102": 102,
173
+ "LABEL_103": 103,
174
+ "LABEL_104": 104,
175
+ "LABEL_105": 105,
176
+ "LABEL_106": 106,
177
+ "LABEL_107": 107,
178
+ "LABEL_108": 108,
179
+ "LABEL_109": 109,
180
+ "LABEL_11": 11,
181
+ "LABEL_110": 110,
182
+ "LABEL_111": 111,
183
+ "LABEL_112": 112,
184
+ "LABEL_113": 113,
185
+ "LABEL_114": 114,
186
+ "LABEL_115": 115,
187
+ "LABEL_116": 116,
188
+ "LABEL_117": 117,
189
+ "LABEL_118": 118,
190
+ "LABEL_119": 119,
191
+ "LABEL_12": 12,
192
+ "LABEL_120": 120,
193
+ "LABEL_121": 121,
194
+ "LABEL_122": 122,
195
+ "LABEL_123": 123,
196
+ "LABEL_124": 124,
197
+ "LABEL_125": 125,
198
+ "LABEL_126": 126,
199
+ "LABEL_127": 127,
200
+ "LABEL_128": 128,
201
+ "LABEL_129": 129,
202
+ "LABEL_13": 13,
203
+ "LABEL_130": 130,
204
+ "LABEL_131": 131,
205
+ "LABEL_132": 132,
206
+ "LABEL_133": 133,
207
+ "LABEL_134": 134,
208
+ "LABEL_135": 135,
209
+ "LABEL_136": 136,
210
+ "LABEL_137": 137,
211
+ "LABEL_138": 138,
212
+ "LABEL_139": 139,
213
+ "LABEL_14": 14,
214
+ "LABEL_140": 140,
215
+ "LABEL_141": 141,
216
+ "LABEL_142": 142,
217
+ "LABEL_143": 143,
218
+ "LABEL_144": 144,
219
+ "LABEL_145": 145,
220
+ "LABEL_146": 146,
221
+ "LABEL_147": 147,
222
+ "LABEL_148": 148,
223
+ "LABEL_149": 149,
224
+ "LABEL_15": 15,
225
+ "LABEL_150": 150,
226
+ "LABEL_16": 16,
227
+ "LABEL_17": 17,
228
+ "LABEL_18": 18,
229
+ "LABEL_19": 19,
230
+ "LABEL_2": 2,
231
+ "LABEL_20": 20,
232
+ "LABEL_21": 21,
233
+ "LABEL_22": 22,
234
+ "LABEL_23": 23,
235
+ "LABEL_24": 24,
236
+ "LABEL_25": 25,
237
+ "LABEL_26": 26,
238
+ "LABEL_27": 27,
239
+ "LABEL_28": 28,
240
+ "LABEL_29": 29,
241
+ "LABEL_3": 3,
242
+ "LABEL_30": 30,
243
+ "LABEL_31": 31,
244
+ "LABEL_32": 32,
245
+ "LABEL_33": 33,
246
+ "LABEL_34": 34,
247
+ "LABEL_35": 35,
248
+ "LABEL_36": 36,
249
+ "LABEL_37": 37,
250
+ "LABEL_38": 38,
251
+ "LABEL_39": 39,
252
+ "LABEL_4": 4,
253
+ "LABEL_40": 40,
254
+ "LABEL_41": 41,
255
+ "LABEL_42": 42,
256
+ "LABEL_43": 43,
257
+ "LABEL_44": 44,
258
+ "LABEL_45": 45,
259
+ "LABEL_46": 46,
260
+ "LABEL_47": 47,
261
+ "LABEL_48": 48,
262
+ "LABEL_49": 49,
263
+ "LABEL_5": 5,
264
+ "LABEL_50": 50,
265
+ "LABEL_51": 51,
266
+ "LABEL_52": 52,
267
+ "LABEL_53": 53,
268
+ "LABEL_54": 54,
269
+ "LABEL_55": 55,
270
+ "LABEL_56": 56,
271
+ "LABEL_57": 57,
272
+ "LABEL_58": 58,
273
+ "LABEL_59": 59,
274
+ "LABEL_6": 6,
275
+ "LABEL_60": 60,
276
+ "LABEL_61": 61,
277
+ "LABEL_62": 62,
278
+ "LABEL_63": 63,
279
+ "LABEL_64": 64,
280
+ "LABEL_65": 65,
281
+ "LABEL_66": 66,
282
+ "LABEL_67": 67,
283
+ "LABEL_68": 68,
284
+ "LABEL_69": 69,
285
+ "LABEL_7": 7,
286
+ "LABEL_70": 70,
287
+ "LABEL_71": 71,
288
+ "LABEL_72": 72,
289
+ "LABEL_73": 73,
290
+ "LABEL_74": 74,
291
+ "LABEL_75": 75,
292
+ "LABEL_76": 76,
293
+ "LABEL_77": 77,
294
+ "LABEL_78": 78,
295
+ "LABEL_79": 79,
296
+ "LABEL_8": 8,
297
+ "LABEL_80": 80,
298
+ "LABEL_81": 81,
299
+ "LABEL_82": 82,
300
+ "LABEL_83": 83,
301
+ "LABEL_84": 84,
302
+ "LABEL_85": 85,
303
+ "LABEL_86": 86,
304
+ "LABEL_87": 87,
305
+ "LABEL_88": 88,
306
+ "LABEL_89": 89,
307
+ "LABEL_9": 9,
308
+ "LABEL_90": 90,
309
+ "LABEL_91": 91,
310
+ "LABEL_92": 92,
311
+ "LABEL_93": 93,
312
+ "LABEL_94": 94,
313
+ "LABEL_95": 95,
314
+ "LABEL_96": 96,
315
+ "LABEL_97": 97,
316
+ "LABEL_98": 98,
317
+ "LABEL_99": 99
318
+ },
319
+ "layer_norm_eps": 1e-12,
320
+ "max_position_embeddings": 512,
321
+ "model_type": "bert",
322
+ "num_attention_heads": 12,
323
+ "num_hidden_layers": 12,
324
+ "pad_token_id": 0,
325
+ "position_embedding_type": "absolute",
326
+ "problem_type": "single_label_classification",
327
+ "torch_dtype": "float16",
328
+ "transformers_version": "4.51.3",
329
+ "type_vocab_size": 2,
330
+ "use_cache": true,
331
+ "vocab_size": 30522
332
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8366ad4f846c3f7ce816ae8a2bcba912bd7ce62593c4ff4ceab4b8239f2daf30
3
+ size 219220134
special_tokens_map.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": {
3
+ "content": "[CLS]",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "mask_token": {
10
+ "content": "[MASK]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "[PAD]",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "sep_token": {
24
+ "content": "[SEP]",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "unk_token": {
31
+ "content": "[UNK]",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ }
37
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": false,
45
+ "cls_token": "[CLS]",
46
+ "do_lower_case": true,
47
+ "extra_special_tokens": {},
48
+ "mask_token": "[MASK]",
49
+ "max_length": 512,
50
+ "model_max_length": 512,
51
+ "pad_to_multiple_of": null,
52
+ "pad_token": "[PAD]",
53
+ "pad_token_type_id": 0,
54
+ "padding_side": "right",
55
+ "sep_token": "[SEP]",
56
+ "stride": 0,
57
+ "strip_accents": null,
58
+ "tokenize_chinese_chars": true,
59
+ "tokenizer_class": "BertTokenizer",
60
+ "truncation_side": "right",
61
+ "truncation_strategy": "longest_first",
62
+ "unk_token": "[UNK]"
63
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff