fix: strip Qwen3-ASR output prefix from transcriptions - #8773
Conversation
Qwen3-ASR (via vLLM/sglang OpenAI-compatible endpoint) returns transcriptions in the format: "language English<asr_text>Hello. This is the actual text." The "language <LANG><asr_text>" prefix was being passed verbatim to the LLM as the user's voice message, adding noise and potentially confusing the model on short utterances. Fix: strip everything up to and including the <asr_text> marker in _extract_transcript_text(). The marker is specific enough that false positives are impossible (no natural speech produces angle brackets). The guard `if "<asr_text>" in text` makes this a no-op for non-Qwen providers (Whisper, Groq, etc.). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
teknium1
left a comment
There was a problem hiding this comment.
Thanks for identifying the Qwen3-ASR response shape. The premise remains valid on current main: tools/transcription_tools.py:1787 returns string responses unchanged except for whitespace, and the OpenAI-compatible path calls this helper at tools/transcription_tools.py:1360.
Problems
- The diff's right-side
tools/transcription_tools.py:105replaces provider-aware model resolution with a raw flatstt.modellookup. This is unrelated to prefix stripping and drops documented behavior from the PR base; it should not be part of the salvage. - The diff has no regression test. Current OpenAI transcription coverage in
tests/tools/test_managed_media_gateways.py:305-346covers ordinary text/JSON responses but not the Qwen marker.
Suggested changes
- Apply only the marker normalization to current main's
_extract_transcript_text()(tools/transcription_tools.py:1784) and preserve the current configuration architecture. - Add direct regression cases for string,
.text, and dictionarytextresponses containing<asr_text>.
Automated hermes-sweeper review.
| return legacy | ||
| from hermes_cli.config import read_raw_config | ||
| return read_raw_config().get("stt", {}).get("model") | ||
| except Exception: |
There was a problem hiding this comment.
This unrelated replacement drops the provider-aware model lookup. Please omit this hunk when salvaging the Qwen transcript normalization; the prefix fix does not require changing model-resolution behavior.
|
I refreshed this valid fix on current The replacement keeps the current provider-aware STT configuration behavior, applies Fresh validation on the replacement head: 235 related tests passed, plus Ruff, changed-range formatting, Python compilation, and diff checks. Since this branch is now reported as conflicting, centralizing the current-main review in #65534 avoids carrying the stale unrelated config diff forward. |
Normalize the structured <asr_text> marker after extracting text from string, SDK object, and dictionary transcription responses. Preserve the current provider-aware STT configuration architecture. Refreshes NousResearch#8773 on current main. Co-authored-by: angelos <angelos@oikos.lan.home.malaiwah.com> Assisted-by: Codex:gpt-5.6
Normalize the structured <asr_text> marker after extracting text from string, SDK object, and dictionary transcription responses. Preserve the current provider-aware STT configuration architecture. Refreshes #8773 on current main. Co-authored-by: angelos <angelos@oikos.lan.home.malaiwah.com> Assisted-by: Codex:gpt-5.6
Normalize the structured <asr_text> marker after extracting text from string, SDK object, and dictionary transcription responses. Preserve the current provider-aware STT configuration architecture. Refreshes NousResearch#8773 on current main. Co-authored-by: angelos <angelos@oikos.lan.home.malaiwah.com> Assisted-by: Codex:gpt-5.6
Qwen3-ASR (via vLLM/sglang OpenAI-compatible endpoint) returns transcriptions with a structured prefix:
This prefix was passed verbatim to the LLM as the user's voice message. On short utterances it could confuse the model.
Fix: strip everything up to and including
<asr_text>in_extract_transcript_text(). The marker is XML-like and cannot appear in natural speech, so false positives are impossible. Theif '<asr_text>' in textguard makes this a no-op for non-Qwen providers (Whisper, Groq, etc.).