Skip to content

Commit

Permalink
Fixed nll with label_smoothing to nll
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshkokane01 committed Jan 25, 2024
1 parent 4cbd876 commit b22eaf9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/transformers/models/blip/modeling_blip_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ def forward(
# we are doing next-token prediction; shift prediction scores and input ids by one
shifted_prediction_scores = prediction_scores[:, :-1, :].contiguous()
labels = labels[:, 1:].contiguous().to(shifted_prediction_scores.device)
loss_fct = CrossEntropyLoss(reduction=reduction, label_smoothing=0.1)
loss_fct = CrossEntropyLoss(reduction=reduction, label_smoothing=0.0)
lm_loss = loss_fct(shifted_prediction_scores.view(-1, self.config.vocab_size), labels.view(-1))
if reduction == "none":
lm_loss = lm_loss.view(prediction_scores.size(0), -1).sum(1)
Expand Down

0 comments on commit b22eaf9

Please sign in to comment.