Upload modified model with logging
Browse files- config.json +26 -60
- configuring_modified.py +1 -1
- generation_config.json +1 -1
- model.safetensors +2 -2
- modeling_modified.py +6 -7
- special_tokens_map.json +5 -13
- tokenizer.json +0 -0
- tokenizer_config.json +27 -27
- vocab.txt +0 -0
config.json
CHANGED
@@ -1,75 +1,41 @@
|
|
1 |
{
|
2 |
"_name_or_path": "./modified_model",
|
3 |
-
"_num_labels": 3,
|
4 |
-
"activation_dropout": 0.0,
|
5 |
-
"activation_function": "gelu",
|
6 |
-
"add_final_layer_norm": false,
|
7 |
"architectures": [
|
8 |
-
"
|
9 |
],
|
10 |
-
"
|
11 |
"auto_map": {
|
12 |
-
"AutoConfig": "configuring_modified.
|
13 |
-
"AutoModel": "modeling_modified.
|
14 |
-
"
|
15 |
},
|
16 |
-
"
|
17 |
-
"classif_dropout": 0.0,
|
18 |
-
"classifier_dropout": 0.0,
|
19 |
-
"d_model": 1024,
|
20 |
-
"decoder_attention_heads": 16,
|
21 |
-
"decoder_ffn_dim": 4096,
|
22 |
-
"decoder_layerdrop": 0.0,
|
23 |
-
"decoder_layers": 12,
|
24 |
-
"decoder_start_token_id": 2,
|
25 |
-
"dropout": 0.1,
|
26 |
-
"early_stopping": true,
|
27 |
-
"encoder_attention_heads": 16,
|
28 |
-
"encoder_ffn_dim": 4096,
|
29 |
-
"encoder_layerdrop": 0.0,
|
30 |
-
"encoder_layers": 12,
|
31 |
-
"eos_token_id": 2,
|
32 |
-
"force_bos_token_to_be_generated": true,
|
33 |
-
"forced_bos_token_id": 0,
|
34 |
-
"forced_eos_token_id": 2,
|
35 |
"gradient_checkpointing": false,
|
|
|
|
|
|
|
36 |
"id2label": {
|
37 |
-
"0": "
|
38 |
-
"1": "
|
39 |
-
"2": "
|
40 |
},
|
41 |
-
"
|
42 |
-
"
|
43 |
"label2id": {
|
44 |
-
"
|
45 |
-
"
|
46 |
-
"
|
47 |
},
|
48 |
-
"
|
49 |
-
"
|
50 |
-
"
|
51 |
-
"
|
52 |
-
"model_type": "bart",
|
53 |
-
"no_repeat_ngram_size": 3,
|
54 |
-
"normalize_before": false,
|
55 |
-
"num_beams": 4,
|
56 |
"num_hidden_layers": 12,
|
57 |
-
"
|
58 |
-
"
|
59 |
-
"prefix": " ",
|
60 |
-
"scale_embedding": false,
|
61 |
-
"task_specific_params": {
|
62 |
-
"summarization": {
|
63 |
-
"early_stopping": true,
|
64 |
-
"length_penalty": 2.0,
|
65 |
-
"max_length": 142,
|
66 |
-
"min_length": 56,
|
67 |
-
"no_repeat_ngram_size": 3,
|
68 |
-
"num_beams": 4
|
69 |
-
}
|
70 |
-
},
|
71 |
"torch_dtype": "float32",
|
72 |
-
"transformers_version": "4.
|
|
|
73 |
"use_cache": true,
|
74 |
-
"vocab_size":
|
75 |
}
|
|
|
1 |
{
|
2 |
"_name_or_path": "./modified_model",
|
|
|
|
|
|
|
|
|
3 |
"architectures": [
|
4 |
+
"ModifiedBertForSequenceClassificationWithHook"
|
5 |
],
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
"auto_map": {
|
8 |
+
"AutoConfig": "configuring_modified.BertConfig",
|
9 |
+
"AutoModel": "modeling_modified.ModifiedBertForSequenceClassificationWithHook",
|
10 |
+
"AutoModelForSequenceClassification": "modeling_modified.ModifiedBertForSequenceClassificationWithHook"
|
11 |
},
|
12 |
+
"classifier_dropout": null,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
"gradient_checkpointing": false,
|
14 |
+
"hidden_act": "gelu",
|
15 |
+
"hidden_dropout_prob": 0.1,
|
16 |
+
"hidden_size": 768,
|
17 |
"id2label": {
|
18 |
+
"0": "positive",
|
19 |
+
"1": "negative",
|
20 |
+
"2": "neutral"
|
21 |
},
|
22 |
+
"initializer_range": 0.02,
|
23 |
+
"intermediate_size": 3072,
|
24 |
"label2id": {
|
25 |
+
"negative": 1,
|
26 |
+
"neutral": 2,
|
27 |
+
"positive": 0
|
28 |
},
|
29 |
+
"layer_norm_eps": 1e-12,
|
30 |
+
"max_position_embeddings": 512,
|
31 |
+
"model_type": "bert",
|
32 |
+
"num_attention_heads": 12,
|
|
|
|
|
|
|
|
|
33 |
"num_hidden_layers": 12,
|
34 |
+
"pad_token_id": 0,
|
35 |
+
"position_embedding_type": "absolute",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
"torch_dtype": "float32",
|
37 |
+
"transformers_version": "4.45.1",
|
38 |
+
"type_vocab_size": 2,
|
39 |
"use_cache": true,
|
40 |
+
"vocab_size": 30522
|
41 |
}
|
configuring_modified.py
CHANGED
@@ -1 +1 @@
|
|
1 |
-
from transformers import
|
|
|
1 |
+
from transformers import BertConfig
|
generation_config.json
CHANGED
@@ -12,5 +12,5 @@
|
|
12 |
"no_repeat_ngram_size": 3,
|
13 |
"num_beams": 4,
|
14 |
"pad_token_id": 1,
|
15 |
-
"transformers_version": "4.
|
16 |
}
|
|
|
12 |
"no_repeat_ngram_size": 3,
|
13 |
"num_beams": 4,
|
14 |
"pad_token_id": 1,
|
15 |
+
"transformers_version": "4.45.1"
|
16 |
}
|
model.safetensors
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:44410d63084e27ab2793e34f98851f76035255851e7a46fcd36d19296845b815
|
3 |
+
size 437961724
|
modeling_modified.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
|
2 |
import sys
|
3 |
import platform
|
4 |
import subprocess
|
5 |
import pkg_resources
|
6 |
import json
|
|
|
7 |
import os
|
8 |
|
9 |
def get_os_info() -> dict:
|
@@ -38,7 +38,7 @@ def get_gpu_info() -> list:
|
|
38 |
# Check for NVIDIA GPUs
|
39 |
try:
|
40 |
nvidia_smi_output = subprocess.check_output(["nvidia-smi", "--query-gpu=name,memory.total,driver_version", "--format=csv,noheader"]).decode("utf-8")
|
41 |
-
gpus = [line.strip().split(", ") for line in nvidia_smi_output.strip().split("
|
42 |
for gpu in gpus:
|
43 |
gpu_info.append({"type": "NVIDIA", "name": gpu[0], "memory": gpu[1], "driver_version": gpu[2]})
|
44 |
except Exception:
|
@@ -81,10 +81,9 @@ def get_env_info() -> dict:
|
|
81 |
"relevant_env_variables": get_env_variables()
|
82 |
}
|
83 |
return env_info
|
|
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
class ModifiedBartForConditionalGenerationWithHook(BartForConditionalGeneration):
|
88 |
"""Modified model class with logging and error handling."""
|
89 |
def __init__(self, config):
|
90 |
super().__init__(config)
|
@@ -103,7 +102,7 @@ class ModifiedBartForConditionalGenerationWithHook(BartForConditionalGeneration)
|
|
103 |
|
104 |
return outputs
|
105 |
except Exception as e:
|
106 |
-
print(f"An error occurred during the forward pass: {
|
107 |
print("Environment info:")
|
108 |
print(json.dumps(get_env_info(), indent=2))
|
109 |
raise e # Re-raise the exception
|
@@ -126,7 +125,7 @@ class ModifiedBartForConditionalGenerationWithHook(BartForConditionalGeneration)
|
|
126 |
|
127 |
return outputs
|
128 |
except Exception as e:
|
129 |
-
print(f"An error occurred during the generate method: {
|
130 |
print("Environment info:")
|
131 |
print(json.dumps(get_env_info(), indent=2))
|
132 |
raise e # Re-raise the exception
|
|
|
|
|
1 |
import sys
|
2 |
import platform
|
3 |
import subprocess
|
4 |
import pkg_resources
|
5 |
import json
|
6 |
+
import traceback
|
7 |
import os
|
8 |
|
9 |
def get_os_info() -> dict:
|
|
|
38 |
# Check for NVIDIA GPUs
|
39 |
try:
|
40 |
nvidia_smi_output = subprocess.check_output(["nvidia-smi", "--query-gpu=name,memory.total,driver_version", "--format=csv,noheader"]).decode("utf-8")
|
41 |
+
gpus = [line.strip().split(", ") for line in nvidia_smi_output.strip().split("\\n")]
|
42 |
for gpu in gpus:
|
43 |
gpu_info.append({"type": "NVIDIA", "name": gpu[0], "memory": gpu[1], "driver_version": gpu[2]})
|
44 |
except Exception:
|
|
|
81 |
"relevant_env_variables": get_env_variables()
|
82 |
}
|
83 |
return env_info
|
84 |
+
from transformers import BertForSequenceClassification
|
85 |
|
86 |
+
class ModifiedBertForSequenceClassificationWithHook(BertForSequenceClassification):
|
|
|
|
|
87 |
"""Modified model class with logging and error handling."""
|
88 |
def __init__(self, config):
|
89 |
super().__init__(config)
|
|
|
102 |
|
103 |
return outputs
|
104 |
except Exception as e:
|
105 |
+
print(f"An error occurred during the forward pass: {traceback.format_exc()}")
|
106 |
print("Environment info:")
|
107 |
print(json.dumps(get_env_info(), indent=2))
|
108 |
raise e # Re-raise the exception
|
|
|
125 |
|
126 |
return outputs
|
127 |
except Exception as e:
|
128 |
+
print(f"An error occurred during the generate method: {traceback.format_exc()}")
|
129 |
print("Environment info:")
|
130 |
print(json.dumps(get_env_info(), indent=2))
|
131 |
raise e # Re-raise the exception
|
special_tokens_map.json
CHANGED
@@ -1,15 +1,7 @@
|
|
1 |
{
|
2 |
-
"
|
3 |
-
"
|
4 |
-
"
|
5 |
-
"
|
6 |
-
|
7 |
-
"lstrip": true,
|
8 |
-
"normalized": true,
|
9 |
-
"rstrip": false,
|
10 |
-
"single_word": false
|
11 |
-
},
|
12 |
-
"pad_token": "<pad>",
|
13 |
-
"sep_token": "</s>",
|
14 |
-
"unk_token": "<unk>"
|
15 |
}
|
|
|
1 |
{
|
2 |
+
"cls_token": "[CLS]",
|
3 |
+
"mask_token": "[MASK]",
|
4 |
+
"pad_token": "[PAD]",
|
5 |
+
"sep_token": "[SEP]",
|
6 |
+
"unk_token": "[UNK]"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
}
|
tokenizer.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
CHANGED
@@ -1,57 +1,57 @@
|
|
1 |
{
|
2 |
-
"add_prefix_space": false,
|
3 |
"added_tokens_decoder": {
|
4 |
"0": {
|
5 |
-
"content": "
|
6 |
"lstrip": false,
|
7 |
-
"normalized":
|
8 |
"rstrip": false,
|
9 |
"single_word": false,
|
10 |
"special": true
|
11 |
},
|
12 |
-
"
|
13 |
-
"content": "
|
14 |
"lstrip": false,
|
15 |
-
"normalized":
|
16 |
"rstrip": false,
|
17 |
"single_word": false,
|
18 |
"special": true
|
19 |
},
|
20 |
-
"
|
21 |
-
"content": "
|
22 |
"lstrip": false,
|
23 |
-
"normalized":
|
24 |
"rstrip": false,
|
25 |
"single_word": false,
|
26 |
"special": true
|
27 |
},
|
28 |
-
"
|
29 |
-
"content": "
|
30 |
"lstrip": false,
|
31 |
-
"normalized":
|
32 |
"rstrip": false,
|
33 |
"single_word": false,
|
34 |
"special": true
|
35 |
},
|
36 |
-
"
|
37 |
-
"content": "
|
38 |
-
"lstrip":
|
39 |
-
"normalized":
|
40 |
"rstrip": false,
|
41 |
"single_word": false,
|
42 |
"special": true
|
43 |
}
|
44 |
},
|
45 |
-
"bos_token": "<s>",
|
46 |
"clean_up_tokenization_spaces": true,
|
47 |
-
"cls_token": "
|
48 |
-
"
|
49 |
-
"
|
50 |
-
"mask_token": "
|
51 |
-
"model_max_length":
|
52 |
-
"
|
53 |
-
"
|
54 |
-
"
|
55 |
-
"
|
56 |
-
"
|
|
|
|
|
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": 512,
|
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
|
|