Compare commits
1 Commits
788505311a
...
e091e6c13d
| Author | SHA1 | Date |
|---|---|---|
|
|
e091e6c13d |
|
|
@ -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
|
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
|
logits = outputs.logits[:, -1, :] / temperature
|
||||||
if repetition_penalty != 1.0:
|
if repetition_penalty != 1.0:
|
||||||
for i in range(input_ids.shape[0]):
|
for i in range(input_ids.shape[0]): logits[i, torch.unique(input_ids[i])] /= repetition_penalty
|
||||||
seen = torch.unique(input_ids[i]); score = logits[i, seen]; logits[i, seen] = torch.where(score > 0, score / repetition_penalty, score * repetition_penalty)
|
|
||||||
if top_k > 0:
|
if top_k > 0:
|
||||||
logits[logits < torch.topk(logits, top_k)[0][..., -1, None]] = -float('inf')
|
logits[logits < torch.topk(logits, top_k)[0][..., -1, None]] = -float('inf')
|
||||||
if top_p < 1.0:
|
if top_p < 1.0:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue