Skip to content

Conversation

@Ceaser1717
Copy link

Summary

This PR fixes the infinite generation loop issue that occurred when the model
encountered repeating checksum-like patterns such as “A5A5A5A5...”.

Changes Made

  • Added import re for regex-based pattern detection.
  • Added repetition checks inside the generate() function:
    • Detects excessive "A5" repetition using (A5){10,} regex.
    • Detects same token repeating 10 or more times continuously.
  • Prints a warning and safely breaks the loop to prevent runaway generation.

Result

  • Stops infinite “A5A5A5...” loops.
  • Improves text generation stability and safety.
  • Verified on prompt containing checksum-like strings.

Fixes: #1008

…ion (Issue deepseek-ai#1008)

Added a simple repetition detection inside the generate() loop to stop the model 
from endlessly producing patterns like “A5A5A5...”. 

- Imported `re` for regex pattern matching.
- Stops generation if “A5” repeats 10+ times or the same token appears 10 times.
- Prints a warning and exits safely instead of looping infinitely.

Fixes: deepseek-ai#1008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Model enters infinite loop when processing a specific SHA512 checksum pattern in a prompt.

1 participant