iolimat482 commited on
Commit
b92e7e5
·
verified ·
1 Parent(s): 4b08ec1

Upload BERT hierarchical classification model for grades 1, 2 and 3

Browse files
README.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # BERT Hierarchical Classification Model
3
+
4
+ This model is a fine-tuned BERT-based model for hierarchical classification of Common Core Standard questions.
5
+
6
+ ## Model Description
7
+
8
+ The model classifies input texts into the following hierarchical levels:
9
+
10
+ - Grade
11
+ - Domain
12
+ - Cluster
13
+ - Standard
14
+
15
+ ## Files
16
+
17
+ - `config.json`: Model configuration.
18
+ - `pytorch_model.bin`: Model weights.
19
+ - `modeling.py`: Model class definition.
20
+ - `tokenizer/`: Tokenizer files.
21
+ - `label_encoders.joblib`: Label encoders for mapping predictions back to labels.
22
+
23
+ ## Usage
24
+
25
+ See instructions below on how to load and use the model.
26
+
best_model.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:264a0736580bdc21f02adf05f262b6bb233a7457df11fa950743f6a6abaf6afa
3
+ size 438388429
config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "attention_probs_dropout_prob": 0.1,
3
+ "classifier_dropout": null,
4
+ "hidden_act": "gelu",
5
+ "hidden_dropout_prob": 0.1,
6
+ "hidden_size": 768,
7
+ "initializer_range": 0.02,
8
+ "intermediate_size": 3072,
9
+ "layer_norm_eps": 1e-12,
10
+ "max_position_embeddings": 512,
11
+ "model_type": "bert",
12
+ "num_attention_heads": 12,
13
+ "num_clusters": 20,
14
+ "num_domains": 8,
15
+ "num_grades": 9,
16
+ "num_hidden_layers": 12,
17
+ "num_standards": 85,
18
+ "pad_token_id": 0,
19
+ "position_embedding_type": "absolute",
20
+ "transformers_version": "4.48.1",
21
+ "type_vocab_size": 2,
22
+ "use_cache": true,
23
+ "vocab_size": 30522
24
+ }
label_encoders.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aa3a8cc65c51b62af563d2614004a8f84d785b52e40db031e4f7e80230b1259d
3
+ size 2962
modeling.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import torch
3
+ import torch.nn as nn
4
+ from transformers import BertModel, BertConfig
5
+
6
+ class BertHierarchicalClassification(nn.Module):
7
+ def __init__(self, config):
8
+ super(BertHierarchicalClassification, self).__init__()
9
+ self.bert = BertModel(config)
10
+ hidden_size = config.hidden_size
11
+
12
+ self.num_grades = config.num_grades
13
+ self.num_domains = config.num_domains
14
+ self.num_clusters = config.num_clusters
15
+ self.num_standards = config.num_standards
16
+
17
+ self.grade_classifier = nn.Linear(hidden_size, self.num_grades)
18
+ self.domain_classifier = nn.Linear(hidden_size, self.num_domains)
19
+ self.cluster_classifier = nn.Linear(hidden_size, self.num_clusters)
20
+ self.standard_classifier = nn.Linear(hidden_size, self.num_standards)
21
+ self.dropout = nn.Dropout(0.1)
22
+
23
+ def forward(self, input_ids, attention_mask):
24
+ outputs = self.bert(input_ids=input_ids, attention_mask=attention_mask)
25
+ pooled_output = outputs.pooler_output
26
+ pooled_output = self.dropout(pooled_output)
27
+
28
+ grade_logits = self.grade_classifier(pooled_output)
29
+ domain_logits = self.domain_classifier(pooled_output)
30
+ cluster_logits = self.cluster_classifier(pooled_output)
31
+ standard_logits = self.standard_classifier(pooled_output)
32
+
33
+ return grade_logits, domain_logits, cluster_logits, standard_logits
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_config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "extra_special_tokens": {},
49
+ "mask_token": "[MASK]",
50
+ "model_max_length": 512,
51
+ "never_split": null,
52
+ "pad_token": "[PAD]",
53
+ "sep_token": "[SEP]",
54
+ "strip_accents": null,
55
+ "tokenize_chinese_chars": true,
56
+ "tokenizer_class": "BertTokenizer",
57
+ "unk_token": "[UNK]"
58
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff