Compare commits

..

1 Commits

Author SHA1 Message Date
orbisai0security e091e6c13d
Merge 8607169546 into 802c15b2b4 2026-05-06 16:39:54 +05:30
1 changed files with 1 additions and 2 deletions

View File

@ -266,8 +266,7 @@ class MiniMindForCausalLM(PreTrainedModel, GenerationMixin):
attention_mask = torch.cat([attention_mask, attention_mask.new_ones(attention_mask.shape[0], 1)], -1) if attention_mask is not None else None
logits = outputs.logits[:, -1, :] / temperature
if repetition_penalty != 1.0:
for i in range(input_ids.shape[0]):
seen = torch.unique(input_ids[i]); score = logits[i, seen]; logits[i, seen] = torch.where(score > 0, score / repetition_penalty, score * repetition_penalty)
for i in range(input_ids.shape[0]): logits[i, torch.unique(input_ids[i])] /= repetition_penalty
if top_k > 0:
logits[logits < torch.topk(logits, top_k)[0][..., -1, None]] = -float('inf')
if top_p < 1.0: