ollama - 💡(How to fix) Fix Gemma4:31b Structured Output inconsistent with Reasoning / Thinking [3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#15386Fetched 2026-04-08 03:01:19
View on GitHub
Comments
3
Participants
2
Timeline
4
Reactions
0
Timeline (top)
commented ×3labeled ×1
RAW_BUFFERClick to expand / collapse

What is the issue?

ISSUE: model makes a decision in reasoning that is not reflected in final JSON output.

Happens on edge cases in my system. Never noticed this when running models like gpt-oss:120b. I don't know if this is a problem with Ollama or the model itself.

I am running gemma4:31b to make a decision in an automated ticketing system. The decisions are 'SEND' and 'SKIP'. I enforce the values with:

class Decision(BaseModel): decision: Literal['SEND', 'SKIP']

As described in docs I use the format= to pass this structure to the model. I have not passed the think= to the chat function.

REASONING EXAMPLE (only the ending):

Conclusion: All criteria for SEND are met.

Self-Correction/Double Check: Is there any ambiguity?

  • Ticket: "Ne pridem do dokumentov" (I can't get to the documents).

  • Problem: "Uporabnik nima ustreznega dostopa (read / modify)".

  • Solution: Use FIM to add yourself to the group.

  • Problem Details: K:\ is covered.

  • Everything aligns.

    Final Decision: SEND.

OUTPUT:

Decision(decision='SKIP')

Any info on this inconsistency would be very helpful!

Relevant log output

OS

Windows

GPU

Nvidia

CPU

Intel

Ollama version

0.20.2

extent analysis

TL;DR

The issue may be resolved by passing the think= parameter to the chat function to ensure the model's reasoning is reflected in the final JSON output.

Guidance

  • Review the documentation for the chat function to understand the purpose of the think= parameter and how it affects the model's output.
  • Verify that the format= parameter is correctly passing the Decision structure to the model.
  • Check the model's configuration and version to ensure it is compatible with the gemma4:31b model and the Ollama version 0.20.2.
  • Test the model with different inputs and edge cases to see if the inconsistency is specific to certain scenarios.

Example

No code snippet is provided as the issue does not contain sufficient information to create a specific example.

Notes

The issue may be related to the model's internal decision-making process or the way the Ollama library handles the model's output. Further investigation is needed to determine the root cause of the inconsistency.

Recommendation

Apply a workaround by passing the think= parameter to the chat function to see if it resolves the issue, as the documentation suggests it may affect the model's output.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

ollama - 💡(How to fix) Fix Gemma4:31b Structured Output inconsistent with Reasoning / Thinking [3 comments, 2 participants]