oliverdk commited on
Commit
7e59788
1 Parent(s): 2b97f0b

End of training

Browse files
.hydra/config.yaml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ model:
2
+ dataset_name: redwoodresearch/diamonds-seed1
3
+ model_type: codegen
4
+ pretrained_model_name: Salesforce/codegen-350M-mono
5
+ max_length: 1024
6
+ hparams:
7
+ learning_rate: 2.0e-05
8
+ weight_decay: 0.02
9
+ lr_scheduler_type: cosine
10
+ warmup_steps: 64
11
+ effective_batch_size: 32
12
+ num_train_epochs: 5
13
+ per_device_train_batch_size: 4
14
+ per_device_eval_batch_size: 4
15
+ fp16: true
16
+ dataset_len: null
17
+ push_to_hub: true
.hydra/hydra.yaml ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ hydra:
2
+ run:
3
+ dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S}
4
+ sweep:
5
+ dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S}
6
+ subdir: ${hydra.job.num}
7
+ launcher:
8
+ submitit_folder: ${hydra.sweep.dir}/.submitit/%j
9
+ timeout_min: 1440
10
+ cpus_per_task: null
11
+ gpus_per_node: null
12
+ tasks_per_node: 1
13
+ mem_gb: 16
14
+ nodes: 1
15
+ name: ${hydra.job.name}
16
+ stderr_to_stdout: false
17
+ _target_: hydra_plugins.hydra_submitit_launcher.submitit_launcher.SlurmLauncher
18
+ partition: null
19
+ qos: high
20
+ comment: null
21
+ constraint: null
22
+ exclude: ddpg.ist.berkeley.edu,dqn.ist.berkeley.edu
23
+ gres: gpu:A6000:1
24
+ cpus_per_gpu: null
25
+ gpus_per_task: null
26
+ mem_per_gpu: null
27
+ mem_per_cpu: null
28
+ account: null
29
+ signal_delay_s: 120
30
+ max_num_timeout: 0
31
+ additional_parameters: {}
32
+ array_parallelism: 256
33
+ setup: null
34
+ sweeper:
35
+ _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper
36
+ max_batch_size: null
37
+ params: null
38
+ help:
39
+ app_name: ${hydra.job.name}
40
+ header: '${hydra.help.app_name} is powered by Hydra.
41
+
42
+ '
43
+ footer: 'Powered by Hydra (https://hydra.cc)
44
+
45
+ Use --hydra-help to view Hydra specific help
46
+
47
+ '
48
+ template: '${hydra.help.header}
49
+
50
+ == Configuration groups ==
51
+
52
+ Compose your configuration from those groups (group=option)
53
+
54
+
55
+ $APP_CONFIG_GROUPS
56
+
57
+
58
+ == Config ==
59
+
60
+ Override anything in the config (foo.bar=value)
61
+
62
+
63
+ $CONFIG
64
+
65
+
66
+ ${hydra.help.footer}
67
+
68
+ '
69
+ hydra_help:
70
+ template: 'Hydra (${hydra.runtime.version})
71
+
72
+ See https://hydra.cc for more info.
73
+
74
+
75
+ == Flags ==
76
+
77
+ $FLAGS_HELP
78
+
79
+
80
+ == Configuration groups ==
81
+
82
+ Compose your configuration from those groups (For example, append hydra/job_logging=disabled
83
+ to command line)
84
+
85
+
86
+ $HYDRA_CONFIG_GROUPS
87
+
88
+
89
+ Use ''--cfg hydra'' to Show the Hydra config.
90
+
91
+ '
92
+ hydra_help: ???
93
+ hydra_logging:
94
+ version: 1
95
+ formatters:
96
+ simple:
97
+ format: '[%(asctime)s][HYDRA] %(message)s'
98
+ handlers:
99
+ console:
100
+ class: logging.StreamHandler
101
+ formatter: simple
102
+ stream: ext://sys.stdout
103
+ root:
104
+ level: INFO
105
+ handlers:
106
+ - console
107
+ loggers:
108
+ logging_example:
109
+ level: DEBUG
110
+ disable_existing_loggers: false
111
+ job_logging:
112
+ version: 1
113
+ formatters:
114
+ simple:
115
+ format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s'
116
+ handlers:
117
+ console:
118
+ class: logging.StreamHandler
119
+ formatter: simple
120
+ stream: ext://sys.stdout
121
+ file:
122
+ class: logging.FileHandler
123
+ formatter: simple
124
+ filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log
125
+ root:
126
+ level: INFO
127
+ handlers:
128
+ - console
129
+ - file
130
+ disable_existing_loggers: false
131
+ env: {}
132
+ mode: MULTIRUN
133
+ searchpath: []
134
+ callbacks: {}
135
+ output_subdir: .hydra
136
+ overrides:
137
+ hydra:
138
+ - hydra.mode=MULTIRUN
139
+ task:
140
+ - model.dataset_name=redwoodresearch/diamonds-seed1
141
+ job:
142
+ name: train
143
+ chdir: null
144
+ override_dirname: model.dataset_name=redwoodresearch/diamonds-seed1
145
+ id: '747438'
146
+ num: 0
147
+ config_name: codegen_diamonds_slurm
148
+ env_set: {}
149
+ env_copy: []
150
+ config:
151
+ override_dirname:
152
+ kv_sep: '='
153
+ item_sep: ','
154
+ exclude_keys: []
155
+ runtime:
156
+ version: 1.3.2
157
+ version_base: '1.1'
158
+ cwd: /nas/ucb/oliveradk/measurement-pred
159
+ config_sources:
160
+ - path: hydra.conf
161
+ schema: pkg
162
+ provider: hydra
163
+ - path: /nas/ucb/oliveradk/measurement-pred/conf
164
+ schema: file
165
+ provider: main
166
+ - path: ''
167
+ schema: structured
168
+ provider: schema
169
+ output_dir: /nas/ucb/oliveradk/measurement-pred/multirun/2024-12-17/07-26-22/0
170
+ choices:
171
+ hparams: hparams
172
+ model: codegen_diamonds
173
+ hydra/env: default
174
+ hydra/callbacks: null
175
+ hydra/job_logging: default
176
+ hydra/hydra_logging: default
177
+ hydra/hydra_help: default
178
+ hydra/help: default
179
+ hydra/sweeper: basic
180
+ hydra/launcher: slurm_chai
181
+ hydra/output: default
182
+ verbose: false
.hydra/overrides.yaml ADDED
@@ -0,0 +1 @@
 
 
1
+ - model.dataset_name=redwoodresearch/diamonds-seed1
README.md CHANGED
@@ -1,199 +1,76 @@
1
  ---
