Hi everyone,
We’re building a healthcare application that uses MedGemma to extract structured information from medical documents into JSON. We self-host the model and have run into two problems with long structured outputs that we haven’t been able to solve. If anyone has faced something similar or found a resolution, we’d be very grateful if you could share it.
Question 1: Runaway whitespace under guided JSON decoding
We serve google/medgemma-1.5-4b-it with vLLM 0.30.0 (bf16, --max-model-len 131072, temperature 0, fixed seed, max_new_tokens 8192) and use vLLM’s response_format: json_schema (guided decoding) so the model returns JSON matching our schema. When a value is not present in the input, our instructions tell the model to write a fixed placeholder string, and most of the time it does. But on a noticeable share of requests, the model stops producing content partway through the JSON and emits only whitespace (spaces and newlines) until it hits the token limit. The response ends with finish_reason="length", the JSON is incomplete and can’t be parsed, and in one batch eight responses together used about 83,000 output tokens, far more than a normal answer. Because we run at temperature 0 with a fixed seed, retrying gives exactly the same result. We tried disabling “any whitespace” in the structured-output backend, but the problem continued. Has anyone seen MedGemma do this under guided decoding? Is there a recommended vLLM structured-output backend or setting for MedGemma, or a schema or prompt pattern (for example, avoiding optional or deeply nested fields) that stops the model from padding instead of writing the placeholder or closing the JSON?
Question 2: Output length limit for large structured answers
Some of our schemas are fairly large, and a complete, correct answer needs an estimated 3,500–5,500 output tokens. Our server default is 8,192 new tokens, and we’re unsure whether MedGemma 1.5 4B handles long structured outputs reliably at that length. Was the model tuned mainly on shorter outputs? Is there a practical or recommended maximum output length, beyond which quality drops or runaway generation becomes more likely? We also see that very large JSON schemas, once compiled into a decoding grammar, seem to make the model less reliable than larger general-purpose models on the same schema. Would you recommend splitting one large schema into several smaller requests, or is there a known limit on schema size or complexity for MedGemma with guided decoding? Any guidance on output limits and schema design for long structured extractions would help a lot.
Happy to share more technical details (vLLM launch flags or a sample of the truncated output) if that would help. Thanks in advance for any pointers!