In today's artificial intelligence ecosystem, large-scale language models (LLMs) have become the engine of countless bespoke applications, from conversational assistants to code generators to data mining systems. However, behind the apparent effectiveness of these models lie technical details that can compromise their reliability, especially when used in business environments that demand structured and predictable outputs. A paradigmatic case is that of repetition penalties – a common mechanism to encourage diversity in responses – which, implemented incorrectly, can introduce a silent corruption in the results.
The multiplicative repetition penalty, widely distributed in frameworks such as HuggingFace, vLLM or llama.cpp, operates on logits (values prior to the softmax function) by classifying them according to their sign: positive ones are divided by a theta factor, while negative ones are multiplied by that same factor. At first glance, this logic seems reasonable: penalizing tokens that have already appeared by reducing their probability. However, the softmax function is invariant to constant shifts of all logits, which means that the zero point of a model—the threshold that separates the 'positive' from the 'negative'—is arbitrary and not linked to any semantic property of the language. As a consequence, the penalty per sign depends on a value that the training does not set, generating inconsistent results between different models and, even worse, distorting the quality of the outputs.
This inconsistency has two measurable and troubling effects. First, the penalty is not well defined: if you re-center the logits of a model by adding a constant to them – an operation that does not alter the probabilities when theta=1 – when applying a typical factor of 1.3, changes are observed in between 58% and 96% of the tokens generated in greedy mode, while alternative methods based on normalized probabilities do not produce any variation. Different pre-trained models have very different zero points, so the same repetition_penalty becomes a different operation in each one. Second, and more critical for enterprise applications, this mechanism corrupts structured outputs: in tests with 200 real JSON schemas, a factor of 1.3 reduces the rate of valid outputs (schema-compliant) from 97% to 23%. For a company that integrates LLMs into the automatic generation of documents, configurations, or API responses, this drop is unacceptable.
The root of the problem is technical: the softmax transforms logits into probabilities by adding a constant to all logits does not alter the final probabilities, but the sign penalty introduces a dependence on the position of that zero. The solution, which already exists in HuggingFace under the LogitNormalization operator (although disabled by default and applied after the penalty), is to apply the penalty on the normalized log-probabilities instead of on the raw logits. In this way, the correction becomes consistent and respects the fundamental invariance of the model.
For companies developing custom software with artificial intelligence, this finding underscores the need to carefully audit the LLM components they integrate into their flows. It is not enough to adopt a popular model: the concrete implementation of techniques such as repetition penalization can make the difference between a reliable output and a systematically corrupt one. In environments where the generation of code, structured documents or responses for cybersecurity systems is critical, this type of bug can have serious consequences, from failures in AWS and Azure cloud services to vulnerabilities in automated processes.
At Q2BSTUDIO, as a software and technology development company, we understand that technical excellence is not limited to choosing the latest tools, but to implementing them rigorously. Our AI services for enterprises include integrating LLMs with best practices, such as penalty normalization and structured exit validation. In addition, we offer AI agents that incorporate these correction mechanisms to ensure consistent results. If your organization needs bespoke applications that leverage LLMs securely and predictably, our cross-platform development expertise can help you build robust solutions.
Monitoring and correcting these effects is also an area where the combination of artificial intelligence and business intelligence services is particularly valuable. Using dashboards in Power BI that analyze the rate of valid outputs or the deviation between models, technical teams can detect deviations in time. We also offer AI services for companies that include customization and fine-tuning of models with corrected penalties, avoiding the problems described.
In conclusion, the world of machine learning is full of small details that, ignored, can undermine trust in systems that should be predictable. The repetition penalty per sign is a clear example of how a seemingly innocent implementation can introduce a source of systematic error. For companies building on these technologies, understanding these subtleties is not a luxury, but a necessity. Adopting practices such as logit standardization, schema validation, and continuous auditing of AI components is what differentiates a successful project from one that generates unpleasant surprises. At Q2BSTUDIO, we help our clients navigate this complex ecosystem, offering solutions ranging from custom software development to cloud integration, always with a focus on quality and reliability.