2
- library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
 
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
 
11
 
12
- ## Model Details
13
 
14
- ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
 
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
- ### Model Sources [optional]
29
 
30
- <!-- Provide the basic links for the model. -->
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
 
 
 
 
 
 
 
 
 
35
 
36
- ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
 
 
 
 
 
 
39
 
40
- ### Direct Use
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
-
191
- [More Information Needed]
192
-
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
196
-
197
- ## Model Card Contact
198
-
199
- [More Information Needed]
 
1
  ---
2
+ license: bsd-3-clause
3
+ base_model: Salesforce/codegen-350M-mono
4
+ tags:
5
+ - generated_from_trainer
6
+ metrics:
7
+ - accuracy
8
+ model-index:
9
+ - name: codegen-350M-mono-measurement_pred-diamonds-seed1
10
+ results: []
11
  ---
12
 
13
+ <!-- This model card has been generated automatically according to the information the Trainer had access to. You
14
+ should probably proofread and complete it, then remove this comment. -->
15
 
16
+ # codegen-350M-mono-measurement_pred-diamonds-seed1
17
 
18
+ This model is a fine-tuned version of [Salesforce/codegen-350M-mono](https://huggingface.co/Salesforce/codegen-350M-mono) on an unknown dataset.
19
+ It achieves the following results on the evaluation set:
20
+ - Loss: 0.4208
21
+ - Accuracy: 0.9039
22
+ - Accuracy Sensor 0: 0.8951
23
+ - Auroc Sensor 0: 0.9544
24
+ - Accuracy Sensor 1: 0.9114
25
+ - Auroc Sensor 1: 0.9468
26
+ - Accuracy Sensor 2: 0.9304
27
+ - Auroc Sensor 2: 0.9752
28
+ - Accuracy Aggregated: 0.8787
29
+ - Auroc Aggregated: 0.9601
30
 
31
+ ## Model description
32
 
33
+ More information needed
34
 
35
+ ## Intended uses & limitations
36
 
37
+ More information needed
38
 
39
+ ## Training and evaluation data
40
 
41
+ More information needed
 
 
 
 
 
 
42
 
43
+ ## Training procedure
44
 
45
+ ### Training hyperparameters
46
 
47
+ The following hyperparameters were used during training:
48
+ - learning_rate: 2e-05
49
+ - train_batch_size: 4
50
+ - eval_batch_size: 4
51
+ - seed: 42
52
+ - gradient_accumulation_steps: 8
53
+ - total_train_batch_size: 32
54
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
55
+ - lr_scheduler_type: cosine
56
+ - lr_scheduler_warmup_steps: 64
57
+ - num_epochs: 5
58
+ - mixed_precision_training: Native AMP
59
 
60
+ ### Training results
61
 
62
+ | Training Loss | Epoch | Step | Validation Loss | Accuracy | Accuracy Sensor 0 | Auroc Sensor 0 | Accuracy Sensor 1 | Auroc Sensor 1 | Accuracy Sensor 2 | Auroc Sensor 2 | Accuracy Aggregated | Auroc Aggregated |
63
+ |:-------------:|:------:|:----:|:---------------:|:--------:|:-----------------:|:--------------:|:-----------------:|:--------------:|:-----------------:|:--------------:|:-------------------:|:----------------:|
64
+ | 0.2957 | 0.9997 | 781 | 0.3062 | 0.8755 | 0.8833 | 0.8927 | 0.8724 | 0.8925 | 0.8966 | 0.9193 | 0.8494 | 0.8893 |
65
+ | 0.1972 | 1.9994 | 1562 | 0.2602 | 0.8922 | 0.8898 | 0.9341 | 0.9076 | 0.9355 | 0.9133 | 0.9617 | 0.8582 | 0.9350 |
66
+ | 0.1195 | 2.9990 | 2343 | 0.2889 | 0.8943 | 0.8747 | 0.9475 | 0.9022 | 0.9347 | 0.9168 | 0.9700 | 0.8835 | 0.9516 |
67
+ | 0.0784 | 4.0 | 3125 | 0.3078 | 0.9104 | 0.9084 | 0.9574 | 0.9125 | 0.9486 | 0.9380 | 0.9760 | 0.8828 | 0.9611 |
68
+ | 0.0347 | 4.9984 | 3905 | 0.4208 | 0.9039 | 0.8951 | 0.9544 | 0.9114 | 0.9468 | 0.9304 | 0.9752 | 0.8787 | 0.9601 |
69
 
 
70
 
71
+ ### Framework versions
72
 
73
+ - Transformers 4.41.0
74
+ - Pytorch 2.3.0+cu121
75
+ - Datasets 2.19.1
76
+ - Tokenizers 0.19.1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
added_tokens.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "\t\t": 50294,
3
+ "\t\t\t": 50293,
4
+ "\t\t\t\t": 50292,
5
+ "\t\t\t\t\t": 50291,
6
+ "\t\t\t\t\t\t": 50290,
7
+ "\t\t\t\t\t\t\t": 50289,
8
+ "\t\t\t\t\t\t\t\t": 50288,
9
+ "\t\t\t\t\t\t\t\t\t": 50287,
10
+ " ": 50286,
11
+ " ": 50285,
12
+ " ": 50284,
13
+ " ": 50283,
14
+ " ": 50282,
15
+ " ": 50281,
16
+ " ": 50280,
17
+ " ": 50279,
18
+ " ": 50278,
19
+ " ": 50277,
20
+ " ": 50276,
21
+ " ": 50275,
22
+ " ": 50274,
23
+ " ": 50273,
24
+ " ": 50272,
25
+ " ": 50271,
26
+ " ": 50270,
27
+ " ": 50269,
28
+ " ": 50268,
29
+ " ": 50267,
30
+ " ": 50266,
31
+ " ": 50265,
32
+ " ": 50264,
33
+ " ": 50263,
34
+ " ": 50262,
35
+ " ": 50261,
36
+ " ": 50260,
37
+ " ": 50259,
38
+ " ": 50258,
39
+ " ": 50257
40
+ }
config.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "_name_or_path": "multirun/2024-12-16/09-38-37/0/checkpoint-3905",
3
  "activation_function": "gelu_new",
