Aryan7500 commited on
Commit
2f1e4a2
·
verified ·
1 Parent(s): 08e4b06

Upload 7 files

Browse files
README.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DistilBERT-Based Intent Detection Model for Banking Customer Queries
2
+
3
+ This repository contains a fine-tuned **DistilBERT** model for **intent detection** in banking customer support scenarios. It is trained on the **BANKING77 dataset** and designed to accurately classify user queries into 77 distinct banking-related intents.
4
+
5
+ ## Model Details
6
+
7
+ - **Model Architecture:** DistilBERT Base Uncased
8
+ - **Task:** Intent Detection for Banking Queries
9
+ - **Dataset:** [BANKING77](https://huggingface.co/datasets/banking77)
10
+ - **Fine-tuning Framework:** Hugging Face Transformers
11
+ - **Language:** English
12
+ - **Number of Labels:** 77
13
+ - **Quantization:** *Not applied (full precision)*
14
+
15
+ ## Usage
16
+
17
+ ### Installation
18
+
19
+ ```bash
20
+ pip install transformers torch datasets
21
+ ```
22
+
23
+ ### Loading the Model
24
+
25
+ ```python
26
+ from transformers import DistilBertTokenizer, DistilBertForSequenceClassification
27
+ import torch
28
+
29
+ # Load fine-tuned model
30
+ model_path = "./banking77-distilbert" # Adjust path if different
31
+ model = DistilBertForSequenceClassification.from_pretrained(model_path)
32
+ tokenizer = DistilBertTokenizer.from_pretrained(model_path)
33
+ model.eval()
34
+
35
+ # Sample query
36
+ text = "I need to reset my online banking password."
37
+
38
+ # Tokenize and predict
39
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
40
+ with torch.no_grad():
41
+ outputs = model(**inputs)
42
+ predicted_class = torch.argmax(outputs.logits, dim=1).item()
43
+
44
+ # Example label map (replace with the full BANKING77 map)
45
+ label_map = {0: "activate_my_card", 1: "balance", 2: "card_arrival", ..., 76: "why_was_my_card_declined"}
46
+ print(f"Predicted Intent: {label_map[predicted_class]}")
47
+ ```
48
+
49
+ ## Performance Metrics
50
+
51
+ - **Accuracy:** ~95% (on the BANKING77 test split)
52
+ - **Loss:** ~0.13 (after fine-tuning for 4 epochs)
53
+
54
+ ## Fine-Tuning Details
55
+
56
+ ### Dataset
57
+
58
+ - **Name:** BANKING77
59
+ - **Size:** ~13,000 customer support queries
60
+ - **Intents:** 77 unique labeled banking intents
61
+
62
+ ### Training
63
+
64
+ - **Epochs:** 4
65
+ - **Batch Size:** 16
66
+ - **Learning Rate:** 2e-5
67
+ - **Optimizer:** AdamW
68
+ - **Evaluation Strategy:** per epoch
69
+ - **Loss Function:** CrossEntropyLoss
70
+
71
+ ### Hardware
72
+
73
+ - **GPU Used:** NVIDIA Tesla T4 (via Google Colab)
74
+ - **Training Time:** ~15 minutes
75
+
76
+ ## Repository Structure
77
+
78
+ ```
79
+ .
80
+ ├── banking77-distilbert/ # Fine-tuned model directory (saved via trainer.save_model)
81
+ │ ├── config.json
82
+ │ ├── pytorch_model.bin
83
+ │ ├── tokenizer_config.json
84
+ │ ├── vocab.txt
85
+ ├── intent_predictor.py # Script for predicting intents (with preprocessing)
86
+ ├── README.md # Model documentation
87
+ ```
88
+
89
+ ## Limitations
90
+
91
+ - The model is trained only on banking-related intents; it may misclassify out-of-domain queries.
92
+ - Multilingual support is not included — limited to English.
93
+ - Model does not handle multiple intents per query.
94
+
95
+ ## Contributing
96
+
97
+ Contributions and suggestions are welcome. Please open an issue or pull request for improvements or additional features.
config.json ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation": "gelu",
3
+ "architectures": [
4
+ "DistilBertForSequenceClassification"
5
+ ],
6
+ "attention_dropout": 0.1,
7
+ "dim": 768,
8
+ "dropout": 0.1,
9
+ "hidden_dim": 3072,
10
+ "id2label": {
11
+ "0": "LABEL_0",
12
+ "1": "LABEL_1",
13
+ "2": "LABEL_2",
14
+ "3": "LABEL_3",
15
+ "4": "LABEL_4",
16
+ "5": "LABEL_5",
17
+ "6": "LABEL_6",
18
+ "7": "LABEL_7",
19
+ "8": "LABEL_8",
20
+ "9": "LABEL_9",
21
+ "10": "LABEL_10",
22
+ "11": "LABEL_11",
23
+ "12": "LABEL_12",
24
+ "13": "LABEL_13",
25
+ "14": "LABEL_14",
26
+ "15": "LABEL_15",
27
+ "16": "LABEL_16",
28
+ "17": "LABEL_17",
29
+ "18": "LABEL_18",
30
+ "19": "LABEL_19",
31
+ "20": "LABEL_20",
32
+ "21": "LABEL_21",
33
+ "22": "LABEL_22",
34
+ "23": "LABEL_23",
35
+ "24": "LABEL_24",
36
+ "25": "LABEL_25",
37
+ "26": "LABEL_26",
38
+ "27": "LABEL_27",
39
+ "28": "LABEL_28",
40
+ "29": "LABEL_29",
41
+ "30": "LABEL_30",
42
+ "31": "LABEL_31",
43
+ "32": "LABEL_32",
44
+ "33": "LABEL_33",
45
+ "34": "LABEL_34",
46
+ "35": "LABEL_35",
47
+ "36": "LABEL_36",
48
+ "37": "LABEL_37",
49
+ "38": "LABEL_38",
50
+ "39": "LABEL_39",
51
+ "40": "LABEL_40",
52
+ "41": "LABEL_41",
53
+ "42": "LABEL_42",
54
+ "43": "LABEL_43",
55
+ "44": "LABEL_44",
56
+ "45": "LABEL_45",
57
+ "46": "LABEL_46",
58
+ "47": "LABEL_47",
59
+ "48": "LABEL_48",
60
+ "49": "LABEL_49",
61
+ "50": "LABEL_50",
62
+ "51": "LABEL_51",
63
+ "52": "LABEL_52",
64
+ "53": "LABEL_53",
65
+ "54": "LABEL_54",
66
+ "55": "LABEL_55",
67
+ "56": "LABEL_56",
68
+ "57": "LABEL_57",
69
+ "58": "LABEL_58",
70
+ "59": "LABEL_59",
71
+ "60": "LABEL_60",
72
+ "61": "LABEL_61",
73
+ "62": "LABEL_62",
74
+ "63": "LABEL_63",
75
+ "64": "LABEL_64",
76
+ "65": "LABEL_65",
77
+ "66": "LABEL_66",
78
+ "67": "LABEL_67",
79
+ "68": "LABEL_68",
80
+ "69": "LABEL_69",
81
+ "70": "LABEL_70",
82
+ "71": "LABEL_71",
83
+ "72": "LABEL_72",
84
+ "73": "LABEL_73",
85
+ "74": "LABEL_74",
86
+ "75": "LABEL_75",
87
+ "76": "LABEL_76"
88
+ },
89
+ "initializer_range": 0.02,
90
+ "label2id": {
91
+ "LABEL_0": 0,
92
+ "LABEL_1": 1,
93
+ "LABEL_10": 10,
94
+ "LABEL_11": 11,
95
+ "LABEL_12": 12,
96
+ "LABEL_13": 13,
97
+ "LABEL_14": 14,
98
+ "LABEL_15": 15,
99
+ "LABEL_16": 16,
100
+ "LABEL_17": 17,
101
+ "LABEL_18": 18,
102
+ "LABEL_19": 19,
103
+ "LABEL_2": 2,
104
+ "LABEL_20": 20,
105
+ "LABEL_21": 21,
106
+ "LABEL_22": 22,
107
+ "LABEL_23": 23,
108
+ "LABEL_24": 24,
109
+ "LABEL_25": 25,
110
+ "LABEL_26": 26,
111
+ "LABEL_27": 27,
112
+ "LABEL_28": 28,
113
+ "LABEL_29": 29,
114
+ "LABEL_3": 3,
115
+ "LABEL_30": 30,
116
+ "LABEL_31": 31,
117
+ "LABEL_32": 32,
118
+ "LABEL_33": 33,
119
+ "LABEL_34": 34,
120
+ "LABEL_35": 35,
121
+ "LABEL_36": 36,
122
+ "LABEL_37": 37,
123
+ "LABEL_38": 38,
124
+ "LABEL_39": 39,
125
+ "LABEL_4": 4,
126
+ "LABEL_40": 40,
127
+ "LABEL_41": 41,
128
+ "LABEL_42": 42,
129
+ "LABEL_43": 43,
130
+ "LABEL_44": 44,
131
+ "LABEL_45": 45,
132
+ "LABEL_46": 46,
133
+ "LABEL_47": 47,
134
+ "LABEL_48": 48,
135
+ "LABEL_49": 49,
136
+ "LABEL_5": 5,
137
+ "LABEL_50": 50,
138
+ "LABEL_51": 51,
139
+ "LABEL_52": 52,
140
+ "LABEL_53": 53,
141
+ "LABEL_54": 54,
142
+ "LABEL_55": 55,
143
+ "LABEL_56": 56,
144
+ "LABEL_57": 57,
145
+ "LABEL_58": 58,
146
+ "LABEL_59": 59,
147
+ "LABEL_6": 6,
148
+ "LABEL_60": 60,
149
+ "LABEL_61": 61,
150
+ "LABEL_62": 62,
151
+ "LABEL_63": 63,
152
+ "LABEL_64": 64,
153
+ "LABEL_65": 65,
154
+ "LABEL_66": 66,
155
+ "LABEL_67": 67,
156
+ "LABEL_68": 68,
157
+ "LABEL_69": 69,
158
+ "LABEL_7": 7,
159
+ "LABEL_70": 70,
160
+ "LABEL_71": 71,
161
+ "LABEL_72": 72,
162
+ "LABEL_73": 73,
163
+ "LABEL_74": 74,
164
+ "LABEL_75": 75,
165
+ "LABEL_76": 76,
166
+ "LABEL_8": 8,
167
+ "LABEL_9": 9
168
+ },
169
+ "max_position_embeddings": 512,
170
+ "model_type": "distilbert",
171
+ "n_heads": 12,
172
+ "n_layers": 6,
173
+ "pad_token_id": 0,
174
+ "problem_type": "single_label_classification",
175
+ "qa_dropout": 0.1,
176
+ "seq_classif_dropout": 0.2,
177
+ "sinusoidal_pos_embds": false,
178
+ "tie_weights_": true,
179
+ "torch_dtype": "float16",
180
+ "transformers_version": "4.51.3",
181
+ "vocab_size": 30522
182
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5e70689cad41f7376b742f45cbc2d6a65ab2b0c148805704b47544c810842682
3
+ size 134037794
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "model_max_length": 512,
50
+ "pad_token": "[PAD]",
51
+ "sep_token": "[SEP]",
52
+ "strip_accents": null,
53
+ "tokenize_chinese_chars": true,
54
+ "tokenizer_class": "DistilBertTokenizer",
55
+ "unk_token": "[UNK]"
56
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff