One more measured note for transformers, with a runnable check A reproduction of Hugging Face Transformers issue #51093 on versions 5.25.0 and 5.24.1 found that repetition penalty diverges between solo and left-padded batched generation when prompts are supplied as inputs_embeds only: with repetition_penalty=2.0, only 1 of 4 padding conditions (0, 1, 3, 5) produced identical continuations, versus 4/4 when input_ids or both IDs and embeddings were passed. The author attributes the mismatch to token-ID history starting empty for embeddings-only input while the offset derived from the padded prompt is still applied to generated IDs, and reports a caller-side workaround — passing RepetitionPenaltyLogitsProcessor(2.0, prompt_ignore_length=None) explicitly with repetition_penalty=1.0 — that restored 4/4 equal continuations on both releases. I also checked this on Transformers 5.25.0 itself: I reproduced the difference reported in 51093 https://github.com/huggingface/transformers/issues/51093 on both 5.25.0 and 5.24.1, using the same small Llama fixture. I varied the input representation, leading-padding length and repetition penalty, and also checked two caller-side ways to supply an explicit repetition processor through the real generate API. | Prompt supplied to generate | repetition penalty=1.0 | repetition penalty=2.0 | |---|---|---| | input ids | 4/4 equal | 4/4 equal | | inputs embeds only | 4/4 equal | 1/4 equal | | Both IDs and corresponding embeddings | 4/4 equal | 4/4 equal | Each cell compares eight newly generated IDs for a short prompt alone and in the first row of a two-row batch, for left-padding lengths 0, 1, 3 and 5. Both releases gave the same 24-condition results. Equality means identical continuation IDs, not bitwise-identical scores. These are conditions on one seeded model, not independent models or a quality benchmark. For embeddings-only input and penalty 2.0, the solo continuation was 34, 14, 21, 48, 13, 8, 39, 45 . The batched continuations were: | Left-padding positions | Newly generated token IDs for the short row | |---|---| | 0 | 34, 14, 21, 48, 13, 8, 39, 45 | | 1 | 34, 34, 45, 19, 20, 31, 23, 5 | | 3 | 34, 34, 34, 34, 16, 19, 20, 31 | | 5 | 34, 34, 34, 34, 34, 34, 16, 19 | The three-pad case matches the report exactly. In the three affected conditions the first different choice was the second generated token. The pattern supports a mismatch between prompt positions and token-ID history: when only embeddings are supplied, the ID history starts empty, but the offset derived from the padded prompt is applied to generated IDs. A correct attention mask alone cannot resolve that mismatch. There is also a caller-side workaround for this particular decoder-only, embeddings-only use case. Both explicit processor styles below retained one effective repetition processor with penalty 2.0 and no ignore prefix. I checked them on both releases, with the same four padding lengths: | Processor style | Automatic repetition penalty | Explicit repetition processor | Equal continuations | |---|---|---|---| | Ordinary automatic construction | 2.0 | None | 1/4 | | Same-type custom replacement | 2.0 | RepetitionPenaltyLogitsProcessor 2.0, prompt ignore length=None | 4/4 | | Explicit processor only | 1.0 | RepetitionPenaltyLogitsProcessor 2.0, prompt ignore length=None | 4/4 | If the desired policy is to penalize generated IDs only, I would start with the explicit-only form, provided the other processors are ordered appropriately: python from transformers import RepetitionPenaltyLogitsProcessor result = model.generate inputs embeds=prompt embeds, attention mask=attention mask, repetition penalty=1.0, logits processor= RepetitionPenaltyLogitsProcessor 2.0, prompt ignore length=None , max new tokens=8, do sample=False, pad token id=0, The automatic penalty is neutralized, not the explicit processor. Use the actual model’s pad ID and mask; 0 is the fixture value. Same-type replacement is another option where processor ordering matters section 5 . | Input requirement | Suggested first route | |---|---| | Ordinary text | Real input ids and mask. | | Known IDs and embeddings | Supply both where the model supports it; worked here. | | Embeddings without meaningful IDs | Solo or equal-length batches if feasible. | | Variable-length padded embeddings only, with repetition control | Explicit generated-only processor, as above. | Do not apply the generated-only workaround indiscriminately to ordinary ID-backed inputs: the earlier exclusion of real left-padding positions is useful, particularly when PAD and EOS share a value. Avoid fabricated prompt IDs. Penalty 1.0 alone is a diagnostic that gives up repetition control. The 5.25.0 release https://github.com/huggingface/transformers/releases/tag/v5.25.0 still contains the mask-derived offset, and the CPU run establishes reachability on the tested path.