4
  "aggregate_weight": 0.3,
5
  "architectures": [
@@ -28,6 +28,7 @@
28
  "resid_pdrop": 0.0,
29
  "rotary_dim": 32,
30
  "scale_attn_weights": true,
 
31
  "sensor_token": " omit",
32
  "sensor_token_id": 42848,
33
  "sensors_weight": 0.7,
 
1
  {
2
+ "_name_or_path": "Salesforce/codegen-350M-mono",
3
  "activation_function": "gelu_new",
4
  "aggregate_weight": 0.3,
5
  "architectures": [
 
28
  "resid_pdrop": 0.0,
29
  "rotary_dim": 32,
30
  "scale_attn_weights": true,
31
+ "sensor_loc_type": "locs_from_token",
32
  "sensor_token": " omit",
33
  "sensor_token_id": 42848,
34
  "sensors_weight": 0.7,
configuration_measurement_pred.py CHANGED
@@ -1,12 +1,11 @@
1
  from abc import abstractmethod
2
  from transformers import PretrainedConfig
3
-
4
  class MeasurementPredictorConfig(PretrainedConfig):
5
 
6
  def __init__(
7
  self,
8
  sensor_token=" omit",
9
- sensor_token_id=None, # 35991
10
  n_sensors=3,
11
  use_aggregated=True,
12
  sensors_weight = 0.7,
@@ -14,7 +13,7 @@ class MeasurementPredictorConfig(PretrainedConfig):
14
  **kwargs
15
  ):
16
  self.sensor_token = sensor_token
17
- self.sensor_token_id = sensor_token_id
18
  self.n_sensors = n_sensors
19
  self.use_aggregated = use_aggregated
20
  self.sensors_weight = sensors_weight
 
1
  from abc import abstractmethod
2
  from transformers import PretrainedConfig
 
3
  class MeasurementPredictorConfig(PretrainedConfig):
4
 
5
  def __init__(
6
  self,
7
  sensor_token=" omit",
8
+ sensor_loc_type="locs_from_token",
9
  n_sensors=3,
10
  use_aggregated=True,
11
  sensors_weight = 0.7,
 
13
  **kwargs
14
  ):
15
  self.sensor_token = sensor_token
16
+ self.sensor_loc_type = sensor_loc_type
17
  self.n_sensors = n_sensors
18
  self.use_aggregated = use_aggregated
19
  self.sensors_weight = sensors_weight
logs/events.out.tfevents.1734449259.gail.ist.berkeley.edu.2164200.0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f2e41afc7f407fc05f1fa23c0ac11383aa446decd69608ac285b2bde2241d367
3
+ size 16069
logs/events.out.tfevents.1734449259.gail.ist.berkeley.edu.2164202.0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dc8e0c1ebaeb3911235992cf8c244ec725d9fb7f9dedf62e710a2549ff901085
3
+ size 16069
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6db46790e772f6c64c2feada56506ffb0cddfc2c34220f42811ed42410ffa2ba
3
  size 1216963976
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:534b1793885a479e7ba9217ee8a820a82d9ab8fd5fa08e9f8fecbdfae51bce71
3
  size 1216963976
modeling_measurement_pred.py CHANGED
@@ -3,14 +3,19 @@ from typing import Optional, Tuple, Union
3
  import torch
4
  from torch.nn import BCEWithLogitsLoss
5
  from transformers import PreTrainedModel, PreTrainedTokenizer
 
6
  from transformers.modeling_outputs import BaseModelOutputWithPast, SequenceClassifierOutputWithPast
7
 
 
 
 
 
8
  class MeasurementPredictorMixin(PreTrainedModel):
9
 
10
  def __init__(self, config):
11
  super().__init__(config)
 
12
  self.sensor_token = config.sensor_token
13
- self.sensor_token_id = config.sensor_token_id
14
  self.n_sensors = config.n_sensors
15
  self.sensor_probes = torch.nn.ModuleList([
16
  torch.nn.Linear(config.emb_dim, 1) for _ in range(config.n_sensors)
@@ -20,15 +25,13 @@ class MeasurementPredictorMixin(PreTrainedModel):
20
  self.aggregate_probe = torch.nn.Linear(config.emb_dim, 1)
21
  self.sensors_weight = config.sensors_weight
22
  self.aggregate_weight = config.aggregate_weight
 
 
23
 
24
- def check_tokenizer(self, tokenizer: PreTrainedTokenizer):
25
- sensor_token_id = tokenizer.convert_tokens_to_ids(tokenizer.tokenize(self.sensor_token))[0]
26
- assert sensor_token_id == self.sensor_token_id
27
-
28
- def set_sensor_token(self, sensor_token: str, tokenizer: PreTrainedTokenizer):
29
- sensor_token_id = tokenizer.tokenize(sensor_token)[0]
30
- self.sensor_token = sensor_token
31
- self.sensor_token_id = sensor_token_id
32
 
33
  def forward(
34
  self,
@@ -64,10 +67,9 @@ class MeasurementPredictorMixin(PreTrainedModel):
64
  output_hidden_states=output_hidden_states,
65
  return_dict=return_dict,
66
  )
67
- flat_tensor_token_idxs = (input_ids == self.sensor_token_id).nonzero(as_tuple=True)[1]
68
- tensor_token_idxs = flat_tensor_token_idxs.view(-1, self.n_sensors)
69
  sensor_embs = base_model_output.last_hidden_state.gather(
70
- 1, tensor_token_idxs.unsqueeze(-1).expand(-1, -1, self.config.emb_dim)
71
  )
72
  assert sensor_embs.shape == (input_ids.shape[0], self.n_sensors, self.config.emb_dim), f"{sensor_embs.shape} != {(input_ids.shape[0], self.n_sensors, self.config.emb_dim)}"
73
  sensor_logits = torch.concat([self.sensor_probes[i](sensor_embs[:, i, :])
 
3
  import torch
4
  from torch.nn import BCEWithLogitsLoss
5
  from transformers import PreTrainedModel, PreTrainedTokenizer
6
+ from transformers.tokenization_utils_base import PreTrainedTokenizerBase
7
  from transformers.modeling_outputs import BaseModelOutputWithPast, SequenceClassifierOutputWithPast
8
 
9
+
10
+ from .sensor_loc_reg import SENSOR_LOC_REGISTRY
11
+ from .sensor_loc_finder import SensorLocFinder
12
+
13
  class MeasurementPredictorMixin(PreTrainedModel):
14
 
15
  def __init__(self, config):
16
  super().__init__(config)
17
+ self.sensor_loc_type = config.sensor_loc_type
18
  self.sensor_token = config.sensor_token
 
19
  self.n_sensors = config.n_sensors
20
  self.sensor_probes = torch.nn.ModuleList([
21
  torch.nn.Linear(config.emb_dim, 1) for _ in range(config.n_sensors)
 
25
  self.aggregate_probe = torch.nn.Linear(config.emb_dim, 1)
26
  self.sensors_weight = config.sensors_weight
27
  self.aggregate_weight = config.aggregate_weight
28
+
29
+ self.get_sensor_locs: SensorLocFinder = None
30
 
31
+ def init_sensor_loc_finder(self, tokenizer: PreTrainedTokenizerBase):
32
+ self.get_sensor_locs = SENSOR_LOC_REGISTRY[self.sensor_loc_type](
33
+ tokenizer, sensor_token=self.sensor_token, n_sensors=self.n_sensors
34
+ )
 
 
 
 
35
 
36
  def forward(
37
  self,
 
67
  output_hidden_states=output_hidden_states,
68
  return_dict=return_dict,
69
  )
70
+ sensor_locs = self.get_sensor_locs(input_ids)
 
71
  sensor_embs = base_model_output.last_hidden_state.gather(
72
+ 1, sensor_locs.unsqueeze(-1).expand(-1, -1, self.config.emb_dim)
73
  )
74
  assert sensor_embs.shape == (input_ids.shape[0], self.n_sensors, self.config.emb_dim), f"{sensor_embs.shape} != {(input_ids.shape[0], self.n_sensors, self.config.emb_dim)}"
75
  sensor_logits = torch.concat([self.sensor_probes[i](sensor_embs[:, i, :])
sensor_loc_finder.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from abc import ABC, abstractmethod
2
+ import torch
3
+ from transformers import PreTrainedTokenizerBase
4
+
5
+
6
+ class SensorLocFinder(ABC):
7
+
8
+ @abstractmethod
9
+ def __init__(self, tokenizer: PreTrainedTokenizerBase, **kwargs):
10
+ pass
11
+
12
+ @abstractmethod
13
+ def find_sensor_locs(self, input_ids: torch.Tensor) -> torch.Tensor:
14
+ pass
15
+
16
+ def __call__(self, input_ids: torch.Tensor) -> torch.Tensor:
17
+ return self.find_sensor_locs(input_ids)
sensor_loc_reg.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from enum import Enum
2
+
3
+ from .sensor_loc_stories import StoriesSensorLocFinder
4
+ from .sensor_locs_from_token import SensorLocFinderFromToken
5
+
6
+
7
+ SENSOR_LOC_REGISTRY = {
8
+ "stories": StoriesSensorLocFinder,
9
+ "locs_from_token": SensorLocFinderFromToken
10
+ }
sensor_loc_stories.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import PreTrainedTokenizerBase
3
+
4
+ from .sensor_loc_finder import SensorLocFinder
5
+
6
+
7
+ class StoriesSensorLocFinder(SensorLocFinder):
8
+
9
+ def __init__(self, tokenizer: PreTrainedTokenizerBase, **kwargs):
10
+ self.questions_section_toks = tokenizer.encode("## Questions")
11
+ self.question_mark_tok = tokenizer.encode("?")[0]
12
+ self.other_question_mark_tok = tokenizer.encode(")?")[0]
13
+ assert len(self.questions_section_toks) == 2
14
+
15
+ def find_sensor_locs(self, input_ids: torch.Tensor) -> torch.Tensor:
16
+ device = input_ids.device
17
+ question_mark_locs = self._is_sensor_loc(input_ids)
18
+ total_locs = torch.cumsum(question_mark_locs, dim=-1)
19
+ total_overall = total_locs[:, -1]
20
+ assert (
21
+ total_overall == 3
22
+ ).all(), "can handle different cases, but assuming this is easiest"
23
+ eqs = total_locs[:, :, None] == torch.arange(1, 4)[None, None].to(device)
24
+ locs = torch.where(
25
+ eqs.any(dim=-2),
26
+ torch.argmax(eqs.to(torch.uint8), dim=-2),
27
+ input_ids.shape[-1] - 3,
28
+ ).clamp(max=input_ids.shape[-1] - 3)
29
+ return locs
30
+
31
+
32
+ def _is_sensor_loc(self, input_ids: torch.Tensor):
33
+ questions_section_toks = self.questions_section_toks
34
+ question_mark_tok = self.question_mark_tok
35
+ other_question_mark_tok = self.other_question_mark_tok
36
+ eq_question_item = (input_ids[:, :-1] == questions_section_toks[0]) & (
37
+ input_ids[:, 1:] == questions_section_toks[1]
38
+ )
39
+ assert (eq_question_item.sum(dim=-1, dtype=torch.int) == 1).all(), "could relax"
40
+
41
+ summed = torch.cumsum(
42
+ torch.cat([eq_question_item, eq_question_item[:, -1:]], dim=-1), dim=-1
43
+ )
44
+ return (summed > 0) & (
45
+ (input_ids == question_mark_tok) | (input_ids == other_question_mark_tok)
46
+ )
sensor_locs_from_token.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import PreTrainedTokenizerBase
3
+
4
+ from .sensor_loc_finder import SensorLocFinder
5
+
6
+
7
+ class SensorLocFinderFromToken(SensorLocFinder):
8
+
9
+ def __init__(self, tokenizer: PreTrainedTokenizerBase, sensor_token: str, n_sensors: int):
10
+ self.sensor_token_id = tokenizer.encode(sensor_token)[0]
11
+ self.n_sensors = n_sensors
12
+
13
+ def find_sensor_locs(self, input_ids: torch.Tensor) -> torch.Tensor:
14
+ flat_sensor_token_idxs = (input_ids == self.sensor_token_id).nonzero(as_tuple=True)[1]
15
+ sensor_token_idxs = flat_sensor_token_idxs.view(-1, self.n_sensors)
16
+ return sensor_token_idxs
special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|endoftext|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "<|endoftext|>",
17
+ "unk_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,327 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "50256": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "50257": {
13
+ "content": " ",
14
+ "lstrip": false,
15
+ "normalized": true,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": false
19
+ },
20
+ "50258": {
21
+ "content": " ",
22
+ "lstrip": false,
23
+ "normalized": true,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": false
27
+ },
28
+ "50259": {
29
+ "content": " ",
30
+ "lstrip": false,
31
+ "normalized": true,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": false
35
+ },
36
+ "50260": {
37
+ "content": " ",
38
+ "lstrip": false,
39
+ "normalized": true,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": false
43
+ },
44
+ "50261": {
45
+ "content": " ",
46
+ "lstrip": false,
47
+ "normalized": true,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": false
51
+ },
52
+ "50262": {
53
+ "content": " ",
54
+ "lstrip": false,
55
+ "normalized": true,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": false
59
+ },
60
+ "50263": {
61
+ "content": " ",
62
+ "lstrip": false,
63
+ "normalized": true,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": false
67
+ },
68
+ "50264": {
69
+ "content": " ",
70
+ "lstrip": false,
71
+ "normalized": true,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": false
75
+ },
76
+ "50265": {
77
+ "content": " ",
78
+ "lstrip": false,
79
+ "normalized": true,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": false
83
+ },
84
+ "50266": {
85
+ "content": " ",
86
+ "lstrip": false,
87
+ "normalized": true,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": false
91
+ },
92
+ "50267": {
93
+ "content": " ",
94
+ "lstrip": false,
95
+ "normalized": true,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": false
99
+ },
100
+ "50268": {
101
+ "content": " ",
102
+ "lstrip": false,
103
+ "normalized": true,
104
+ "rstrip": false,
105
+ "single_word": false,
106
+ "special": false
107
+ },
108
+ "50269": {
109
+ "content": " ",
110
+ "lstrip": false,
111
+ "normalized": true,
112
+ "rstrip": false,
113
+ "single_word": false,
114
+ "special": false
115
+ },
116
+ "50270": {
117
+ "content": " ",
118
+ "lstrip": false,
119
+ "normalized": true,
120
+ "rstrip": false,
121
+ "single_word": false,
122
+ "special": false
123
+ },
124
+ "50271": {
125
+ "content": " ",
126
+ "lstrip": false,
127
+ "normalized": true,
128
+ "rstrip": false,
129
+ "single_word": false,
130
+ "special": false
131
+ },
132
+ "50272": {
133
+ "content": " ",
134
+ "lstrip": false,
135
+ "normalized": true,
136
+ "rstrip": false,
137
+ "single_word": false,
138
+ "special": false
139
+ },
140
+ "50273": {
141
+ "content": " ",
142
+ "lstrip": false,
143
+ "normalized": true,
144
+ "rstrip": false,
145
+ "single_word": false,
146
+ "special": false
147
+ },
148
+ "50274": {
149
+ "content": " ",
150
+ "lstrip": false,
151
+ "normalized": true,
152
+ "rstrip": false,
153
+ "single_word": false,
154
+ "special": false
155
+ },
156
+ "50275": {
157
+ "content": " ",
158
+ "lstrip": false,
159
+ "normalized": true,
160
+ "rstrip": false,
161
+ "single_word": false,
162
+ "special": false
163
+ },
164
+ "50276": {
165
+ "content": " ",
166
+ "lstrip": false,
167
+ "normalized": true,
168
+ "rstrip": false,
169
+ "single_word": false,
170
+ "special": false
171
+ },
172
+ "50277": {
173
+ "content": " ",
174
+ "lstrip": false,
175
+ "normalized": true,
176
+ "rstrip": false,
177
+ "single_word": false,
178
+ "special": false
179
+ },
180
+ "50278": {
181
+ "content": " ",
182
+ "lstrip": false,
183
+ "normalized": true,
184
+ "rstrip": false,
185
+ "single_word": false,
186
+ "special": false
187
+ },
188
+ "50279": {
189
+ "content": " ",
190
+ "lstrip": false,
191
+ "normalized": true,
192
+ "rstrip": false,
193
+ "single_word": false,
194
+ "special": false
195
+ },
196
+ "50280": {
197
+ "content": " ",
198
+ "lstrip": false,
199
+ "normalized": true,
200
+ "rstrip": false,
201
+ "single_word": false,
202
+ "special": false
203
+ },
204
+ "50281": {
205
+ "content": " ",
206
+ "lstrip": false,
207
+ "normalized": true,
208
+ "rstrip": false,
209
+ "single_word": false,
210
+ "special": false
211
+ },
212
+ "50282": {
213
+ "content": " ",
214
+ "lstrip": false,
215
+ "normalized": true,
216
+ "rstrip": false,
217
+ "single_word": false,
218
+ "special": false
219
+ },
220
+ "50283": {
221
+ "content": " ",
222
+ "lstrip": false,
223
+ "normalized": true,
224
+ "rstrip": false,
225
+ "single_word": false,
226
+ "special": false
227
+ },
228
+ "50284": {
229
+ "content": " ",
230
+ "lstrip": false,
231
+ "normalized": true,
232
+ "rstrip": false,
233
+ "single_word": false,
234
+ "special": false
235
+ },
236
+ "50285": {
237
+ "content": " ",
238
+ "lstrip": false,
239
+ "normalized": true,
240
+ "rstrip": false,
241
+ "single_word": false,
242
+ "special": false
243
+ },
244
+ "50286": {
245
+ "content": " ",
246
+ "lstrip": false,
247
+ "normalized": true,
248
+ "rstrip": false,
249
+ "single_word": false,
250
+ "special": false
251
+ },
252
+ "50287": {
253
+ "content": "\t\t\t\t\t\t\t\t\t",
254
+ "lstrip": false,
255
+ "normalized": true,
256
+ "rstrip": false,
257
+ "single_word": false,
258
+ "special": false
259
+ },
260
+ "50288": {
261
+ "content": "\t\t\t\t\t\t\t\t",
262
+ "lstrip": false,
263
+ "normalized": true,
264
+ "rstrip": false,
265
+ "single_word": false,
266
+ "special": false
267
+ },
268
+ "50289": {
269
+ "content": "\t\t\t\t\t\t\t",
270
+ "lstrip": false,
271
+ "normalized": true,
272
+ "rstrip": false,
273
+ "single_word": false,
274
+ "special": false
275
+ },
276
+ "50290": {
277
+ "content": "\t\t\t\t\t\t",
278
+ "lstrip": false,
279
+ "normalized": true,
280
+ "rstrip": false,
281
+ "single_word": false,
282
+ "special": false
283
+ },
284
+ "50291": {
285
+ "content": "\t\t\t\t\t",
286
+ "lstrip": false,
287
+ "normalized": true,
288
+ "rstrip": false,
289
+ "single_word": false,
290
+ "special": false
291
+ },
292
+ "50292": {
293
+ "content": "\t\t\t\t",
294
+ "lstrip": false,
295
+ "normalized": true,
296
+ "rstrip": false,
297
+ "single_word": false,
298
+ "special": false
299
+ },
300
+ "50293": {
301
+ "content": "\t\t\t",
302
+ "lstrip": false,
303
+ "normalized": true,
304
+ "rstrip": false,
305
+ "single_word": false,
306
+ "special": false
307
+ },
308
+ "50294": {
309
+ "content": "\t\t",
310
+ "lstrip": false,
311
+ "normalized": true,
312
+ "rstrip": false,
313
+ "single_word": false,
314
+ "special": false
315
+ }
316
+ },
317
+ "bos_token": "<|endoftext|>",
318
+ "clean_up_tokenization_spaces": true,
319
+ "eos_token": "<|endoftext|>",
320
+ "model_max_length": 2048,
321
+ "pad_token": "<|endoftext|>",
322
+ "padding_side": "left",
323
+ "return_token_type_ids": false,
324
+ "tokenizer_class": "CodeGenTokenizer",
325
+ "truncation_side": "left",
326
+ "unk_token": "<|endoftext|>"
327
+ }
train.log ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ [2024-12-17 07:27:38,728][accelerate.utils.other][WARNING] - Detected kernel version 5.4.0, which is below the recommended minimum of 5.5.0; this can cause the process to hang. It is recommended to upgrade the kernel to the minimum version or higher.
2
+ [2024-12-17 07:27:38,922][accelerate.utils.other][WARNING] - Detected kernel version 5.4.0, which is below the recommended minimum of 5.5.0; this can cause the process to hang. It is recommended to upgrade the kernel to the minimum version or higher.
3
+ [2024-12-17 11:28:11,228][submitit][INFO] - Job completed successfully
4
+ [2024-12-17 11:28:11,254][submitit][INFO] - Exiting after successful completion
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:46537025ed79b806772f1037bd9e69b5421224e3503ae4b33b08f8564cbf2a86
3
+ size 5112
vocab.json ADDED
The diff for this file is too large to render. See raw diff