Update modeling_minicpmv.py
Browse files- modeling_minicpmv.py +2 -1
modeling_minicpmv.py
CHANGED
|
@@ -295,7 +295,7 @@ class MiniCPMV(MiniCPMVPreTrainedModel):
|
|
| 295 |
pad_embedding_vector = embedding_layer.weight[0]
|
| 296 |
vector_reshaped = pad_embedding_vector.view(1, 1, 4096)
|
| 297 |
|
| 298 |
-
for tensor in batch:
|
| 299 |
to_add = []
|
| 300 |
for pl in range(tensor.shape[1]):
|
| 301 |
to_add.append(1)
|
|
@@ -304,6 +304,7 @@ class MiniCPMV(MiniCPMVPreTrainedModel):
|
|
| 304 |
tensor = torch.cat((tensor, vector_reshaped), dim=1)
|
| 305 |
to_add.append(0)
|
| 306 |
print(tensor.shape, "UPDATED_SHAPE")
|
|
|
|
| 307 |
attention_mask.append(to_add)
|
| 308 |
attention_mask = torch.tensor(attention_mask)
|
| 309 |
|
|
|
|
| 295 |
pad_embedding_vector = embedding_layer.weight[0]
|
| 296 |
vector_reshaped = pad_embedding_vector.view(1, 1, 4096)
|
| 297 |
|
| 298 |
+
for place, tensor in enumerate(batch):
|
| 299 |
to_add = []
|
| 300 |
for pl in range(tensor.shape[1]):
|
| 301 |
to_add.append(1)
|
|
|
|
| 304 |
tensor = torch.cat((tensor, vector_reshaped), dim=1)
|
| 305 |
to_add.append(0)
|
| 306 |
print(tensor.shape, "UPDATED_SHAPE")
|
| 307 |
+
batch[place] = tensor
|
| 308 |
attention_mask.append(to_add)
|
| 309 |
attention_mask = torch.tensor(attention_mask)
|
| 310 |
|