Update modeling_hf_nomic_bert.py
Browse files
modeling_hf_nomic_bert.py
CHANGED
@@ -1694,7 +1694,6 @@ class NomicBertModel(NomicBertPreTrainedModel):
|
|
1694 |
return_dict=None,
|
1695 |
matryoshka_dim=None,
|
1696 |
inputs_embeds=None,
|
1697 |
-
head_mask=None,
|
1698 |
):
|
1699 |
if input_ids is not None and inputs_embeds is not None:
|
1700 |
raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
|
@@ -1868,7 +1867,7 @@ class NomicBertForMultipleChoice(NomicBertPreTrainedModel):
|
|
1868 |
def __init__(self, config):
|
1869 |
super().__init__(config)
|
1870 |
|
1871 |
-
self.
|
1872 |
classifier_dropout = (
|
1873 |
config.classifier_dropout if config.classifier_dropout is not None else config.hidden_dropout_prob
|
1874 |
)
|
@@ -1911,7 +1910,7 @@ class NomicBertForMultipleChoice(NomicBertPreTrainedModel):
|
|
1911 |
else None
|
1912 |
)
|
1913 |
|
1914 |
-
outputs = self.
|
1915 |
input_ids,
|
1916 |
attention_mask=attention_mask,
|
1917 |
token_type_ids=token_type_ids,
|
@@ -1999,7 +1998,7 @@ class NomicBertForTokenClassification(NomicBertPreTrainedModel):
|
|
1999 |
|
2000 |
loss = None
|
2001 |
if labels is not None:
|
2002 |
-
loss_fct = CrossEntropyLoss()
|
2003 |
loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1))
|
2004 |
|
2005 |
if not return_dict:
|
@@ -2081,7 +2080,7 @@ class NomicBertForQuestionAnswering(NomicBertPreTrainedModel):
|
|
2081 |
start_positions = start_positions.clamp(0, ignored_index)
|
2082 |
end_positions = end_positions.clamp(0, ignored_index)
|
2083 |
|
2084 |
-
loss_fct = CrossEntropyLoss(ignore_index=ignored_index)
|
2085 |
start_loss = loss_fct(start_logits, start_positions)
|
2086 |
end_loss = loss_fct(end_logits, end_positions)
|
2087 |
total_loss = (start_loss + end_loss) / 2
|
|
|
1694 |
return_dict=None,
|
1695 |
matryoshka_dim=None,
|
1696 |
inputs_embeds=None,
|
|
|
1697 |
):
|
1698 |
if input_ids is not None and inputs_embeds is not None:
|
1699 |
raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
|
|
|
1867 |
def __init__(self, config):
|
1868 |
super().__init__(config)
|
1869 |
|
1870 |
+
self.new = NomicBertModel(config, add_pooling_layer=True)
|
1871 |
classifier_dropout = (
|
1872 |
config.classifier_dropout if config.classifier_dropout is not None else config.hidden_dropout_prob
|
1873 |
)
|
|
|
1910 |
else None
|
1911 |
)
|
1912 |
|
1913 |
+
outputs = self.new(
|
1914 |
input_ids,
|
1915 |
attention_mask=attention_mask,
|
1916 |
token_type_ids=token_type_ids,
|
|
|
1998 |
|
1999 |
loss = None
|
2000 |
if labels is not None:
|
2001 |
+
loss_fct = nn.CrossEntropyLoss()
|
2002 |
loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1))
|
2003 |
|
2004 |
if not return_dict:
|
|
|
2080 |
start_positions = start_positions.clamp(0, ignored_index)
|
2081 |
end_positions = end_positions.clamp(0, ignored_index)
|
2082 |
|
2083 |
+
loss_fct = nn.CrossEntropyLoss(ignore_index=ignored_index)
|
2084 |
start_loss = loss_fct(start_logits, start_positions)
|
2085 |
end_loss = loss_fct(end_logits, end_positions)
|
2086 |
total_loss = (start_loss + end_loss) / 2
|