Commit Graph

17 Commits (367838379a92288eab0a9c9cd5a98a028c4699a5)

Author SHA1 Message Date
d 🔹 367838379a fix: repetition_penalty boosts negative-logit tokens instead of suppressing them
The generate() method divides all previously-seen token logits by
repetition_penalty uniformly. For tokens with negative logits (which
represent less-likely tokens), dividing by penalty > 1.0 moves the
logit toward zero, which *increases* the token's softmax probability.
This is the exact opposite of the intended repetition suppression.

Example with penalty=1.5:
  logit -3.0 → -3.0/1.5 = -2.0 → probability INCREASES (bug)
  logit -3.0 → -3.0*1.5 = -4.5 → probability decreases (correct)

Fix: apply the penalty conditionally based on logit sign:
  - positive logits: divide by penalty (push toward zero)
  - negative logits: multiply by penalty (push away from zero)

Both directions reduce probability for previously-seen tokens, matching
the behavior of Hugging Face Transformers' RepetitionPenaltyLogitsProcessor.

Added 14 tests covering: direction correctness for positive/negative logits,
penalty=1.0 no-op, batch independence, duplicate token handling, large
penalties, edge cases, and a regression test proving the old code boosted
negative-logit token probabilities.
2026-04-03 12:11:16 +00:00
jingyaogong 2ab6455d9d [update] open causal 2026-04-02 15:28:58 +08:00
jingyaogong 101d7df2da [update] minimind-3 2026-03-25 23:57:45 +08:00
jingyaogong c090b69c4d [update] align loss 2026-01-15 00:56:32 +08:00
jingyaogong 1279a61681 [update] prompt prefill 2026-01-13 17:46:54 +08:00
jingyaogong 9d898576ac [update] aux loss 2026-01-01 22:41:46 +08:00
jingyaogong c65335b56f [fix] experts unused 2025-12-31 21:47:04 +08:00
jingyaogong 5129f0e2a2 [fix] dtype & lr 2025-12-09 13:01:38 +08:00
jingyaogong ecd1ae1563 [fix] reduce aux_loss_alpha 2025-12-05 23:08:29 +08:00
jingyaogong 151fdf7e76 [feat] update yarn 2025-12-01 16:15:05 +08:00
jingyaogong 6b86ea399a [feat] release memory 2025-11-27 19:39:49 +08:00
jingyaogong f5374dc87f [fix] model attn_mask 2025-11-19 22:26:53 +08:00
jingyaogong a044578d73 [fix] update model 2025-11-18 13:07:20 +08:00
yuyu5333 7d02ce673c fix: attn_forwad when is_causal=True assert attn_mask is None 2025-11-18 03:17:17 +00:00
jingyaogong 4e35fb9da8 [fix] update model 2025-10-17 00:09:32 +08:00
jingyaogong 29454c31af fix bugs 2025-04-27 09:56:49 +08:00
jingyaogong a62faf34bd 250426 2025-04-26 10:05:47 +08:00