Home / use case

Haunted Haiku: a local Gemma 3 poet that also designs the card

At a glance
Models & engines
Ollama with gemma3:4b by default (HAIKU_MODEL=gemma3:12b or any other Ollama model also works)
Key gotcha
The model sometimes returned the emoji as a list instead of a string, which printed raw brackets into the picture; the fix was to join lists.

What they built

Haunted Haiku is a one-file Python app: you type a word or mood, and Gemma 3 running in Ollama on localhost writes a spooky haiku about it. The same reply also chooses two dark colours and a few emoji, and the app draws the poem as a card with a gradient, soft bokeh lights and a faint emoji scene, which you can save as a PNG.

There is no image model: the picture is plain CSS driven by the model's choices. A stepper changes the poem from 1 to 10 lines, and the model is a one-line swap with HAIKU_MODEL.

Optional buttons read the poem aloud and add a short soundtrack using ElevenLabs, a hosted service that needs an API key and internet. The author is clear that those are the exception: the haiku and the card work fully offline.

Setup

  • Python with Dash and Dash Mantine Components for the UI, plain requests for the model call
  • Ollama with gemma3:4b by default (HAIKU_MODEL=gemma3:12b or any other Ollama model also works)
  • Runs at http://localhost:8063 with no login

How it works

  1. One POST to Ollama's /api/chat with format set to json, temperature 0.9, asks for the poem lines, 1 to 3 emoji and two colours from Mantine's palette names.
  2. Setting "format": "json" makes Ollama constrain the output to valid JSON.
  3. The app validates the reply and falls back to defaults when the model goes off-schema.

Results & numbers

  • The author's takeaway is that a small model goes a long way when asked for structure: one request makes it both the poet and the art director.
  • Most haiku come out close to 5-7-5, but not all of them.

Gotchas

  • The model sometimes returned the emoji as a list instead of a string, which printed raw brackets into the picture; the fix was to join lists.
  • It can return a colour outside the palette or the same colour twice, so both are checked with a default fallback.
  • Gemma doesn't count syllables reliably, so 5-7-5 is a hint, not a guarantee.
  • The optional music button failed because the ElevenLabs key lacked the music permission; the app had wrongly guessed a paid-plan error, and the author would now show the API's own message.
“The unpleasant surprise was how often a small model almost follows a schema. Validating its output is not optional.”— E. Smith

Do it yourself

  1. Pull the model: ollama pull gemma3:4b.
  2. Clone the banana0000/haiku repository from GitHub and install requirements with pip install -r requirements.txt.
  3. Skip the .env file if you want to stay fully offline; the voice and music buttons are optional.
  4. Run python app.py and open http://localhost:8063.
  5. Type a word, press Summon a haiku, and save the card as a PNG.
  6. To reuse the idea, send your own prompt with format json and validate every field before using it.
git clone https://github.com/banana0000/haiku
cd haiku
ollama pull gemma3:4b
pip install -r requirements.txt
python app.py
Source: E. Smith (DEV Community) · Published 2026-10-28 · Added 2026-10-30. This write-up summarizes the original source; see it for full details.

Similar setups

PatchPal TinyAgent: a coding agent on a 4B model and a 6GB laptop GPU

WiseProbe adapted its PatchPal coding agent to run Gemma 4 E4B or Qwen3.5 4B through Ollama on a 6GB RTX A1000, using handoff-note compaction and capped file reads to work inside a 16K or 32K window.

WiseProbe Blog · 2026-11-25

Local AI: a one-click Windows app that picks a model for your PC and sets up Ollama for friends

Tired of setting up local LLMs for friends, a developer built a free MIT-licensed Windows app that detects your GPU and RAM, installs Ollama without admin rights, pulls a fitting model and opens a private chat.

Oleg Che (DEV Community) · 2026-11-04

rip: a local Gemma 2 2B writes epitaphs and revival ideas for your abandoned side projects

A Hacktoberfest CLI scans your folders for dormant projects and has Gemma 2 2B on Ollama write a witty obituary and a suggestion to revive each one, sending only metadata, never code.

razorbill (DEV Community) · 2026-11-03

Link Séance: a local Gemma 3 writes grounded epitaphs for the dead links in your bookmarks

Abdul AmberNeel built a command-line tool that checks every link in a bookmarks file, finds the last living Wayback Machine snapshot of dead ones, and has a local Gemma 3 write a two-sentence epitaph only from what the archive kept.

Abdul AmberNeel (DEV Community) · 2026-10-31