Repetition Penalty Flaw Corrupts LLM Structured Output

Peter Hollows· July 14, 2026 View original

Summary

The widely used sign-branched repetition penalty in LLM inference engines is flawed because it depends on an arbitrary logit zero-point, leading to inconsistent behavior across models and corrupting structured output. Applying the penalty to normalized log-probabilities instead of raw logits resolves these issues.

The multiplicative repetition penalty, a common feature across various Large Language Model (LLM) inference ecosystems like HuggingFace and vLLM, contains a critical design flaw. This penalty branches its operation based on the sign of each raw logit, dividing positive logits and multiplying negative ones. However, the softmax function, which converts logits into probabilities, is invariant to adding a constant to all logits. This means a model's logit zero-point is arbitrary and unconstrained by training, yet the sign-branching penalty reads and reacts to this arbitrary point. This fundamental issue leads to two measurable consequences. Firstly, the penalty is not well-defined: re-centering a model's logits, which is a no-op at a penalty factor of 1, drastically changes 58-96% of greedy tokens at a typical factor of 1.3. Different model checkpoints have widely varying zero-points, making a fixed repetition penalty behave differently across models. Secondly, it severely corrupts structured output. On 200 real-world JSON schemas, a penalty factor of 1.3 caused the rate of valid, schema-conformant output to plummet from 97% to just 23%. The research demonstrates that applying the repetition penalty to normalized log-probabilities instead of raw logits effectively removes both of these detrimental effects. HuggingFace already provides a "LogitNormalization" operator, but it is currently off by default and applied after the flawed penalty. The study provides detailed measurements across five models, two code models, and various inference stacks, replicating the effects and confirming the efficacy of the normalized variant.

Why it matters

Professionals deploying LLMs, especially for structured data generation (e.g., JSON), must be aware of this critical flaw in common repetition penalties, as it can severely degrade output quality and reliability.

How to implement this in your domain

  1. 1Review current LLM inference configurations, specifically the application of repetition penalties.
  2. 2Prioritize using repetition penalties applied to normalized log-probabilities if available in your inference stack.
  3. 3If using HuggingFace, ensure `LogitNormalization` is enabled and applied *before* the repetition penalty.
  4. 4Conduct rigorous testing of LLM outputs, particularly for structured formats, when using repetition penalties.
  5. 5Advocate for updates in inference libraries to default to or recommend the corrected repetition penalty application.

Who benefits

AI DevelopmentSoftware EngineeringData ScienceContent GenerationFinTech

Key takeaways

  • Common LLM repetition penalties are flawed due to dependence on arbitrary logit zero-points.
  • This flaw causes inconsistent behavior across models and corrupts structured output.
  • A typical penalty factor can reduce valid JSON output from 97% to 23%.
  • Applying the penalty to normalized log-probabilities resolves these issues.

Original post by Peter Hollows

"arXiv:2607.09791v1 Announce Type: new Abstract: The multiplicative repetition penalty shipped across the LLM inference ecosystem (HuggingFace, vLLM, llama.cpp, and a dozen further engines) branches on the sign of each raw logit (divide positives by theta, multiply negatives). But…"

View on X

Originally posted by Peter Hollows on X · view source

Want to go deeper?

Turn these trends into skills with Learnijoy's hands-on AI & tech courses.

Explore courses