Skip to content

Commit

Permalink
Fix sequence generator test. (#3546)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinxzhao authored Aug 25, 2023
1 parent e5513c3 commit 2ab5b59
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ludwig/features/text_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,12 @@ def update_metrics(
decoded_targets, decoded_predictions = get_decoded_targets_and_predictions(targets, predictions, tokenizer)
for metric_name, metric_fn in self._metric_functions.items():
prediction_key = get_metric_tensor_input(metric_name)
if prediction_key == RESPONSE and tokenizer is not None:
# RESPONSE metrics cannot be computed if decoded texts are not provided.
# Decoded texts are only provided using the LLM model type.
if decoded_targets is not None and decoded_predictions is not None:
metric_fn.update(decoded_predictions, decoded_targets)
if prediction_key == RESPONSE:
if tokenizer is not None:
# RESPONSE metrics cannot be computed if decoded texts are not provided.
# Decoded texts are only provided using the LLM model type.
if decoded_targets is not None and decoded_predictions is not None:
metric_fn.update(decoded_predictions, decoded_targets)
else:
metric_fn = metric_fn.to(predictions[prediction_key].device)
metric_fn.update(predictions[prediction_key].detach(), targets)
Expand Down

0 comments on commit 2ab5b59

Please sign in to comment.