diff --git a/detector_benchmark/watermark/unbiased/unbiased.py b/detector_benchmark/watermark/unbiased/unbiased.py index ed7918d..af32129 100644 --- a/detector_benchmark/watermark/unbiased/unbiased.py +++ b/detector_benchmark/watermark/unbiased/unbiased.py @@ -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