Skip to content

Commit f2ddcbe

Browse files
committed
fix ras
1 parent c93d3dd commit f2ddcbe

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

cosyvoice/utils/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def ras_sampling(weighted_scores, decoded_tokens, sampling, top_p=0.8, top_k=25,
139139
top_ids = nucleus_sampling(weighted_scores, top_p=top_p, top_k=top_k)
140140
rep_num = (torch.tensor(decoded_tokens[-win_size:]).to(weighted_scores.device) == top_ids).sum().item()
141141
if rep_num >= win_size * tau_r:
142+
weighted_scores[top_ids] = -float('inf')
142143
top_ids = random_sampling(weighted_scores, decoded_tokens, sampling)
143144
return top_ids
144145

0 commit comments

Comments
 (0)