Upload modeling_mists.py
Browse files- modeling_mists.py +0 -19
modeling_mists.py
CHANGED
@@ -137,12 +137,6 @@ class MistsForConditionalGeneration(MistsPreTrainedModel):
|
|
137 |
# Compute the maximum embed dimension
|
138 |
max_embed_dim = (num_special_time_series_tokens.max() * (num_time_series_patches - 1)) + sequence_length
|
139 |
max_embed_dim = int(max_embed_dim.item()) # γγ³γ½γ«γγζ΄ζ°ε€γεεΎ
|
140 |
-
if max_embed_dim is None:
|
141 |
-
print(f"num_special_time_series_tokens.max(): {num_special_time_series_tokens.max()}")
|
142 |
-
print(f"num_time_series_patches: {num_time_series_patches}")
|
143 |
-
print(f"sequence_length: {sequence_length}")
|
144 |
-
else:
|
145 |
-
print(f"max_embed_dim 0: {max_embed_dim}")
|
146 |
batch_indices, non_time_series_indices = torch.where(input_ids != self.config.time_series_token_index)
|
147 |
|
148 |
# 2. Compute the positions where text should be written
|
@@ -181,16 +175,10 @@ class MistsForConditionalGeneration(MistsPreTrainedModel):
|
|
181 |
# we need to index copy on [0, 577, 578, 579] for the text and [1:576] for the time_series features
|
182 |
final_embedding[batch_indices, text_to_overwrite] = inputs_embeds[batch_indices, non_time_series_indices]
|
183 |
final_attention_mask[batch_indices, text_to_overwrite] = attention_mask[batch_indices, non_time_series_indices]
|
184 |
-
print("max_embed_dim is None: ", (max_embed_dim is None))
|
185 |
-
print("max_embed_dim: ", max_embed_dim)
|
186 |
if labels is not None:
|
187 |
final_labels[batch_indices, text_to_overwrite] = labels[batch_indices, non_time_series_indices]
|
188 |
-
print("max_embed_dim is None: ", (max_embed_dim is None))
|
189 |
-
print("max_embed_dim: ", max_embed_dim)
|
190 |
|
191 |
# 5. Fill the embeddings corresponding to the time_series. Anything that is not `text_positions` needs filling (#29835)
|
192 |
-
print("inputs_embeds.device: ", inputs_embeds.device)
|
193 |
-
print("max_embed_dim: ", max_embed_dim, " is None: ", (max_embed_dim is None))
|
194 |
time_series_to_overwrite = torch.full(
|
195 |
(batch_size, max_embed_dim), True, dtype=torch.bool, device=inputs_embeds.device
|
196 |
)
|
@@ -251,14 +239,9 @@ class MistsForConditionalGeneration(MistsPreTrainedModel):
|
|
251 |
# else self.config.vision_feature_select_strategy
|
252 |
# )
|
253 |
|
254 |
-
print("========")
|
255 |
-
print("input_ids: ", input_ids.shape)
|
256 |
-
print("time_series_values: ", time_series_values.shape)
|
257 |
-
|
258 |
if inputs_embeds is None:
|
259 |
# 1. Extra the input embeddings
|
260 |
inputs_embeds = self.get_input_embeddings()(input_ids)
|
261 |
-
print("inputs_embeds: ", inputs_embeds.shape)
|
262 |
|
263 |
# 2. Merge text and time_series
|
264 |
if time_series_values is not None and input_ids.shape[1] != 1:
|
@@ -305,8 +288,6 @@ class MistsForConditionalGeneration(MistsPreTrainedModel):
|
|
305 |
|
306 |
attention_mask = torch.cat((extended_attention_mask, attention_mask[:, -target_length:]), dim=1)
|
307 |
position_ids = torch.sum(attention_mask, dim=1).unsqueeze(-1) - 1
|
308 |
-
|
309 |
-
print("inputs_embeds: ", inputs_embeds.shape)
|
310 |
|
311 |
outputs = self.language_model(
|
312 |
attention_mask=attention_mask,
|
|
|
137 |
# Compute the maximum embed dimension
|
138 |
max_embed_dim = (num_special_time_series_tokens.max() * (num_time_series_patches - 1)) + sequence_length
|
139 |
max_embed_dim = int(max_embed_dim.item()) # γγ³γ½γ«γγζ΄ζ°ε€γεεΎ
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
batch_indices, non_time_series_indices = torch.where(input_ids != self.config.time_series_token_index)
|
141 |
|
142 |
# 2. Compute the positions where text should be written
|
|
|
175 |
# we need to index copy on [0, 577, 578, 579] for the text and [1:576] for the time_series features
|
176 |
final_embedding[batch_indices, text_to_overwrite] = inputs_embeds[batch_indices, non_time_series_indices]
|
177 |
final_attention_mask[batch_indices, text_to_overwrite] = attention_mask[batch_indices, non_time_series_indices]
|
|
|
|
|
178 |
if labels is not None:
|
179 |
final_labels[batch_indices, text_to_overwrite] = labels[batch_indices, non_time_series_indices]
|
|
|
|
|
180 |
|
181 |
# 5. Fill the embeddings corresponding to the time_series. Anything that is not `text_positions` needs filling (#29835)
|
|
|
|
|
182 |
time_series_to_overwrite = torch.full(
|
183 |
(batch_size, max_embed_dim), True, dtype=torch.bool, device=inputs_embeds.device
|
184 |
)
|
|
|
239 |
# else self.config.vision_feature_select_strategy
|
240 |
# )
|
241 |
|
|
|
|
|
|
|
|
|
242 |
if inputs_embeds is None:
|
243 |
# 1. Extra the input embeddings
|
244 |
inputs_embeds = self.get_input_embeddings()(input_ids)
|
|
|
245 |
|
246 |
# 2. Merge text and time_series
|
247 |
if time_series_values is not None and input_ids.shape[1] != 1:
|
|
|
288 |
|
289 |
attention_mask = torch.cat((extended_attention_mask, attention_mask[:, -target_length:]), dim=1)
|
290 |
position_ids = torch.sum(attention_mask, dim=1).unsqueeze(-1) - 1
|
|
|
|
|
291 |
|
292 |
outputs = self.language_model(
|
293 |
attention_mask=attention_mask,
|