From 0481ac30c6166cc31735dd7d547ccd2adcfa345b Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Wed, 27 May 2026 15:33:48 +0400 Subject: [PATCH] Studio: disable thinking for RAG captioner requests Reasoning models (gemma-4, qwen3-thinking) burn the entire max_tokens budget on output and return empty visible content, so the captioner produced zero captions for every image. Pass chat_template_kwargs={enable_thinking: false} per-request to skip the reasoning phase, and bump max_tokens 120 -> 200 as headroom. --- studio/backend/core/rag/captioner.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/studio/backend/core/rag/captioner.py b/studio/backend/core/rag/captioner.py index 23e3b78e33..94ba4be324 100644 --- a/studio/backend/core/rag/captioner.py +++ b/studio/backend/core/rag/captioner.py @@ -37,7 +37,7 @@ _PROMPT = ( "(axes, labels, captions, visible text, main objects). " "Do not speculate beyond what is visible." ) -_MAX_NEW_TOKENS = 120 +_MAX_NEW_TOKENS = 200 # Downscale large images so the base64 payload stays manageable; the chat # model's prefill cost scales with image-tile count, not pixel count, but # very large inputs still bloat the JSON body. 1600 px on the long side @@ -122,6 +122,11 @@ def _post_one(client: Any, endpoint: str, model: str, blob: bytes) -> str: ], "max_tokens": _MAX_NEW_TOKENS, "temperature": 0.0, + # Reasoning models (gemma-4, qwen3-thinking, etc.) burn the whole + # token budget on output and emit empty visible content + # — useless for a short image caption. Disable thinking for this + # request only; the user's chat sessions stay unaffected. + "chat_template_kwargs": {"enable_thinking": False}, } response = client.post(endpoint, json = payload) response.raise_for_status()