Make loss calculation possible during eval mode

#7
by tanaymehta - opened
Files changed (1) hide show
  1. modeling_pharia.py +1 -1
modeling_pharia.py CHANGED
@@ -771,7 +771,7 @@ class PhariaForCausalLM(PhariaPreTrainedModel):
771
  "You have to specify the `labels` tensor when training the model."
772
  )
773
 
774
- if self.training and labels is not None:
775
  # Shift logits and labels for causal language modeling
776
  shift_logits = logits[..., :-1, :].contiguous()
777
  shift_labels = labels[..., 1:].contiguous()
 
771
  "You have to specify the `labels` tensor when training the model."
772
  )
773
 
774
+ if labels is not None:
775
  # Shift logits and labels for causal language modeling
776
  shift_logits = logits[..., :-1, :].contiguous()
777
  shift_labels = labels[..., 1:].contiguous()