published fresh until

Ollama: why does Gemma 3 extraction return empty JSON?

Summary As of November 2026, validate the response against your extraction schema first, then compare a short prompt and another resume. Get the reported empty JSON case, an independent contrary result, and the unsuccessful CPU-only attempt (sources re-fetched 2026-11-03).

Not for tool calls moving onto the user turn, see ollama-empty-content-array-tool-turn-merged.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

For Gemma 3 returning {}, validate the response against your extraction schema, then compare a short prompt and another resume: the reported cause remains unresolved (Ollama documentation, Sahandi78's follow-up).

Do first: immediately after your Python chat call, run Resume.model_validate_json(response.message.content); this adapts the official documentation's Country.model_validate_json example to the reporter's Resume model (Ollama maintainers, Sahandi78's schema call).

Evidence: one failing application report, an independent run that returned populated JSON, and official schema guidance; neither report establishes a general Gemma 3 defect (Sahandi78, rick-github).

Not for: tool calls moving onto the user turn; see ollama-empty-content-array-tool-turn-merged.

Diagnostic: empty JSON object ({})

Sahandi78's October 31 report in ollama/ollama #19427 says “Gemma3 returns: {}”. The call completes with done=True and done_reason='stop', without an exception; its pasted response has eval_count=2. This is an empty extraction result, rather than a reported JSON parsing exception.

Compare the inputs

1. Keep the reporter's schema setting, format=Resume.model_json_schema(), and options={"temperature": 0}. Repeat the extraction with a short prompt using the same schema. Sahandi78 reports populated JSON for that control but {} for the original resume task (original report). 2. Repeat with another resume while keeping the model and prompt unchanged. In the November 1 follow-up, Sahandi78 reports complete outputs for two other PDFs. This comparison is a diagnostic control, not a remedy for the failing PDF (follow-up). 3. Follow the official schema recipe: pass the schema through format, validate the returned content, and consider including the schema as a string in the prompt. The Ollama maintainers say “then validate the response”; their examples use Pydantic validation. These are documented usage steps, not a documented cure for this report (structured-output guidance).

Findings and fix status

  • Reported environment: Windows, with no exact Windows version; Ollama 0.40.5, Python 3.10.5, Ollama Python library 0.6.3, gemma3:4b, NVIDIA GeForce GTX 1050 with 4 GB VRAM, and driver 582.78. The reporter describes approximately 52% CPU and 48% GPU allocation. These identify one affected setup, not an affected-version range (Sahandi78).
  • Cause remains a hypothesis: the original report suspects longer prompts combined with structured output. The later follow-up narrows that suspicion to specific extracted text interacting with the prompt, because other resumes produced complete JSON. Sahandi78 explicitly says the exact cause is unidentified (report, follow-up).
  • Independent result: on November 1, rick-github says a run of the repository “generated a full JSON result”. That comment does not specify a matching machine or software version, so it is contrary evidence rather than a matched-environment reproduction (rick-github, ollama/ollama).
  • CPU-only attempt: rick-github initially considered context size but said the logs showed no buffer shift or truncation, then suggested num_gpu: 0. Sahandi78 subsequently reported no difference with that option. The exchange does not establish CPU-only mode as a workaround (suggestion, outcome).
  • Model comparison: Sahandi78 reports that qwen2.5:3b produced the expected extraction with the same code, prompt and schema. This is a reported alternative for that application, not a general model ranking (original report).
  • Release status: the issue is closed by the reporter, following the content-dependent observations. The closing comment identifies neither a repair PR or commit nor a release containing a remedy; closure does not establish a released fix (issue state, closing explanation).

Limits

One application reports the failing extraction; the independent run returned populated JSON without a matching environment description. The sources do not establish a first affected version, a PDF parsing cause, or a remedy for the original document. The shorter-prompt and other-document comparisons help isolate the symptom; they do not recover the missing fields from that document (report, independent run, follow-up).

Sources re-fetched 2026-11-03.

Started from a post by @Sahandi78, packaged by the editor. Original post

Subjects

More in local models

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Ollama: why does Gemma 3 extraction return empty JSON?
Summary: As of November 2026, validate the response against your extraction schema first, then compare a short prompt and another resume. Get the reported empty JSON case, an independent contrary result, and the unsuccessful CPU-only attempt (sources re-fetched 2026-11-03).
Copy for agent
get the whatworks thread ollama-gemma-structured-extraction-empty-json and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread ollama-gemma-structured-extraction-empty-json
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks