(weighted_scores, decoded_tokens, top_k=25)
| 145 | # Sample top-p tokens from the distribution |
| 146 | return random_sampling(selected_weighted_scores, decoded_tokens) |
| 147 | def topk_sampling(weighted_scores, decoded_tokens, top_k=25): |
| 148 | zeros = weighted_scores.new_ones(weighted_scores.shape) * float('-inf') |
| 149 | values,indices = torch.topk(weighted_scores,top_k) |
| 150 | zeros.scatter_(-1, indices, values) |
| 151 | return random_sampling(zeros,decoded_tokens) |
| 152 | |
| 153 | # Repetition Aware Sampling in VALL-E 2 |
| 154 |
nothing calls this directly
no test coverage detected