cd /news/large-language-models/one-more-measured-note-for-transform… · home › topics › large-language-models › article
[ARTICLE · art-179888] src=discuss.huggingface.co ↗ pub= topic=large-language-models verified=true sentiment=· neutral

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.

recommendation

When generating from inputs_embeds with repetition control, pass RepetitionPenaltyLogitsProcessor(2.0, prompt_ignore_length=None) explicitly and set repetition_penalty=1.0; the source measured 4/4 equal continuations versus 1/4 with automatic construction.

more in playbook: Inference and self-hosting
read3 min views14 publishedDec 2, 2026

I also checked this on Transformers 5.25.0 itself:

I reproduced the difference reported in #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:

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 still contains the mask-derived offset, and the CPU run establishes reachability on the tested path.

── more in #large-language-models 4 stories · sorted by recency
── more on @hugging face 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/one-more-measured-no…] indexed:0 read:3min 2026-12-02 · —