Skip to content

Add an opt-in repetition guard for Nemotron Transcribe - #1198

Merged
0xShug0 merged 1 commit into
mainfrom
feature/nemotron-transcribe-repetition-guard
Nov 4, 2026
Merged

0xShug0 merged 1 commit into
mainfrom
feature/nemotron-transcribe-repetition-guard

Conversation

@0xShug0

@0xShug0 0xShug0 commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Nemotron Transcribe can repeat generated text until its output cap without producing EOS. Add an opt-in repetition_guard request option, default false, using NVIDIA NeMo-Speech.cpp's LoopGuard detection rules.

The guard detects short periodic token loops and sustained replay of previously emitted token sequences. It retains the generated prefix, including the newest token, and reports termination: "repetition_detected" rather than claiming EOS. State is local to each generation; logits and sampling are unchanged. Disabled requests do not construct or update detector state.

Enable with --request-option repetition_guard=true, or "options": {"repetition_guard": true} in a server request. It limits wasted generation; it does not repair wrong-language output or recover missing speech. Genuine repeated speech can trigger it, and some repetition does not meet its thresholds, so it remains opt-in.

The implementation is adapted from NVIDIA/NeMo-Speech.cpp at 536b17a41bef62d2a67a40ed3df61df26a4389fe, retaining its attribution. No script/language mask is imported. Changes are limited to this model's decoder, request contract, documentation and tests, plus its source registration.

Validation

Debug CUDA inference on RTX 5090 with native Q4_K_S experts and the F16 encoder, greedy decoding and a 768-token output cap:

Three-minute Mandarin case Guard off Guard on
Uninterrupted narration after a longer request primes context capacity 768 tokens, token limit 565 tokens, repetition detected
Repeated-audio stress fixture 768 tokens, token limit 712 tokens, repetition detected

Guarded text was an exact prefix of unguarded text. Disabling the guard afterward restored the original full output exactly. The uninterrupted fixture also ended normally in a smaller-capacity sequence, so the priming sequence is part of that reproducer; this does not claim all fresh three-minute requests loop.

  • Five non-looping controls retained identical text and token counts with the guard on/off.
  • Six default transcripts matched pre-change main byte-for-byte.
  • Invalid option values returned HTTP 400; the CLI option also completed a normal request.
  • Focused tests cover all 32 periodic boundaries, upstream replay thresholds, genuine threefold phrase repetition, reset behavior, and an actual small CPU decoder's stopping/callback behavior, EOS priority, cancellation and token limits.
  • Detector methods match upstream after class/namespace/token-type substitutions. Model-spec validation, Debug builds and whitespace checks pass.

Related: #1180. This addresses runaway repetition handling, not the broader language/prompt investigation.

@0xShug0
0xShug0 merged commit 039ed34 into main Nov 4, 2026
7 checks passed
@0xShug0
0xShug0 deleted the feature/nemotron-transcribe-repetition-guard branch November 4, 2026 15:10
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.

1 participant