Update modeling_hf_nomic_bert.py
Browse files
modeling_hf_nomic_bert.py
CHANGED
@@ -16,7 +16,7 @@ from einops import rearrange, repeat
|
|
16 |
from transformers import GPT2Config, PreTrainedModel
|
17 |
from transformers.models.bert.modeling_bert import (
|
18 |
BaseModelOutputWithPoolingAndCrossAttentions,
|
19 |
-
|
20 |
SequenceClassifierOutput
|
21 |
)
|
22 |
|
@@ -323,6 +323,8 @@ class NomicBertPreTrainedModel(PreTrainedModel):
|
|
323 |
rotary_scaling_factor = kwargs.pop("rotary_scaling_factor", None)
|
324 |
if rotary_scaling_factor:
|
325 |
config.rotary_scaling_factor = rotary_scaling_factor
|
|
|
|
|
326 |
if config.n_positions <= 0 and config.rotary_emb_fraction > 0:
|
327 |
config.n_positions = 2048
|
328 |
if num_labels:
|
@@ -1145,9 +1147,11 @@ class NomicBertForPreTraining(NomicBertPreTrainedModel):
|
|
1145 |
)
|
1146 |
total_loss = masked_lm_loss.float()
|
1147 |
|
1148 |
-
return
|
1149 |
loss=total_loss,
|
1150 |
-
|
|
|
|
|
1151 |
)
|
1152 |
|
1153 |
|
|
|
16 |
from transformers import GPT2Config, PreTrainedModel
|
17 |
from transformers.models.bert.modeling_bert import (
|
18 |
BaseModelOutputWithPoolingAndCrossAttentions,
|
19 |
+
MaskedLMOutput,
|
20 |
SequenceClassifierOutput
|
21 |
)
|
22 |
|
|
|
323 |
rotary_scaling_factor = kwargs.pop("rotary_scaling_factor", None)
|
324 |
if rotary_scaling_factor:
|
325 |
config.rotary_scaling_factor = rotary_scaling_factor
|
326 |
+
else:
|
327 |
+
config.rotary_scaling_factor = None
|
328 |
if config.n_positions <= 0 and config.rotary_emb_fraction > 0:
|
329 |
config.n_positions = 2048
|
330 |
if num_labels:
|
|
|
1147 |
)
|
1148 |
total_loss = masked_lm_loss.float()
|
1149 |
|
1150 |
+
return MaskedLMOutput(
|
1151 |
loss=total_loss,
|
1152 |
+
logits=prediction_scores,
|
1153 |
+
hidden_states=outputs.hidden_states,
|
1154 |
+
attentions=None,
|
1155 |
)
|
1156 |
|
1157 |
|