anicolson commited on
Commit
7d7afdc
1 Parent(s): 3e7fb25

Upload model

Browse files
config.json CHANGED
@@ -1,10 +1,10 @@
1
  {
2
  "_commit_hash": null,
3
  "architectures": [
4
- "LongitudinalPromptVariableCXREncoderDecoderModel"
5
  ],
6
  "auto_map": {
7
- "AutoModel": "modelling_longitudinal.LongitudinalPromptVariableCXREncoderDecoderModel"
8
  },
9
  "decoder": {
10
  "_name_or_path": "",
@@ -78,7 +78,7 @@
78
  "top_p": 1.0,
79
  "torch_dtype": null,
80
  "torchscript": false,
81
- "transformers_version": "4.28.1",
82
  "type_vocab_size": 2,
83
  "typical_p": 1.0,
84
  "use_bfloat16": false,
@@ -2243,7 +2243,7 @@
2243
  "top_p": 1.0,
2244
  "torch_dtype": "float32",
2245
  "torchscript": false,
2246
- "transformers_version": "4.28.1",
2247
  "typical_p": 1.0,
2248
  "use_bfloat16": false
2249
  },
 
1
  {
2
  "_commit_hash": null,
3
  "architectures": [
4
+ "LongitudinalPromptMultiCXREncoderDecoderModel"
5
  ],
6
  "auto_map": {
7
+ "AutoModel": "modelling_longitudinal.LongitudinalPromptMultiCXREncoderDecoderModel"
8
  },
9
  "decoder": {
10
  "_name_or_path": "",
 
78
  "top_p": 1.0,
79
  "torch_dtype": null,
80
  "torchscript": false,
81
+ "transformers_version": "4.31.0",
82
  "type_vocab_size": 2,
83
  "typical_p": 1.0,
84
  "use_bfloat16": false,
 
2243
  "top_p": 1.0,
2244
  "torch_dtype": "float32",
2245
  "torchscript": false,
2246
+ "transformers_version": "4.31.0",
2247
  "typical_p": 1.0,
2248
  "use_bfloat16": false
2249
  },
generation_config.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
  "_from_model_config": true,
3
  "pad_token_id": 0,
4
- "transformers_version": "4.28.1"
5
  }
 
1
  {
2
  "_from_model_config": true,
3
  "pad_token_id": 0,
4
+ "transformers_version": "4.31.0"
5
  }
modelling_longitudinal.py CHANGED
@@ -47,7 +47,7 @@ class CvtProjectionHead(torch.nn.Module):
47
  return x
48
 
49
 
50
- class VariableCvtWithProjectionHead(transformers.CvtPreTrainedModel):
51
  def __init__(self, config):
52
  super().__init__(config)
53
 
@@ -93,7 +93,7 @@ class VariableCvtWithProjectionHead(transformers.CvtPreTrainedModel):
93
  )
94
 
95
 
96
- class LongitudinalPromptVariableCXREncoderDecoderModel(VisionEncoderDecoderModel):
97
 
98
  config_class = VisionEncoderDecoderConfig
99
  base_model_prefix = "vision_encoder_decoder"
@@ -127,7 +127,7 @@ class LongitudinalPromptVariableCXREncoderDecoderModel(VisionEncoderDecoderModel
127
 
128
  # Encoder:
129
  if encoder is None:
130
- encoder = VariableCvtWithProjectionHead(config=config.encoder)
131
 
132
  # Decoder:
133
  if decoder is None:
@@ -150,7 +150,7 @@ class LongitudinalPromptVariableCXREncoderDecoderModel(VisionEncoderDecoderModel
150
  self.encoder.config = self.config.encoder
151
  self.decoder.config = self.config.decoder
152
 
153
- # Load variable checkpoint:
154
  if encoder_decoder_ckpt_name:
155
  encoder_decoder = AutoModel.from_pretrained(encoder_decoder_ckpt_name, trust_remote_code=True)
156
  self.load_state_dict(encoder_decoder.state_dict())
@@ -266,6 +266,12 @@ class LongitudinalPromptVariableCXREncoderDecoderModel(VisionEncoderDecoderModel
266
  https://github.com/huggingface/transformers/blob/main/src/transformers/models/encoder_decoder/modeling_encoder_decoder.py#L660
267
  """
268
 
 
 
 
 
 
 
269
  decoder_inputs = self.decoder.prepare_inputs_for_generation(input_ids, past_key_values=past_key_values)
270
  decoder_attention_mask = (input_ids != mask_token_id).int()
271
  decoder_position_ids = torch.nn.functional.relu(
 
47
  return x
48
 
49
 
50
+ class MultiCvtWithProjectionHead(transformers.CvtPreTrainedModel):
51
  def __init__(self, config):
52
  super().__init__(config)
53
 
 
93
  )
94
 
95
 
96
+ class LongitudinalPromptMultiCXREncoderDecoderModel(VisionEncoderDecoderModel):
97
 
98
  config_class = VisionEncoderDecoderConfig
99
  base_model_prefix = "vision_encoder_decoder"
 
127
 
128
  # Encoder:
129
  if encoder is None:
130
+ encoder = MultiCvtWithProjectionHead(config=config.encoder)
131
 
132
  # Decoder:
133
  if decoder is None:
 
150
  self.encoder.config = self.config.encoder
151
  self.decoder.config = self.config.decoder
152
 
153
+ # Load multi checkpoint:
154
  if encoder_decoder_ckpt_name:
155
  encoder_decoder = AutoModel.from_pretrained(encoder_decoder_ckpt_name, trust_remote_code=True)
156
  self.load_state_dict(encoder_decoder.state_dict())
 
266
  https://github.com/huggingface/transformers/blob/main/src/transformers/models/encoder_decoder/modeling_encoder_decoder.py#L660
267
  """
268
 
269
+ # An update to generate() now prepends bos_token_id to each sequence if it does not exist at the start of the input:
270
+ # https://github.com/huggingface/transformers/blob/d533465150532b0c5de167b574e59f64c68b1154/src/transformers/generation/utils.py#L699C13-L699C30
271
+ # Hence, we remove the prepended bos_token_id from each sequence if it is there:
272
+ if torch.all(input_ids[:, 0] == 1):
273
+ input_ids = input_ids[:, 1:]
274
+
275
  decoder_inputs = self.decoder.prepare_inputs_for_generation(input_ids, past_key_values=past_key_values)
276
  decoder_attention_mask = (input_ids != mask_token_id).int()
277
  decoder_position_ids = torch.nn.functional.relu(
pytorch_model.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:279780778130d2a0378261470937f17960bcd9e109f347209c41277a87db95a2
3
- size 450315441
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1c18b94af309415cfd3c6169cfb5a5261a1c50d8707413bd56b1426a1cc0fcf
3
+ size 450311021