AbidHasan95 commited on
Commit
1455e81
1 Parent(s): 2a8e9a7

First commit

Browse files
config.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "abc2",
3
+ "architectures": [
4
+ "BertForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "custom_pipelines": {
9
+ "sms-classification": {
10
+ "impl": "sms_classifier.SMSClassificationPipeline",
11
+ "pt": [
12
+ "AutoModelForSequenceClassification"
13
+ ],
14
+ "tf": [
15
+ "TFAutoModelForSequenceClassification"
16
+ ]
17
+ }
18
+ },
19
+ "hidden_act": "gelu",
20
+ "hidden_dropout_prob": 0.1,
21
+ "hidden_size": 512,
22
+ "initializer_range": 0.02,
23
+ "intermediate_size": 2048,
24
+ "layer_norm_eps": 1e-12,
25
+ "max_position_embeddings": 512,
26
+ "model_type": "bert",
27
+ "num_attention_heads": 8,
28
+ "num_hidden_layers": 2,
29
+ "pad_token_id": 0,
30
+ "position_embedding_type": "absolute",
31
+ "torch_dtype": "float32",
32
+ "transformers_version": "4.38.2",
33
+ "type_vocab_size": 2,
34
+ "use_cache": true,
35
+ "vocab_size": 30522
36
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9fa25d6948b403ef3438761d39e0e66ac075bb066d75f866041b597067476d77
3
+ size 89844232
sms_classifier.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline, BertModel, AutoTokenizer, PretrainedConfig,PreTrainedModel, Pipeline
2
+
3
+
4
+ class SMSClassificationPipeline(Pipeline):
5
+ def _sanitize_parameters(self, **kwargs):
6
+ preprocess_kwargs = {}
7
+ # if "second_text" in kwargs:
8
+ # preprocess_kwargs["second_text"] = kwargs["second_text"]
9
+ return preprocess_kwargs, {}, {}
10
+
11
+ def preprocess(self, text):
12
+ return self.tokenizer(text, return_tensors=self.framework)
13
+
14
+ def _forward(self, model_inputs):
15
+ return self.model(**model_inputs)
16
+
17
+ def postprocess(self, model_outputs):
18
+ seq_labels = [
19
+ "Transaction",
20
+ "Courier",
21
+ "OTP",
22
+ "Expiry",
23
+ "Misc",
24
+ "Tele Marketing",
25
+ "Spam",
26
+ ]
27
+
28
+ token_class_labels = [
29
+ 'O',
30
+ 'Courier Service',
31
+ 'Credit',
32
+ 'Date',
33
+ 'Debit',
34
+ 'Email',
35
+ 'Expiry',
36
+ 'Item',
37
+ 'Order ID',
38
+ 'Organization',
39
+ 'OTP',
40
+ 'Phone Number',
41
+ 'Refund',
42
+ 'Time',
43
+ 'Tracking ID',
44
+ 'URL',
45
+ ]
46
+ # logits = model_outputs.logits[0].numpy()
47
+ # probabilities = softmax(logits)
48
+
49
+ # best_class = np.argmax(probabilities)
50
+ # label = self.model.config.id2label[best_class]
51
+ # score = probabilities[best_class].item()
52
+ # logits = logits.tolist()
53
+ # return {"label": label, "score": score, "logits": logits}
54
+ # out = self.tokenizer(model_outputs, return_tensors="pt")
55
+ token_classification_logits, sequence_logits = model_outputs
56
+ token_classification_logits = token_classification_logits.argmax(2)[0]
57
+ sequence_logits = sequence_logits.argmax(1)[0]
58
+ token_classification_out = [token_class_labels[i] for i in token_classification_logits.tolist()]
59
+ seq_classification_out = seq_labels[sequence_logits]
60
+ # return token_classification_out, seq_classification_out
61
+ return {"token_classfier":token_classification_out, "sequence_classfier": seq_classification_out}
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,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": true,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": true,
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 1000000000000000019884624838656,
50
+ "never_split": null,
51
+ "pad_token": "[PAD]",
52
+ "sep_token": "[SEP]",
53
+ "strip_accents": null,
54
+ "tokenize_chinese_chars": true,
55
+ "tokenizer_class": "BertTokenizer",
56
+ "unk_token": "[UNK]"
57
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff