[GH-ISSUE #15540] structured output not enfocred on qwen 3.5 / gemma 4 #87617

Closed
opened 2026-05-10 06:08:27 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @Xnyle on GitHub (Apr 13, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/15540

What is the issue?

Using ollama/ollama:0.20.3 and the request (stripped) below to the OpenAI compatible endpoint Ollama returns deltas that in sum do not obey the given schema for at least Gemma 4 26b and Qwen 3 9b.

Sometimes I get Json in markdown but thats it.

Working fine with Gemma3 / GPT OSS

Is this expected / a bug / error in request?

{
  "model": "qwen3.5:9b",
  "messages": [
    {
      "id": "ec197bbb-5f8b-4199-a051-c5e01aaadddd",
      "created_at": -2038034357,
      "completed_at": -2038034356,
      "role": "system",
      "content": "Instructions explaining schema and role... ",
      "metadata": {}
    },
    {
      "id": "491b00b9-27c4-444b-a59f-ead4b02190c1",
      "created_at": -2038034351,
      "completed_at": -2038034254,
      "role": "user",
      "content": "Hi ...",
      "metadata": {}
    }
  ],
  "logprobs": false,
  "temperature": 0.7,
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "result",
      "schema": {
        "$schema": "http://json-schema.org/draft-04/schema#",
        "type": "object",
        "properties": {
          "markdownAnswer": {
            "type": "string"
          },
          "references": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/references"
            },
            "minItems": 1
          }
        },
        "required": [
          "markdownAnswer",
          "references"
        ],
        "$defs": {
          "references": {
            "type": "object",
            "properties": {
              "originIdentifier": {
                "type": "string",
                "pattern": "^[0-9]{1,4}-[0-9]{1,2}$"
              },
              "originMediaType": {
                "type": "string"
              }
            },
            "required": [
              "originIdentifier",
              "originMediaType"
            ]
          }
        }
      }
    }
  },
  "stream": true,
  "reasoning": {
    "effort": "none"
  },
  "stream_options": {
    "include_usage": true
  },
  "reasoning_effort": "none"
}

Relevant log output


OS

Docker

GPU

Nvidia

CPU

Intel

Ollama version

0.20.3

Originally created by @Xnyle on GitHub (Apr 13, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/15540 ### What is the issue? Using ollama/ollama:0.20.3 and the request (stripped) below to the OpenAI compatible endpoint Ollama returns deltas that in sum do not obey the given schema for at least Gemma 4 26b and Qwen 3 9b. Sometimes I get Json in markdown but thats it. Working fine with Gemma3 / GPT OSS Is this expected / a bug / error in request? ``` { "model": "qwen3.5:9b", "messages": [ { "id": "ec197bbb-5f8b-4199-a051-c5e01aaadddd", "created_at": -2038034357, "completed_at": -2038034356, "role": "system", "content": "Instructions explaining schema and role... ", "metadata": {} }, { "id": "491b00b9-27c4-444b-a59f-ead4b02190c1", "created_at": -2038034351, "completed_at": -2038034254, "role": "user", "content": "Hi ...", "metadata": {} } ], "logprobs": false, "temperature": 0.7, "response_format": { "type": "json_schema", "json_schema": { "name": "result", "schema": { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "markdownAnswer": { "type": "string" }, "references": { "type": "array", "items": { "$ref": "#/$defs/references" }, "minItems": 1 } }, "required": [ "markdownAnswer", "references" ], "$defs": { "references": { "type": "object", "properties": { "originIdentifier": { "type": "string", "pattern": "^[0-9]{1,4}-[0-9]{1,2}$" }, "originMediaType": { "type": "string" } }, "required": [ "originIdentifier", "originMediaType" ] } } } } }, "stream": true, "reasoning": { "effort": "none" }, "stream_options": { "include_usage": true }, "reasoning_effort": "none" } ``` ### Relevant log output ```shell ``` ### OS Docker ### GPU Nvidia ### CPU Intel ### Ollama version 0.20.3
GiteaMirror added the bug label 2026-05-10 06:08:27 -05:00
Author
Owner

@ArthurusDent commented on GitHub (Apr 13, 2026):

You are not using the most recent version of Ollama. Could you please re-test?

<!-- gh-comment-id:4237047938 --> @ArthurusDent commented on GitHub (Apr 13, 2026): You are not using the most recent version of Ollama. Could you please re-test?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#87617