Blog
Home

Search the icon instead of generating it: AI stickers on Workers AI and Vectorize

2 December 2026 · 1 view

In a card editor on one of my sites you type a few words ("zebra", "cake") and get a line sticker. I first let a text model write the SVG path. No model I tried could do it. Searching a library of ready-made icons with embeddings worked. Measured on my own runs, not a benchmark.

Constraint

Stickers are 24 by 24 line drawings stored as path data. A check allows only path characters, a length limit, a command limit and numbers inside the drawing area, so whatever a model returns, only a line drawing gets through.

Text models drawing

Tried: Llama 4 Scout, Gemma 4 26B, GLM 4.7 Flash, Mistral Small 3.1, a Qwen coder model, Llama 3.3 70B, gpt-oss-120b.

  • Raw path data: valid syntax, no recognisable shape.
  • A JSON list of shapes converted to a path by my own code: same result. The converter was verified by rendering, the models were the problem.
  • The one good cat was my prompt example copied back. Test with subjects that are not in the prompt.
  • Showing the three nearest library icons as examples did not help for subjects without a near neighbour. gpt-oss-120b gave a zigzag for "zebra from the side".

The card editor with

What Gemma 4 drew for "arrow" after a code change made it return output at all. It works now, but the result is a crooked shape, not an arrow, as the editor itself warns.

Reasoning models return nothing

Gemma 4 and GLM returned choices with empty content. Thinking is paid out of max_tokens.

  • Reply shapes differ: response, choices[0].message.content, or the Responses API output list (gpt-oss). Read only the text of the message items.
  • gpt-oss takes input plus reasoning: { effort }.
  • Gemma 4 has chat_template_kwargs: { enable_thinking: false }. It is on by default, with no budget setting. 3000 tokens still gave an empty reply.
  • Usage comes as prompt_tokens/completion_tokens or input_tokens/output_tokens. completion_tokens_details.reasoning_tokens shows the thinking.
  • Do not retry an empty reply. It thinks as long and costs the same again.

What worked: search

  • Library: about 5,700 icons, Lucide (ISC) and Tabler outline (MIT). No brand logos, no -off variants. Paths rewritten with explicit command letters, because compact forms hide big numbers from the check.
  • Index: one vector per icon in a Vectorize namespace, @cf/baai/bge-m3. The text is the name and tags in English plus my own Portuguese and Spanish words. The path is in the vector metadata, so no icon is in the Worker bundle.
  • Query: one embedding and one Vectorize query. Ranking is mine: vector score, plus 0.2 for an exact tag or 0.08 when all words are in the tags. For a known Portuguese word the English icon name is queried too ("bolo" finds cake).
  • Cut-off: only icons within 0.12 of the best score and at least 0.52, at most four. Offline, the right icon scored 0.55 to 0.9 and an unrelated one up to about 0.5, so the gap does part of the work. Those numbers come from a quantised bge-m3 on a CPU, so check them on the deployed site.

Cost

  • Search: about 0.01 neuron.
  • Vectorize bills (stored + queries) * dimensions. A query adds one vector. 5,700 icons at 1024 dimensions are about 5.8M stored dimensions, counted once.
  • A drawing by a non reasoning text model: about 35 neurons, more with thinking.

What drew well

Z-Image Turbo gave the best drawing in a quick try-out on another site (fal.ai), not on Cloudflare. It returns an image that would still have to be converted to SVG. I could not use it on Workers AI, so I did not build it:

  • Not on Workers AI, so the typed words go to a third party.
  • An API key and a bill outside the neuron budget.
  • The result is a raster. It would be traced to path data in the browser (a Worker has a 10 ms CPU limit) and pass the same check.

Takeaways

  • If a good library exists, embeddings plus a ranking you control beat generation on quality and cost.
  • A strict output check makes every experiment safe.
  • Log numbers, never text: finish reason, tokens written, tokens thought.

Co-authored with Claude.

If this was useful, you can buy me a coffee.

New articles: follow via RSS.

Let's connect on LinkedIn.

Comments

← All articlesView as Markdown