Skip to content

Commit

Permalink
potential fix in unbiased watermarking
Browse files Browse the repository at this point in the history
  • Loading branch information
marluxiaboss committed Oct 30, 2024
1 parent e60094f commit db053e1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion detector_benchmark/watermark/unbiased/unbiased.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ def _get_score(self, input_ids: torch.LongTensor, vocab_size):
pre = input_ids[: i + 1]
cur = input_ids[i + 1]
token_quantile = self._get_green_token_quantile(pre, vocab_size, cur)
scores[i] = torch.stack(token_quantile).reshape(-1)

if isinstance(token_quantile, list) and len(token_quantile) > 0:
scores[i] = torch.stack(token_quantile).reshape(-1)
else:
scores[i] = 0.0 # Default value to prevent errors

return scores

Expand Down

0 comments on commit db053e1

Please sign in to comment.